Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f8446d9
docs: silence HiGHS console output in tutorial notebooks
FBumann May 11, 2026
6d61112
docs: silence HiGHS console output in piecewise tutorials too
FBumann May 11, 2026
8d09ba9
Merge remote-tracking branch 'origin/master' into docs/silence-solver…
FBumann May 13, 2026
ae018a3
docs: fix broken toctree, refresh API reference, and clean up references
FBumann May 13, 2026
fe05bb1
docs: reorganize toctree into basic→advanced sections and rewrite use…
FBumann May 13, 2026
ce7c7b1
docs: fix broken admonitions in notebooks and configure intersphinx
FBumann May 13, 2026
e44cbd3
docs: downgrade coordinate-determination admonition from important to…
FBumann May 13, 2026
c5f9d4d
Revert "docs: downgrade coordinate-determination admonition from impo…
FBumann May 13, 2026
95b7e55
ci: empty commit to retrigger CI
FBumann May 13, 2026
94336ac
docs: rename toctree captions and reorder Examples below Solving
FBumann May 13, 2026
15aa6a4
docs: move Examples directly under User Guide
FBumann May 13, 2026
47db4be
docs: bridge Getting Started → User Guide and rename landing page H1
FBumann May 13, 2026
110ad81
docs: fix malformed first cell of solve-on-remote notebook
FBumann May 13, 2026
55867ac
docs: use markdown links for cross-refs in notebook markdown cells
FBumann May 13, 2026
2caac01
docs: collapse "Where to next" to a single pointer at the User Guide …
FBumann May 13, 2026
6cfa229
docs: restructure api.rst — task-oriented top, classes under the hood…
FBumann May 13, 2026
8e3885b
docs: add docstrings for properties surfaced in api.rst autosummary t…
FBumann May 13, 2026
a7efef2
docs: surface PWL_METHOD / PWL_CONVEXITY type aliases in api.rst
FBumann May 13, 2026
d4b20d3
docs: dissolve the api.rst Advanced umbrella; each item gets a natura…
FBumann May 13, 2026
1e33edd
docs: keep page TOC depth 2; expand right-side TOC to L2 site-wide
FBumann May 13, 2026
8954437
docs: rename "Classes and types" → "Other classes and types"
FBumann May 13, 2026
4c64672
docs: standardise H3 subgroup vocabulary across api.rst class sections
FBumann May 13, 2026
db02982
docs: revert show_toc_level=2 in book-theme options
FBumann May 13, 2026
91777fb
docs: restructure api.rst as Model-first and tighten the curated surface
FBumann May 13, 2026
955ef0b
docs: move piecewise construction helpers into the Piecewise section
FBumann May 13, 2026
2455b6c
docs: harmonise Variables container labels with Variable; fix preambl…
FBumann May 13, 2026
d949ec2
fix: api reference link
FBumann May 18, 2026
dda45c3
Merge branch 'master' into docs/reorganize-toctree
FBumann May 18, 2026
c189984
docs: add working-with-solvers notebook for the stateful Solver API
FBumann May 18, 2026
d4d662a
docs(solvers): drop hardcoded SolverReport coverage list
FBumann May 18, 2026
3c8c53a
docs(solvers): strip stray notebook outputs
FBumann May 18, 2026
87c32d6
docs(solvers): trim redundant cells, silence HiGHS logs
FBumann May 18, 2026
0f9f254
docs(solvers): surface the stateful Solver API in api.rst
FBumann May 18, 2026
5c03449
docs(solvers): rename notebook to using-solvers
FBumann May 18, 2026
1052c9d
docs(solvers): align notebook style with sibling notebooks
FBumann May 18, 2026
670aaf2
docs(solvers): restructure notebook around the common-case flow
FBumann May 18, 2026
a3b5b2e
Merge branch 'master' into docs/working-with-solvers
FBumann May 19, 2026
6810dca
docs(solvers): document Model-side transformation lifecycle
FBumann May 19, 2026
36ec167
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 19, 2026
e045a22
docs(solvers): drop TODO note, use try/finally for SOS apply/undo
FBumann May 19, 2026
651a896
docs(notebooks): strip ExecuteTime / execution metadata
FBumann May 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ Modifying a model
model.Model.remove_objective
model.Model.remove_sos_constraints
model.Model.copy
model.Model.apply_sos_reformulation
model.Model.undo_sos_reformulation
model.Model.reformulate_sos_constraints

Solving
Expand Down Expand Up @@ -498,10 +500,75 @@ Type aliases
Solvers
========

The stateful :class:`~linopy.solvers.Solver` instance owns the solver-side
model and exposes a two-step :meth:`~linopy.solvers.Solver.from_name` /
:meth:`~linopy.solvers.Solver.solve` workflow. :meth:`Model.solve` is a
thin wrapper around it.

.. autosummary::
:toctree: generated/

solvers.Solver

Construction
------------

.. autosummary::
:toctree: generated/

solvers.Solver.from_name
solvers.Solver.from_model

Solving
-------

.. autosummary::
:toctree: generated/

solvers.Solver.solve
solvers.Solver.update_solver_model
solvers.Solver.close

Post-solve state
----------------

.. autosummary::
:toctree: generated/

solvers.Solver.status
solvers.Solver.solution
solvers.Solver.report
solvers.Solver.solver_model

Capabilities
------------

.. autosummary::
:toctree: generated/

solvers.Solver.is_available
solvers.Solver.license_status
solvers.Solver.supports
solvers.Solver.supported_features
solvers.Solver.runtime_features

Discovery
---------

.. autosummary::
:toctree: generated/

solvers.available_solvers
solvers.licensed_solvers
solvers.SolverFeature
solvers.LicenseStatus

Implementations
---------------

.. autosummary::
:toctree: generated/

solvers.CBC
solvers.COPT
solvers.Cplex
Expand Down Expand Up @@ -529,7 +596,10 @@ Solver status and result types
==============================

Types returned by or compared against :attr:`Model.status`,
:attr:`Model.termination_condition`, and :attr:`Model.solution`.
:attr:`Model.termination_condition`, and :attr:`Model.solution`, plus
:class:`~linopy.constants.SolverReport` surfaced on
:attr:`Solver.report <linopy.solvers.Solver.report>` and
:attr:`Result.report <linopy.constants.Result.report>`.

.. autosummary::
:toctree: generated/
Expand All @@ -538,6 +608,7 @@ Types returned by or compared against :attr:`Model.status`,
constants.TerminationCondition
constants.Status
constants.Solution
constants.SolverReport
constants.Result


Expand Down
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ This package is published under MIT license.
:maxdepth: 2
:caption: Solving

using-solvers
solve-on-remote
solve-on-oetc
gpu-acceleration
Expand Down
7 changes: 4 additions & 3 deletions doc/sos-constraints.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,13 @@ as binary + linear constraints using the Big-M method.

.. code-block:: python

# Automatic reformulation during solve
# Automatic reformulation during solve (apply / undo bracketed by Model.solve)
m.solve(solver_name="highs", reformulate_sos=True)

# Or reformulate manually
m.reformulate_sos_constraints()
# Or stage the reformulation manually — e.g. to inspect or export the MILP
m.apply_sos_reformulation()
m.solve(solver_name="highs")
m.undo_sos_reformulation()

**Requirements:**

Expand Down
3 changes: 3 additions & 0 deletions doc/using-solvers.nblink
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../examples/using-solvers.ipynb"
}
117 changes: 85 additions & 32 deletions examples/create-a-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "dramatic-cannon",
"metadata": {},
"source": [],
"outputs": [],
"source": []
"execution_count": null
},
{
"attachments": {},
Expand All @@ -49,15 +49,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "technical-conducting",
"metadata": {},
"outputs": [],
"source": [
"from linopy import Model\n",
"\n",
"m = Model()"
]
],
"outputs": [],
"execution_count": null
},
{
"attachments": {},
Expand All @@ -83,14 +83,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "protecting-power",
"metadata": {},
"outputs": [],
"source": [
"x = m.add_variables(lower=0, name=\"x\")\n",
"y = m.add_variables(lower=0, name=\"y\");"
]
],
"outputs": [],
"execution_count": null
},
{
"attachments": {},
Expand All @@ -103,13 +103,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "virtual-anxiety",
"metadata": {},
"outputs": [],
"source": [
"x"
]
],
"outputs": [],
"execution_count": null
},
{
"attachments": {},
Expand All @@ -127,13 +127,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "fbb46cad",
"metadata": {},
"outputs": [],
"source": [
"3 * x + 7 * y >= 10"
]
],
"outputs": [],
"execution_count": null
},
{
"attachments": {},
Expand All @@ -146,13 +146,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "60f41b76",
"metadata": {},
"outputs": [],
"source": [
"3 * x + 7 * y - 10 >= 0"
]
],
"outputs": [],
"execution_count": null
},
{
"attachments": {},
Expand All @@ -167,14 +167,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "hollywood-production",
"metadata": {},
"outputs": [],
"source": [
"m.add_constraints(3 * x + 7 * y >= 10)\n",
"m.add_constraints(5 * x + 2 * y >= 3);"
]
],
"outputs": [],
"execution_count": null
},
{
"attachments": {},
Expand All @@ -189,13 +189,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "overall-exhibition",
"metadata": {},
"outputs": [],
"source": [
"m.add_objective(x + 2 * y)"
]
],
"outputs": [],
"execution_count": null
},
{
"attachments": {},
Expand All @@ -210,13 +210,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "pressing-copying",
"metadata": {},
"outputs": [],
"source": [
"m.solve(solver_name=\"highs\", output_flag=False)"
]
],
"outputs": [],
"execution_count": null
},
{
"attachments": {},
Expand All @@ -229,23 +229,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "electric-duration",
"metadata": {},
"outputs": [],
"source": [
"x.solution"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"execution_count": null,
"id": "e6d31751",
"metadata": {},
"outputs": [],
"source": [
"y.solution"
]
],
"outputs": [],
"execution_count": null
},
{
"attachments": {},
Expand All @@ -255,6 +255,59 @@
"source": [
"Well done! You solved your first linopy model!"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "f2dc93fa",
"metadata": {},
"source": [
"After solving, the solver instance stays attached to the model as `model.solver`, including a small report (runtime, MIP gap, dual bound, iterations) on solvers that populate it:"
]
},
{
"cell_type": "code",
"id": "21edcd3f",
"metadata": {},
"source": [
"m.solver"
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"id": "91a26989",
"metadata": {},
"source": [
"m.solver.report"
],
"outputs": [],
"execution_count": null
},
{
"attachments": {},
"cell_type": "markdown",
"id": "58965d32",
"source": "Some solvers hold a license while the underlying handle is alive. Release it with `solver.close()` (or `model.solver = None` to also detach the wrapper):",
"metadata": {}
},
{
"cell_type": "code",
"id": "d9c736c6",
"source": "m.solver.close()",
"metadata": {},
"outputs": [],
"execution_count": null
},
{
"attachments": {},
"cell_type": "markdown",
"id": "513277f1",
"metadata": {},
"source": [
"For more on choosing a solver, the construct-then-solve API, and querying solver capabilities, see [Using solvers](using-solvers.ipynb)."
]
}
],
"metadata": {
Expand Down
Loading
Loading