issue with "max" operator in constraint

64 views
Skip to first unread message

Olivier Mégel

unread,
Jan 13, 2016, 12:58:54 PM1/13/16
to YALMIP
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


Johan Löfberg

unread,
Jan 14, 2016, 2:42:55 AM1/14/16
to YALMIP
That's a bug in the non-convex case of the max operator, will fix.

For now, just comment out line 44 in max_internal

Johan Löfberg

unread,
Jan 14, 2016, 2:44:16 AM1/14/16
to YALMIP
meant line 44-53
Reply all
Reply to author
Forward
0 new messages