linopy.solvers.Solver#
- class linopy.solvers.Solver(model=None, io_api=None, options=<factory>, track_updates=False)#
Abstract base class for solving a given linear problem.
Subclasses provide
_build_direct/_run_direct(when supporting the direct API) and_run_file(when supporting LP/MPS files). Construction goes viaSolver.from_name()orSolver.from_model().track_updatestoggles persistent-update support:False(default) — one-shot mode. NoModelSnapshotis captured at build time; any latersolve(model=...)orupdate(model)raisesUpdatesDisabledError. Use for throw-away solver instances and high-levelModel.solve(...).True— long-lived mode. A snapshot is captured at build time and re-captured after each successful in-place update, enabling diff-basedsolve(model=...)/update(model)across iterations.
- __init__(model=None, io_api=None, options=<factory>, track_updates=False)#
Methods
__init__([model, io_api, options, track_updates])apply_update(diff, var_label_index, ...)Apply an in-place
ModelDiffto the built native model.close()Dispose the native solver model and env, releasing any held license.
from_model(model[, io_api, options, ...])Instantiate and build the solver against
model.from_name(name[, model, io_api, options, ...])Construct the solver subclass registered as
name.Return True if this solver's package/binary is importable.
Probe license/runtime availability.
Features whose availability depends on the installed solver version or runtime environment.
safe_get_solution(status, func)Get solution from function call, if status is unknown still try to run it.
solve([model, assign, ignore_dims, ...])Run the prepared solver and return a
Result.solve_problem([model, problem_fn, ...])Deprecated.
solve_problem_from_file(problem_fn[, ...])Deprecated shim that caches
problem_fnand runs via_run_file.solve_problem_from_model(model[, ...])Deprecated shim that builds via
_build_directand runs via_run_direct.All features supported by this solver, static plus runtime.
supports(feature)Check if this solver supports a given feature.
update(model[, apply, ignore_dims])Diff
modelagainst the solver state and optionally apply it.update_solver_model(model, **kwargs)Attributes
accepted_io_apisdisplay_nameenvfeaturesio_apimodelsensesnapshotsolver_namesolver_optionssupports_persistent_updatesupports_sign_updatetrack_updatesoptions