CplexOptimizer#

class CplexOptimizer(disp=False, cplex_parameters=None)[fuente]#

Bases: 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.

Ejemplos

>>> 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.

Parámetros:

Attributes

cplex_parameters#

Returns parameters for CPLEX

disp#

Returns the display setting.

Devuelve:

Whether to print CPLEX information or not.

Methods

get_compatibility_msg(problem)[fuente]#

Checks whether a given problem can be solved with this optimizer.

Returns '' since CPLEX accepts all problems that can be modeled using the QuadraticProgram. CPLEX may throw an exception in case the problem is determined to be non-convex.

Parámetros:

problem (QuadraticProgram) – The optimization problem to check compatibility.

Devuelve:

An empty string.

Tipo del valor devuelto:

str

is_compatible(problem)#

Checks whether a given problem can be solved with the optimizer implementing this method.

Parámetros:

problem (QuadraticProgram) – The optimization problem to check compatibility.

Devuelve:

Returns True if the problem is compatible, False otherwise.

Tipo del valor devuelto:

bool

static is_cplex_installed()[fuente]#

Returns True if cplex is installed

solve(problem)[fuente]#

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.

Parámetros:

problem (QuadraticProgram) – The problem to be solved.

Devuelve:

The result of the optimizer applied to the problem.

Muestra:

QiskitOptimizationError – If the problem is incompatible with the optimizer.

Tipo del valor devuelto:

OptimizationResult