I got negative Lagrange Multipliers in linprog
2 views (last 30 days)
Show older comments
Hello,
I got negative Lagrange multipliers in lambda.upper after an successful run of linprog. But as far as I know, the multipliers have to be greater or equal than zero.
Here is my code:
Strassen = [
1, 8, 9.6, 500;
8, 7, 6.9, 300;
7, 3, 7.7, 300;
7, 9, 5.7, 300;
8, 9, 8.8, 50;
1,10, 12.5, 300;
8,11, 12.5, 500;
9, 4, 7.4, 200;
2,10, 12.4, 500;
10,11, 7.8, 100;
11, 4, 11.1, 500;
4,12, 12.5, 400;
10,14, 14.3, 400;
11,14, 9.0, 300;
11,13, 10.1, 200;
14,13, 8.2, 100;
13,12, 4.7, 100;
13, 5, 12.2, 500; % 100;
12, 5, 11.3, 300;
14, 6, 10.6, 500;
]; %row: (node_start, node_end, costs, upper_bound)
% build incidence matrix from Strassen(:,1:2)
E = Strassen(:,[1,2]); % matrix of edges (row-wise)
n = size(E,1); % number of edges
m = max(max(E)); % largest node = number of nodes (vertices)
Ain = zeros(m,n);
for i=1:n
Ain(E(i,1),i) = -1; Ain(E(i,2),i) = 1;
end
% now we have our incidence matrix Ain
% set rhs for Ain * x = b
b = [
-600;
-400;
100;
200;
400;
300;
0;0;0;0;0;0;0;0;
];
% cost vector
c = Strassen(:,3);
% lower and upper bounds
low = zeros(n,1);
upp = Strassen(:,4);
options = optimoptions('linprog','Algorithm','dual-simplex','display','iter');
% Aufruf des Optimierungsverfahrens
[xstar,fval,exitflag,output,lambda] = linprog(c,[],[],Ain,b,low,upp,[],options);
[lambda.upper, upp-xstar]
Can someone explain me this behaviour?
Thank in advance,
Tommy
1 Comment
Matt J
on 4 Jan 2023
Edited: Matt J
on 4 Jan 2023
Just as concerning, complementary slackness is not satisfied for the interior-point method,
options = optimoptions('linprog','Algorithm','interior-point','display','none');
[xstar,fval,exitflag,output,lambda] = linprog(c,[],[],Ain,b,low,upp,[],options);
comp_slack=[lambda.upper.*(xstar-upp), lambda.lower.*(low-xstar)]
Accepted Answer
Matt J
on 4 Jan 2023
Edited: Matt J
on 4 Jan 2023
I've changed my answer. I can't be completely sure, but it appears that your constraints have numerically unstable properties, that could explain the weird Lagrange multiplier behavior. If I widen your upper and lower bounds by a very small amount, the Lagrange multipliers change a great deal and (are all non-negative as they should be). Conversely, if I narrow the bounds even the slightest bit, the problem becames infeasible. This suggests that your equality-constrained region very narrowly intersects the box-constrainted region, making things unstable. I suspect that could be the reason for the weird Lagrange multiplier behavior.
options = optimoptions('linprog','Algorithm','dual-simplex','display','iter','ConstraintTol',1e-9);
epsilon=1e-6;
%narrow the bounds - problem becomes infeasible
[xstar,fval,exitflag,output,lambda] = linprog(c,[],[],Ain,b,low+epsilon,upp-epsilon,[],options);
%widen the bounds - Lagrange multipliers okay
[xstar,fval,exitflag,output,lambda] = linprog(c,[],[],Ain,b,low-epsilon,upp+epsilon,[],options);
cs=[lambda.upper,(xstar-upp), lambda.lower,(low-xstar)]
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!