qilisdk.utils.classical_solvers.scipy_solver
Classes
Classical solver that uses SciPy to minimize the model's objective. |
Module Contents
- class ScipySolver(method: str | Callable | None = None, **kwargs: dict[str, Any])[fuente]
Bases:
qilisdk.utils.classical_solvers.base_solver.ClassicalSolverClassical solver that uses SciPy to minimize the model’s objective.
This uses the existing QiliSDK SciPyOptimizer (the one used for variational algorithms) to optimize the model function.
Ejemplo
from qilisdk.core import Model from qilisdk.utils.classical_solvers import ScipySolver model = Model.knapsack(values=[5, 4], weights=[3, 2], max_weight=3) result = ScipySolver(method="l-bfgs-b").solve(model)Create a new SciPy based classical solver instance.
- Parámetros:
method (
str | Callable | None, optional) – The SciPy optimizer to use. SeeSciPyOptimizerfor the full list of supported methods. If not given, SciPy chooses a default local minimizer.
- Extra Args:
Any argument supported by
scipy.optimize.minimize(or the corresponding global optimizer) can be passed and is forwarded to the underlyingSciPyOptimizer.
- method = None[fuente]
- extra_arguments[fuente]
- solve(model: qilisdk.core.Model) qilisdk.utils.classical_solvers.base_solver.ClassicalSolverResult[fuente]
Solve the given model by minimizing its objective with SciPy.
- Parámetros:
model – The
Modelinstance to solve.- Devuelve:
the results of the optimization, including the objective value and best solution.
- Tipo del valor devuelto:
- Muestra:
ValueError – if the model contains a variable that is not a BinaryVariable, a SpinVariable or a Variable.