Skip to contents

A model owns decision variables, an objective, constraint rows, and — for a model under uncertainty — random variables and a scenario count. Declare variables with num_var(), int_var(), bin_var() and rand_var(), state the goal with minimize() or maximize(), add constraints with add(), and hand the model to solve().

Usage

model()

Value

A model, an environment of class quicopt_model.

Details

Every setter both mutates the model and returns it invisibly, so the imperative style and the pipe are the same functions:

m <- model()
x <- num_var(m, "x", 0, 4)          # handle style

m <- model() |>                     # pipe style; m$x retrieves the handle
  add_var("x", 0, 4)

Note the pipe mutates its input — the model is one shared object, not a value being copied along the chain.