# How to find Lagrange multipliers corresponding to constraints?

I have a constrained optimisation problem that I solved using Mathematica's FindMinimum function. I would like to know how to get the dual variables corresponding to the constraints I have. Obviously they will be zero for interior solutions and non-zero else, but I would like to look at them all the same.

My problem looks like this:

$\text{Lin}=\text{FindMinimum}\left[\left\{0.3 e^{-\text{z2}} \left(0.09 e^{-(x+\text{z1})}+0.3 e^{-y}\right)+0.09 e^{-(x+\text{z1})}+0.3 e^{-x}+0.3 e^{-y}+0.3 e^{-z},x+y+z+\text{z1}+\text{z2}\leq 100,x\geq 0,y\geq 0,z\geq 0,\text{z1}\geq 0,\text{z2}\geq 0\right\},\{x,y,z,\text{z1},\text{z2}\}\right]$

• From the FindMinimum result you can determine which are the binding constraints, and then write down the corresponding Lagrangian equation(s) and use NSolve or FindRoot to solve for the multipliers. – Daniel Lichtblau Jan 22 '15 at 19:39

A nice little function KT (based on Reduce) that provides both optimal variables and corresponding Lagrange multipliers for simple and small problems can be found here

The following code takes about 15sec to evaluate on my pc:

f = (3/10)*Exp[-z2]*((9/100)*Exp[-(x + z1)] + (3/10)*Exp[-y]) +
(9/100)*Exp[-(x + z1)] + (3/10)*Exp[-x] + (3/10)*Exp[-y] + (3/10)*Exp[-z];

cons={x + y + z + z1 + z2 <= 100, x >= 0, y >= 0, z >= 0, z1 >= 0, z2 >= 0};

KT[-f, cons, {x, y, z, z1, z2}]

x == 1/3 (100 - 3 Log[2] - 3 Log[5] - Log[13] + 2 Log[139]) &&
y == 1/3 (100 + 2 Log[13] - Log[139]) &&
z == 1/3 (100 + 3 Log[2] + 3 Log[5] - Log[13] - Log[139]) &&
z1 == 0 &&
z2 == 0 &&
\[Lambda][1] == (3 1807^(1/3))/(100 E^(100/3)) &&
\[Lambda][2] == 0 &&
\[Lambda][3] == 0 &&
\[Lambda][4] == 0 &&
\[Lambda][5] == (3 13^(1/3))/(139^(2/3) E^(100/3)) &&
\[Lambda][6] == 3819/(100 1807^(2/3) E^(100/3))


The multipliers correspond to the constraints as entered in cons, i.e., $\lambda_1$ corresponds to the sum constraint and the remaining multipliers to the non-negative constraints. Evaluating f for the above values gives 3.65942*10^-15.

On the other hand, using FindMinimum may give a local minimizer depending on the initial values as the following test case shows:

FindMinimum[{f,And@cons}, {{x, 10}, {y, 10}, {z, 10}, {z1, 10}, {z2, 10}}]

{9.68425*10^-7, {x -> 13.7422, y -> 13.7422, z -> 13.7423,
z1 -> 13.1105, z2 -> 13.1105}}