CplexOptimizer#
- class CplexOptimizer(disp=False, cplex_parameters=None)[ソース]#
ベースクラス:
OptimizationAlgorithm
The CPLEX optimizer wrapped as an Qiskit
OptimizationAlgorithm
.This class provides a wrapper for
cplex.Cplex
(https://pypi.org/project/cplex/) to be used within the optimization module.サンプル
>>> from qiskit_optimization.problems import QuadraticProgram >>> from qiskit_optimization.algorithms import CplexOptimizer >>> problem = QuadraticProgram() >>> # specify problem here, if cplex is installed >>> optimizer = CplexOptimizer() if CplexOptimizer.is_cplex_installed() else None >>> if optimizer: result = optimizer.solve(problem)
Initializes the CplexOptimizer.
- パラメータ:
disp (bool) – Whether to print CPLEX output or not.
cplex_parameters (Dict[str, Any] | None) – The parameters for CPLEX. See https://www.ibm.com/docs/en/icos/20.1.0?topic=cplex-parameters for details.
Attributes
- cplex_parameters#
Returns parameters for CPLEX
- disp#
Returns the display setting.
- 戻り値:
Whether to print CPLEX information or not.
Methods
- get_compatibility_msg(problem)[ソース]#
Checks whether a given problem can be solved with this optimizer.
Returns
''
since CPLEX accepts all problems that can be modeled using theQuadraticProgram
. CPLEX may throw an exception in case the problem is determined to be non-convex.- パラメータ:
problem (QuadraticProgram) – The optimization problem to check compatibility.
- 戻り値:
An empty string.
- 戻り値の型:
- 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.
- 戻り値の型:
- solve(problem)[ソース]#
Tries to solves the given problem using the optimizer.
Runs the optimizer to try to solve the optimization problem. If problem is not convex, this optimizer may raise an exception due to incompatibility, depending on the settings.
- パラメータ:
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.
- 戻り値の型: