Reputation: 49
I want to bring min value that >0 of these dvar int values (contain with -,0,+ value) (in constraints section)
forall(r in request)
first_delivery[r] == minl(delivery_time[r][k][j]); that >0
How can I do this ?
Thank you very much.
Upvotes: 0
Views: 152
Reputation: 10037
You can compute new decision variables to keep only the values that are more than 1 and then use min:
dvar int x[1..4];
dvar int x2[1..4]; // derive from x, if x positive then x else max of x+1
dvar int y;
dvar int M;
subject to
{
x[1]==0;
x[2]==-6;
x[3]==4;
x[4]==5;
M==max(i in 1..4) x[i];
forall(i in 1..4)
{
x[i]<=0 => x2[i]==M+1;
x[i]>=1 => x2[i]==x[i];
}
y==min(i in 1..4) x2[i];
}
execute
{
writeln("y=",y);
}
which gives
y=4
Upvotes: 1