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
modelsupplied, diff against the previous build and either apply in place or rebuild before running. Requiresio_api='direct'. Withassign=Truethe Result is written back to the target Model viaModel.assign_result().Coordinate alignment is checked on every dim by default. Pass
ignore_dimsto exclude dims whose coord values legitimately shift between solves.Pass
disallow_rebuild=Trueto guarantee that an existing solver model is updated in place — any condition that would force a rebuild (structural change, sparsity change, backend rejection, …) raisesRebuildRequiredErrorinstead. The initial build on the firstsolve(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.