## 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 bounds

• `upper`, associated with upper bounds

• `eqlin`, associated with linear equalities

• `ineqlin`, associated with linear inequalities

• `eqnonlin`, associated with nonlinear equalities

• `ineqnonlin`, associated with nonlinear inequalities

• `soc`, 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` and `lambda.eqnonlin` fields have size 0 because there are no linear equality constraints and no nonlinear equality constraints.

• The `lambda.ineqlin` field has value `0.3407`, indicating that the linear inequality constraint is active. The linear inequality constraint is ```x(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` and `lambda.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 is `1.7038e-07`, indicating that this constraint is not active. Check the constraint, which is ```x(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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.77503926,"math_prob":0.99779016,"size":2980,"snap":"2023-40-2023-50","text_gpt3_token_len":807,"char_repetition_ratio":0.16364247,"word_repetition_ratio":0.0,"special_character_ratio":0.26409397,"punctuation_ratio":0.17460318,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99734306,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-02T10:06:42Z\",\"WARC-Record-ID\":\"<urn:uuid:636426b9-4b9d-416d-a41c-44a2ab98f0b8>\",\"Content-Length\":\"72690\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:78ff0053-02a0-4244-9dee-a0d5aed766f0>\",\"WARC-Concurrent-To\":\"<urn:uuid:57a97032-93e5-4671-8788-f90c2040e72c>\",\"WARC-IP-Address\":\"104.86.80.92\",\"WARC-Target-URI\":\"https://ch.mathworks.com/help/optim/ug/lagrange-multiplier-structures.html\",\"WARC-Payload-Digest\":\"sha1:ZOZFJHCDTCXVW6XLO5N6ZT5THSAXW7LI\",\"WARC-Block-Digest\":\"sha1:7T4O6VVNPEV7SYYYUWT52WDE5MUTNT5E\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100381.14_warc_CC-MAIN-20231202073445-20231202103445-00709.warc.gz\"}"}