Worked models
nimopt.models contains ten models. Each is a module with three functions.
| Name | Returns |
|---|---|
definition() | a Definition: the formulation with no data bound |
data(scale=1) | the inputs, at a given size |
reference(data) | the optimal objective, computed by direct arithmetic |
The three functions have different callers. This documentation calls
explain(), a benchmark calls build(data(100)), and a test compares a
solve against reference(data(1)). A reference is arithmetic over the inputs
and calls nothing from nimopt. A formulation error is therefore not checked
against a copy of itself.
| Model | Exercises |
|---|---|
dispatch | the baseline formulation |
transport | a sparse network over a subset of a product |
storage | temporal coupling and a cyclic lag |
nodal | grouping through a lookup parameter |
commitment | binary columns |
fleet | many small declarations rather than one large one |
profiled | a bound that varies by hour |
sector | mixed density: dense in one axis, sparse in another |
expansion | a two-stage stochastic program: capacity before the scenario, dispatch after |
recourse | a binary first stage taken before the scenario is known |
from nimopt.models import dispatch
inputs = dispatch.data()
solution = dispatch.definition().build(inputs).solve()
print(solution.status, solution.objective, dispatch.reference(inputs))
Output
optimal 1920.0 1920.0