Hello Johan,
I have a very basic question about the linearization in yalmip. Now I have a binvar vector x, a sdpvar z1 and sdpvar z2, I want to use the non-linear constraint 2*x(1)*x(2)>=1, 3*x(1)*x(2)+2*x(1)*x(2)>=0.8 to be replaced by the linear constrait:2*z1>1,0<=z1<=1,z1<=x(1),z1<=x(2),z1>=x(1)+x(2)-1, 3*z2+2*z1>1.1,0<=z2<=1,z2<=x(2),z2<=x(3),z2>=x(2)+x(3)-1], so the code is like this:
x=binvar(1,3);%al=sdpvar(1);all=sdpvar(1);
obj=x(1)+x(2)+x(3);z1=sdpvar(1);z2=sdpvar(1);
options=sdpsettings('solver','bnb','verbose',0,'debug',1);
opt=solvesdp([2*z1>1,0<=z1<=1,z1<=x(1),z1<=x(2),z1>=x(1)+x(2)-1,...
3*z2+2*z1>1.1,0<=z2<=1,z2<=x(2),z2<=x(3),z2>=x(2)+x(3)-1],obj,options)
double(x)
But it cannot found the solution and shows infeasible problem.
If I change z1=sdpvar(1);z2=sdpvar(1);to z1=binvar(1);z2=binvar(1); and the result shows errors like:
Error using sprintf
Function is not defined for sparse inputs.
Error in lipsol (line 448)
theMessage = sprintf(['Exiting due to infeasibility: %i
singleton variables in the equality\n' ...
Error in linprog (line 249)
[x,fval,lambda,exitflag,output] =
lipsol(f,A,B,Aeq,Beq,lb,ub,options,defaultopt,computeLambda);
Error in calllinprog (line 59)
[x,fmin,flag,output,lambda] = linprog(c, A, b, Aeq, beq, lb, ub,
x0,options.linprog);
Error in bnb_solvelower (line 128)
output = feval(lowersolver,p);
Error in bnb_solvelower (line 120)
output = bnb_solvelower(lowersolver,dummy,upper,lower);
Error in bnb>branch_and_bound (line 605)
output =
bnb_solvelower(lowersolver,relaxed_p,upper+abs(upper)*1e-2+1e-4,lower);
Error in bnb (line 279)
[x_min,solved_nodes,lower,upper,profile,diagnostics] =
branch_and_bound(p,pss);
Error in solvesdp (line 337)
eval(['output = ' solver.call '(interfacedata);']);
Error in Noc (line 79)
opt=solvesdp([2*z1>1,z1<=x(1),z1<=x(2),z1>=x(1)+x(2)-1,…
So what is the reason? Because apparently, there is feasible solutions and when I don't use the linearization, I can definitely get the correct solution. But now with the new variable z1 and z2, which is actually constrained to be 0 or 1, the bob doesn't work. Is there anything wrong with my approach?
Many thanks,
Yanyan
sdpvar x12
Model=[2*x12>=1,
3*x12+2*x12>=0.8,
x12<=x(1),x12<=x(2),x12>=x(1)+x(2)-1]
Hi Johan,
It is like this, I want to avoid using the nonlinear part 2*x(1)*x(2)>=1, 3*x(1)*x(2)+2*x(1)*x(2)>=0.8 by introducing another two variables z1 and z2. And z1 has the constraint of 2*z1>1, 0<=z1<=1,z1<=x(1),z1<=x(2),z1>=x(1)+x(2)-1. You can see the strict inequality is necessary to limit z1 to be 0 or 1. That is the basic idea of the non-linearization. Now I don't need the more powerful cplex, because now it is a very basic problem.
Do you get what I mean?
2*x(1)*x(2)>=1, 3*x(1)*x(2)+2*x(1)*x(2)>=0.8
sdpvar z
Model=[2*z>=1,
3*z+2*z>=0.8,
z<=x(1),z<=x(2),z>=x(1)+x(2)-1]
2*x(1)*x(2)>=1, 3*x(1)*x(2)+2*x(2)*x(3)>=0.8
sdpvar z1 z2
Model=[2*z1>=1,,
3*z1+2*z2>=0.8,
z1<=x(1),z1<=x(2),z1>=x(1)+x(2)-1,
z2<=x(2),z2<=x(3),z2>=x(2)+x(3)-1]