0

i'm currently having a project coding on IBM ILOG Cplex. I've been translating the mathematical model to constraint in CPLEX. here it is, i wonder how we code this constraint on cplex since it has 3 elements. i've try the OR logical but the results seem wrong enter image description here

Wenie
  • 1

1 Answers1

0

Or works fine in OPL but you write that as ||

See example https://github.com/AlexFleischerParis/zooopl/blob/master/zoodisjunction.mod

int nbKids=300;
float costBus40=500;
float costBus30=400;
 
dvar int+ nbBus40;
dvar int+ nbBus30;
 
minimize
 costBus40*nbBus40  +nbBus30*costBus30;
 
subject to
{
 40*nbBus40+nbBus30*30>=nbKids;

//with nb buses 40 less than 3 or more than 7
(nbBus40<=3) || (nbBus40>=7);
}
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
  • can i just wrote forall(...) formula a == formula b == formula c. does the loop terminated if condition formula a == b was met? – Wenie Apr 09 '21 at 12:58
  • No. Be careful x==y==z; is the same as (x==y)==z; which means z is 0 or 1 according to whether x==y – Alex Fleischer Apr 09 '21 at 13:04
  • i've tried the above formula as forall (l in N, k in K, w in W) fc[l][k][w] + sum(i in N:i!=l)y[i][l][k][w] ==x[l][k][w] || lc[l][k][w] + sum(i in N:i!=l)y[l][i][k][w] ==x[l][k][w] ; but it did not seem work. the results gave me fc=1 while the rest are equal 0 – Wenie Apr 09 '21 at 13:40