LinearEqualityToPenalty#

class LinearEqualityToPenalty(penalty=None)[source]#

Bases: QuadraticProgramConverter

Convert a problem with only equality constraints to unconstrained with penalty terms.

Parameters:

penalty (float | None) – Penalty factor to scale equality constraints that are added to objective. If None is passed, a penalty factor will be automatically calculated on every conversion.

Attributes

penalty#

Returns the penalty factor used in conversion.

Returns:

The penalty factor used in conversion.

Methods

convert(problem)[source]#

Convert a problem with equality constraints into an unconstrained problem.

Parameters:

problem (QuadraticProgram) – The problem to be solved, that does not contain inequality constraints.

Returns:

The converted problem, that is an unconstrained problem.

Raises:

QiskitOptimizationError – If an inequality constraint exists.

Return type:

QuadraticProgram

interpret(x)[source]#

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

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:

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

Return type:

ndarray