Skip to contents

A program holds a complete model as plain R lists, in the form the service reads: encode() turns it into bytes, and solve() and submit() accept it directly. as_program() converts a model() into a program. Building one by hand, with this function and the ones it links to, is for parts of the format that a model() does not offer, such as index sets and parameter tables.

Usage

program(
  sets = list(),
  indexed_sets = list(),
  params = list(),
  vars = list(),
  objective = NULL,
  sense = "min",
  constraints = list(),
  fix = list(),
  scenarios = 1,
  scenario_seed = 1,
  sources = list(),
  structures = list(),
  blocks = list()
)

Arguments

sets

A list of index_set()s.

indexed_sets

Sets that differ from position to position (see above).

params

Parameter tables (see above).

vars

A list of var_decl()s.

objective

The objective, an expression node (see ir).

sense

"min" or "max".

constraints

A list of constraint()s.

fix

Variables fixed at a value (see above).

scenarios

How many scenarios to draw, at least 1.

scenario_seed

The seed to draw them from, at least 1.

sources

The random variables: a named list of parametric() and empirical() declarations.

structures

The permutations and partitions: a named list of permutation_decl() and partition_decl() declarations.

blocks

The blocks (see block()): a named list, each element a list of ir_var() nodes, the block's variables.

Value

An object of class quicopt_program: a list with one element per argument, under the argument's name.

Details

Data indexed by positions is given as lists of entries, because a position (a list of numbers and strings) cannot be a name:

  • params maps the name of a parameter table to a list of entries list(key = <position>, value = <number>);

  • indexed_sets maps a name to a list of entries list(key = <position>, value = <list of elements>), a set that differs from position to position;

  • fix is a list of entries list(var = , index = , value = ), each fixing one variable at a value.

The order of the entries does not matter.

A model with random variables also needs sources, which declares them, and scenarios and scenario_seed, which say how many scenarios are drawn and from which seed. A model with permutations or partitions needs structures, and one with blocks blocks.