SlsqpOptimizer#
- class SlsqpOptimizer(iter=100, acc=1e-06, iprint=0, trials=1, clip=100.0, full_output=False)[ソース]#
ベースクラス:
MultiStartOptimizer
The SciPy SLSQP optimizer wrapped as an Qiskit
OptimizationAlgorithm
.This class provides a wrapper for
scipy.optimize.fmin_slsqp
(https://docs.scipy.org/doc/scipy-0.13.0/reference/generated/scipy.optimize.fmin_slsqp.html) to be used within the optimization module. The arguments forfmin_slsqp
are passed via the constructor.サンプル
>>> from qiskit_optimization.problems import QuadraticProgram >>> from qiskit_optimization.algorithms import SlsqpOptimizer >>> problem = QuadraticProgram() >>> # specify problem here >>> x = problem.continuous_var(name="x") >>> y = problem.continuous_var(name="y") >>> problem.maximize(linear=[2, 0], quadratic=[[-1, 2], [0, -2]]) >>> optimizer = SlsqpOptimizer() >>> result = optimizer.solve(problem)
Initializes the SlsqpOptimizer.
This initializer takes the algorithmic parameters of SLSQP and stores them for later use of
fmin_slsqp
whensolve()
is invoked. This optimizer can be applied to find a (local) optimum for problems consisting of only continuous variables.- パラメータ:
iter (int) – The maximum number of iterations.
acc (float) – Requested accuracy.
iprint (int) –
The verbosity of fmin_slsqp :
iprint <= 0 : Silent operation
iprint == 1 : Print summary upon completion (default)
iprint >= 2 : Print status of each iterate and summary
trials (int) – The number of trials for multi-start method. The first trial is solved with the initial guess of zero. If more than one trial is specified then initial guesses are uniformly drawn from
[lowerbound, upperbound]
with potential clipping.clip (float) – Clipping parameter for the initial guesses in the multi-start method. If a variable is unbounded then the lower bound and/or upper bound are replaced with the
-clip
orclip
values correspondingly for the initial guesses.full_output (bool) – If
False
, return only the minimizer of func (default). Otherwise, output final objective function and summary information.
Attributes
- clip#
Returns the clip value for this optimizer.
- 戻り値:
The clip value.
- trials#
Returns the number of trials for this optimizer.
- 戻り値:
The number of trials.
Methods
- get_compatibility_msg(problem)[ソース]#
Checks whether a given problem can be solved with this optimizer.
Checks whether the given problem is compatible, i.e., whether the problem contains only continuous variables, and otherwise, returns a message explaining the incompatibility.
- パラメータ:
problem (QuadraticProgram) – The optimization problem to check compatibility.
- 戻り値:
Returns a string describing the incompatibility.
- 戻り値の型:
- is_compatible(problem)#
Checks whether a given problem can be solved with the optimizer implementing this method.
- パラメータ:
problem (QuadraticProgram) – The optimization problem to check compatibility.
- 戻り値:
Returns True if the problem is compatible, False otherwise.
- 戻り値の型:
- multi_start_solve(minimize, problem)#
Applies a multi start method given a local optimizer.
- パラメータ:
- 戻り値:
The result of the multi start algorithm applied to the problem.
- 戻り値の型:
- solve(problem)[ソース]#
Tries to solves the given problem using the optimizer.
Runs the optimizer to try to solve the optimization problem.
- パラメータ:
problem (QuadraticProgram) – The problem to be solved.
- 戻り値:
The result of the optimizer applied to the problem.
- 例外:
QiskitOptimizationError – If the problem is incompatible with the optimizer.
- 戻り値の型: