Wrong calculation of dual variables

I try to solve the following simple LP Problem.

cvx_begin

    variable L1 nonnegative;

    variable L2 nonnegative;

    variable L3 nonnegative;

    variable L4 nonnegative;

 

   dual variable D{3};

 

    maximize 800*L2+280*L4

subject to     

    D{1}: L1+L2==1 ;

    D{2}: L3+L4==1  ;

    D{3}: 60*L2+28*L4<=80;

       

cvx_end

cvx reports the dual variables are:

[-200]

[ 0]

[ 10]

But is it obviously wrong!. The
correct dual variables are

[ 200]

[ 0]

[ 10]

you can solve it by hand. dual problem has 4 constraints and 3 dual variables.

Min y1+y2+80y3

y1>=0

y1+60y3>=800

y2>=0

y2+28y3>=280

CVX is not wrong. Unlike inequality constraints, the sign of the dual variable of an equality constraint (your first constraint) depends on convention, so either 200 or -200 could be correct. See Unexpected result .

1 Like

It cause a real mess in dantzig-wolfe decomposition. How can i detect the real sign?

Just negate CVX’s output. Mark is correct, the sign of the equality constraints depends on convention. But CVX uses the same convention for equality constraints every time, so just change your code this once and be done.

1 Like

Can you explain this case?

For the following LP

minimize x1+x2

subject to

D1:x1+x2<=5    

D2:-x1+x2<=-2;

Cvx reports D1=0 and D2=1, but D2 must
be negative (-1) . Here is the Dual problem

maximize 5*D1-2*D2

subject to

x1:D1-D2<=1    

x2:D1+D2<=1;

D1<=0;

D2<=0

Is it reports shadow price?

Inequality dual variables are always nonnegative in CVX. They represent the improvement in the objective with a unit relaxation in the inequality.

1 Like