Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

qiskit.optimization.converters.LinearEqualityToPenalty

class LinearEqualityToPenalty(penalty=None)

GitHub

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

Parameters

penalty (Optional[float]) – Penalty factor to scale equality constraints that are added to objective. If None is passed, penalty factor will be automatically calculated.

__init__

__init__(penalty=None)

Parameters

penalty (Optional[float]) – Penalty factor to scale equality constraints that are added to objective. If None is passed, penalty factor will be automatically calculated.


Methods

__init__([penalty])type penaltyOptional[float]
convert(problem)Convert a problem with equality constraints into an unconstrained problem.
decode(result)DEPRECATED Decode a result into another form using the information of conversion.
encode(problem)DEPRECATED Encode a QuadraticProgram into another form and keep the information required to decode the result.
interpret(result)Convert the result of the converted problem back to that of the original problem

Attributes

penaltyReturns the penalty factor used in conversion.

convert

convert(problem)

Convert a problem with equality constraints into an unconstrained problem.

Parameters

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

Return type

QuadraticProgram

Returns

The converted problem, that is an unconstrained problem.

Raises

QiskitOptimizationError – If an inequality constraint exists.

decode

decode(result)

DEPRECATED Decode a result into another form using the information of conversion.

Return type

OptimizationResult

encode

encode(problem)

DEPRECATED Encode a QuadraticProgram into another form and keep the information required to decode the result.

Return type

QuadraticProgram

interpret

interpret(result)

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

Parameters

result (OptimizationResult) – The result of the converted problem or the given result in case of FAILURE.

Return type

OptimizationResult

Returns

The result of the original problem.

Raises

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

penalty

Returns the penalty factor used in conversion.

Return type

Optional[float]

Returns

The penalty factor used in conversion.

Was this page helpful?
Report a bug or request content on GitHub.