A model collects everything the service needs to find the best decision:
the decisions to be made, the objective, the constraints and, when some of
the data is uncertain, the random variables and the number of scenarios.
model() creates an empty one, and these functions fill it:
Details
decisions:
num_var(),int_var(),bin_var(),perm_var()for an ordering andpart_var()for a division into groups;subproblems:
block();uncertain data:
rand_var()andset_empirical();the objective:
minimize()ormaximize();constraints:
add().
solve() then sends the model to the service. m$name retrieves a
variable declared in m by its name, and printing a model shows a short
summary of it.
Each of the functions above changes the model in place and returns it invisibly, so a model can also be written as a pipe:
Unlike most R objects, a model is not copied when it is passed to a
function. After m2 <- m |> add(m$x <= 3), m has the constraint too,
and m2 and m are the same model.