Lagrange Multiplier Structures
Constrained optimization involves a set of Lagrange multipliers, as described in First-Order Optimality Measure. Solvers return estimated Lagrange
multipliers in a structure. The structure is called lambda
because
the conventional symbol for Lagrange multipliers is the Greek letter lambda
(λ). The structure separates the multipliers into the following
types, called fields:
lower
, associated with lower boundsupper
, associated with upper boundseqlin
, associated with linear equalitiesineqlin
, associated with linear inequalitieseqnonlin
, associated with nonlinear equalitiesineqnonlin
, associated with nonlinear inequalitiessoc
, associated with second-order cone constraints
To access, for example, the nonlinear inequality field of a Lagrange multiplier
structure, enter lambda.inqnonlin
. To access the third element of the
Lagrange multiplier associated with lower bounds, enter
lambda.lower(3)
.
The content of the Lagrange multiplier structure depends on the solver. For example,
linear programming has no nonlinearities, so it does not have
eqnonlin
or ineqnonlin
fields. Each applicable
solver's function reference pages contains a description of its Lagrange multiplier
structure under the heading “Outputs.”
Examine the Lagrange multiplier structure for the solution of a nonlinear problem with linear and nonlinear inequality constraints and bounds.
lb = [-3 -3]; % lower bounds ub = [3 3]; % upper bounds A = [1 1]; % linear inequality x(1) + x(2) <= 1 b = 1; Aeq = []; beq = []; x0 = [-1 1]; fun = @(x)100*(x(2) - x(1)^2)^2 + (1 - x(1))^2; % Rosenbrock function nlcons = @(x)deal(x(1)^2 + x(2)^2 - 1,[]); % nonlinear inequality options = optimoptions('fmincon','Display','off'); [x,fval,exitflag,output,lambda] = ... fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nlcons,options); disp(lambda)
eqlin: [0×1 double] eqnonlin: [0×1 double] ineqlin: 0.3407 lower: [2×1 double] upper: [2×1 double] ineqnonlin: 1.7038e-07
Here is an interpretation of the Lagrange multiplier structure.
The
lambda.eqlin
andlambda.eqnonlin
fields have size 0 because there are no linear equality constraints and no nonlinear equality constraints.The
lambda.ineqlin
field has value0.3407
, indicating that the linear inequality constraint is active. The linear inequality constraint isx(1) + x(2) <= 1
. Check that the constraint is active at the solution, meaning the solution causes the inequality to be an equality:x(1) + x(2)
ans = 1.0000
Check the values of the
lambda.lower
andlambda.upper
fields.lambda.lower
ans = 1.0e-07 * 0.2210 0.2365
lambda.upper
ans = 1.0e-07 * 0.3361 0.3056
These values are effectively zero, indicating that the solution is not near the bounds.
The value of the
lambda.ineqnonlin
field is1.7038e-07
, indicating that this constraint is not active. Check the constraint, which isx(1)^2 + x(2)^2 <= 1
.x(1)^2 + x(2)^2
ans = 0.5282
The nonlinear constraint function value is not near its limit, so the Lagrange multiplier is approximately 0.