Set the model objective

set_objective(model, expression, direction = c("max", "min"))

set_objective_(model, expression, direction = c("max", "min"))

Arguments

model
the model
expression
the linear objective as a sum of variables and constants
direction
the optimization direction. Must be either "max" or "min".

Value

a Model with a new objective function definition

Examples

library(magrittr) MIPModel() %>% add_variable(x, lb = 2) %>% add_variable(y, lb = 40) %>% set_objective(x + y, direction = "min")
#> Mixed linear integer optimization problem #> Variables: #> Continuous: 2 #> Integer: 0 #> Binary: 0 #> Search direction: minimize #> Constraints: 0