qiskit_addon_opt_mapper.converters.MaximizeToMinimize

class MaximizeToMinimize[source]

Bases: _FlipProblemSense

Convert a maximization problem to a minimization problem only if it is a maximization problem.

Otherwise problem’s sense is unchanged.

__init__()[source]
Return type:

None

Methods

__init__()

convert(problem)

Flip the sense of a problem.

interpret(x)

Convert the result of the converted problem back to that of the original problem.

convert(problem)[source]

Flip the sense of a problem.

Parameters:

problem (OptimizationProblem) – The problem to be flipped.

Returns:

A converted problem, that has the flipped sense.

Return type:

OptimizationProblem

interpret(x)[source]

Convert the result of the converted problem back to that of the original problem.

Note: This implementation does not modify the result, but the method is required because the base class defines interpret as an abstract method.

Parameters:

x (ndarray | list[float]) – The result of the converted problem or the given result in case of FAILURE.

Returns:

The result of the original problem.

Raises:

OptimizationError – if the number of variables in the result differs from that of the original problem.

Return type:

ndarray