Fix a quantity that is data in one model and a decision in another#
Write one spec in which a quantity, such as a plant's size, is chosen by the solver in one study and given by the data in another. The file does not change between the two. The data does.
- Declare the quantity as a variable, with named bounds.
dimensions:
plant: { dtype: str }
parameters:
size_min: { dims: [plant] }
size_max: { dims: [plant] }
variables:
size:
dims: [plant]
bounds: { lower: size_min, upper: size_max }
-
Write every rule against the variable.
rate - relmax * size <= 0is one equation whethersizeis chosen or given. -
Pin it in the data where it is given. Attach
size_minandsize_maxas the same value for a plant whose size is fixed. Equal bounds pin a variable (variables).
A pinned variable is still a variable: size * on is variable * variable,
and size cannot stand in another variable's bounds:. Where a bound has to
come from it, ship the column as a parameter too.
Fix it in the spec instead#
Where a driver decides the quantity and the model it solves must not, call
spec.fix. A Benders subproblem, a
myopic step and a rolling window each do this:
size becomes a parameter under the same name, so every expression goes on
reading it. Its bounds become the assumption size_within_bounds. A
constraint that named only size becomes an assumption too, because it now
compares numbers. Where size has a where: and absence: undefined, each
row that reads it outside a sum has to stand under that mask: fix adds the
mask to a constraint's where:, or refuses and names the reader.