Hi,
I came across a strange behavior when using the "max" operator in a constraint. It looks like the operator is confused when one term is an sdpvar, and the other one a double:
options=sdpsettings('verbose',0);
a=sdpvar(1,1);
b=sdpvar(1,1);
C=[];
C=[C,a==1];
C=[C,b==max(-1*a,0)];
sol = optimize(C,[],options)
double(a)
double(b)
sol =
yalmiptime: 0.3557
solvertime: 0.0013
info: 'Successfully solved (GUROBI-GUROBI)'
problem: 0
time: 0.0013
ans =
1
ans =
-1.0000
(the value of b is -1, but it should be max(-1*1,0) , i.e 0). However, if I do the following modification, it works (down to the solver numerical precision):
options=sdpsettings('verbose',0);
a=sdpvar(1,1);
b=sdpvar(1,1);
DummyZero=sdpvar(1,1);
C=[];
C=[C,a==1];
C=[C,b==max(-1*a,DummyZero)];
C=[C,DummyZero==0];
sol = optimize(C,[],options)
double(a)
double(b)
sol =
yalmiptime: 0.3967
solvertime: 0.0013
info: 'Successfully solved (GUROBI-GUROBI)'
problem: 0
time: 0.0013
ans =
1
ans =
-2.5466e-11
Am I doing something wrong, or is this a bug ? (note that I can live with the DummyZero sdpvar if I have to).
Best,
Olivier