Hi, Johan. I meet a problem when I did a dual transformation.
I have a linear programming with a equality constraints in it, and I need dualize it for some reason.
but I found my dual problem was not equal to the primal, and I can't find the problem.
So could you please help me check the key code as following:
A is a constant N*M matrix
Y is a M*1 vector
lambda1 is N*N sdpvar
x is M*N sdpvar
%primal problem
constr_sc_fsb=[...
A'*diag(Y)*x == diag(ones(1,N)),...%lambda1
];
obj = 0;
Result=optimize( constr_sc_fsb, obj, sdpsettings('solver', 'cplex', 'cplex.lpmethod', 4) );
Lambda1 = dual(constr_sc_fsb(1));
%dual problem
constr_sc_dual=[...
(A'*diag(Y]))'*lambda1 == 0,...%h
];
obj_dual = sum(sum(diag(ones(1,N)).*lambda1));
Result=optimize( constr_sc_dual, -obj_dual, sdpsettings('solver', 'cplex', 'cplex.lpmethod', 4) ); %, 'cplex.timelimit', 3000
%check if the dual transformation is correct
disp(sum(sum(abs(Lambda1-value(lambda1)))));%here Lambda1 and lambda1 are all zero matrixes
disp(sum(sum(abs(value(x)-dual(constr_sc_dual(1))))));%x is different from the dual value of the dual problem
the solution shows that the value(x) is not equal to the dual value of the dual problem