Optimization API¶
The programmatic interface used to build and solve the model. solve is the one-line
convenience wrapper over the model classes; load_inputs assembles the input
dataset without solving, for inspection.
The mathematical optimization problem — objective function and constraints — is documented separately in the Methodology section.
solve¶
microgridspy.solve(project_name, *, formulation=None, solver='highs', **solver_kwargs)
¶
Build and solve a project, returning the solved model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name
|
str
|
the project folder in the active workspace. |
required |
formulation
|
str | None
|
|
None
|
solver
|
str
|
|
'highs'
|
**solver_kwargs
|
Any
|
forwarded to
|
{}
|
Returns:
| Type | Description |
|---|---|
AnyModel
|
The solved model instance, ready for |
AnyModel
|
|
solve_example¶
One-call end-to-end quick start over the bundled examples —
works straight after pip install.
microgridspy.solve_example(name='demo_typical_year', *, solver='highs', dest=None, overwrite=True, **solver_kwargs)
¶
Load a bundled example project and solve it, end-to-end.
A one-call quick start that works straight after pip install (no repository
clone needed): it copies the example into the active workspace and solves it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
the bundled example to run (see
|
'demo_typical_year'
|
solver
|
str
|
|
'highs'
|
dest
|
str | None
|
destination project name; defaults to |
None
|
overwrite
|
bool
|
replace the destination project if it already exists (default True, so the example is re-runnable). |
True
|
**solver_kwargs
|
Any
|
forwarded to the model's |
{}
|
Returns:
| Type | Description |
|---|---|
AnyModel
|
The solved model instance, ready for |
load_inputs¶
microgridspy.load_inputs(project_name, *, formulation=None)
¶
Assemble and return a project's input dataset, without solving.
Builds the sets and data layers (the same inputs a model would use), so you can inspect the assembled xarray Dataset directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name
|
str
|
the project to read. |
required |
formulation
|
str | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: the assembled input dataset. |