gemseo / algos

Hide inherited members

lagrange_multipliers module

Implementation of the Lagrange multipliers.

class gemseo.algos.lagrange_multipliers.LagrangeMultipliers(opt_problem)[source]

Bases: object

Class that implements the computation of Lagrange Multipliers.

Denote \(x^\ast\) an optimal solution of the optimization problem below.

\[\begin{split}\begin{aligned} & \text{Minimize} & & f(x) \\ & \text{relative to} & & x \\ & \text{subject to} & & \left\{\begin{aligned} & g(x)\le0, \\ & h(x)=0, \\ & \ell\le x\le u. \end{aligned}\right. \end{aligned}\end{split}\]

If the constraints are qualified at \(x^\ast\) then the Lagrange multipliers of \(x^\ast\) are the vectors \(\lambda_g\), \(\lambda_h\), \(\lambda_\ell\) and \(\lambda_u\) satisfying

\[\begin{split}\left\{\begin{aligned} &\frac{\partial f}{\partial x}(x^\ast) +\lambda_g^\top\frac{\partial g}{\partial x}(x^\ast) +\lambda_h^\top\frac{\partial h}{\partial x}(x^\ast) +\sum_j\lambda_{\ell,j}+\sum_j\lambda_{u,j} =0,\\ &\lambda_{g,i}\ge0\text{ if }g_i(x^\ast)=0, \text{ otherwise }\lambda_{g,i}=0,\\ &\lambda_{\ell,j}\le0\text{ if }x^\ast_j=\ell_j, \text{ otherwise }\lambda_{\ell,j}=0,\\ &\lambda_{u,j}\ge0\text{ if }x^\ast_j=u_j, \text{ otherwise }\lambda_{u,j}=0. \end{aligned}\right.\end{split}\]
Parameters:

opt_problem (OptimizationProblem) – The optimization problem on which Lagrange multipliers shall be computed.

compute(x_vect, ineq_tolerance=1e-06, rcond=-1)[source]

Compute the Lagrange multipliers, as a post-processing of the optimal point.

This solves:

(d ActiveConstraints)’ d Objective (——————-) . Lambda = - ———– (d X ) d X

Parameters:
  • x_vect (ndarray) – The optimal point on which the multipliers shall be computed.

  • ineq_tolerance (float) –

    The tolerance on inequality constraints.

    By default it is set to 1e-06.

  • rcond (float) –

    The cut-off ratio for small singular values of the Jacobian (see scipy.linalg.lsq).

    By default it is set to -1.

Returns:

The Lagrange multipliers.

Return type:

dict[str, tuple[list[str], ndarray]]

get_multipliers_arrays()[source]

Return the Lagrange multipliers (zero and nonzero) as arrays.

Returns:

The Lagrange multipliers.

Return type:

dict[str, dict[str, ndarray]]

get_objective_jacobian(x_vect)[source]

Return the Jacobian of the objective.

Parameters:

x_vect (ndarray) – The point at which the Jacobian is computed.

Returns:

The Jacobian of the objective.

Return type:

ndarray

CSTR_LABELS: ClassVar[list[str]] = ['lower_bounds', 'upper_bounds', 'inequality', 'equality']
EQUALITY = 'equality'
INEQUALITY = 'inequality'
LOWER_BOUNDS = 'lower_bounds'
UPPER_BOUNDS = 'upper_bounds'
constraint_violation: float | None

The maximum constraint violation (taking tolerances into account), None if not computed.

kkt_residual: float | None

The residual of the KKT conditions, None if not computed.