linopy.solvers.Solver.solve

Contents

linopy.solvers.Solver.solve#

Solver.solve(model=None, assign=False, ignore_dims=(), disallow_rebuild=False, **run_kwargs)#

Run the prepared solver and return a Result.

With model supplied, diff against the previous build and either apply in place or rebuild before running. Requires io_api='direct'. With assign=True the Result is written back to the target Model via Model.assign_result().

Coordinate alignment is checked on every dim by default. Pass ignore_dims to exclude dims whose coord values legitimately shift between solves.

Pass disallow_rebuild=True to guarantee that an existing solver model is updated in place — any condition that would force a rebuild (structural change, sparsity change, backend rejection, …) raises RebuildRequiredError instead. The initial build on the first solve(model, ...) is still allowed.

Thread safety: the solver lock is held for the entire call, including the native run. This is deliberate — diff/apply and the run must be atomic (otherwise a concurrent apply would change the problem between apply and run), and native solver handles are not thread-safe. Concurrent solves therefore serialize per Solver instance; use separate instances for parallelism. Pure diff computation (update(model, apply=False)) does not take the lock.