Skip to contents

Convenience wrapper around set_solver that stores solver = "gurobi" in the problem object.

This function does not solve the model. It only updates the stored solver configuration.

Usage

set_solver_gurobi(
  x,
  ...,
  solver_params = list(),
  gap_limit = NULL,
  time_limit = NULL,
  solution_limit = NULL,
  cores = NULL,
  verbose = FALSE,
  log_file = NULL,
  write_log = NULL
)

Arguments

x

A Problem object.

...

Additional named solver-specific parameters. These are merged into solver_params. For example, MIPFocus = 1 for Gurobi.

solver_params

Named list of solver-specific parameters. These are merged with previously stored backend-specific parameters rather than replacing them completely.

gap_limit

Optional numeric value in \([0,1]\) giving the relative optimality gap for mixed-integer optimization. If NULL, the previously stored value is kept unchanged.

time_limit

Optional non-negative numeric value giving the maximum solving time in seconds. If NULL, the previously stored value is kept unchanged.

solution_limit

Optional logical flag controlling backend-specific early stopping after feasible solution discovery. If NULL, the previously stored value is kept unchanged.

cores

Optional positive integer giving the number of CPU cores to use. If NULL, the previously stored value is kept unchanged.

verbose

Optional logical flag indicating whether the solver should print log output. If NULL, the previously stored value is kept unchanged.

log_file

Optional character string giving the name of the solver log file. If NULL, the previously stored value is kept unchanged.

write_log

Optional logical flag indicating whether solver output should be written to a file. If NULL, the previously stored value is kept unchanged.

Value

An updated Problem object with Gurobi solver settings stored in x$data$solve_args.

See also

Examples

pu_tbl <- data.frame(
  id = 1:4,
  cost = c(1, 2, 3, 4)
)

feat_tbl <- data.frame(
  id = 1:2,
  name = c("feature_1", "feature_2")
)

dist_feat_tbl <- data.frame(
  pu = c(1, 1, 2, 3, 4),
  feature = c(1, 2, 2, 1, 2),
  amount = c(5, 2, 3, 4, 1)
)

x <- create_problem(
  pu = pu_tbl,
  features = feat_tbl,
  dist_features = dist_feat_tbl,
  cost = "cost"
)

x <- set_solver_gurobi(
  x,
  gap_limit = 0.01,
  time_limit = 600,
  cores = 2,
  MIPFocus = 1
)

x$data$solve_args
#> $solver
#> [1] "gurobi"
#> 
#> $gap_limit
#> [1] 0.01
#> 
#> $time_limit
#> [1] 600
#> 
#> $cores
#> [1] 2
#> 
#> $verbose
#> [1] FALSE
#> 
#> $solver_params
#> $solver_params$MIPFocus
#> [1] 1
#> 
#>