0

I would like to create non-linear violation costs in my VRP. I already created my whole VRP with time windows in which I have these decision variable:

dvar float+ w[N][D]; // violation time for late arrivals for every node and every day

These dvars are working, but now I want to make a link with the violation costs decision variables, which are:

dvar boolean a1[N][D];// no violation 
dvar boolean a2[N][D];// soft violation of 0-5 minutes
dvar boolean a3[N][D];// soft violation of 6-10 minutes
dvar boolean a4[N][D];// soft violation of 11 -15 minutes 
dvar boolean a5[N][D];// soft violation of 15+ minutes

I want to force:

a1[N][D] to be 1, when w[N][D] <=0, 0 otherwise
a2[N][D] to be 1, when w[N][D] >0 & <=5, 0 otherwise
a3[N][D] to be 1, when w[N][D] >5 & <=10, 0 otherwise
a4[N][D] to be 1, when w[N][D] >10 & <=15, 0 otherwise
a5[N][D] to be 1, when w[N][D] >=16, 0 otherwise

Then I have:

  forall(i in N, d in D)
  (a1[i][d] + a2[i][d] + a3[i][d] + a4[i][d] + a5[i][d]) == 1;

There is still something wrong with these constraints though.

forall(i in N, d in D)
  (a1[i][d] + a2[i][d] + a3[i][d] + a4[i][d] + a5[i][d]) == 1; //sum of all a's = 1

forall(i in N, d in D)
  w[n][d]<= (5*a2[i][d]) + 1000*(1-a2[i][d]); // a2 == 1 when w[n][d]>0 & <=5

forall(i in N, d in D)
  (6*a3[i][d] - 1000*(a3[i][d]-1))<= w[i][d]; // a3

forall(i in N, d in D)
   w[i][d] <= (10*a3[i][d]) + 1000*(1-a3[i][d]); // a3

forall(i in N, d in D)
  (11*a4[i][d] - 1000*(a4[i][d]-1))<= w[i][d]; //a4

forall(i in N, d in D)
   w[i][d] <= (15*a4[i][d]) + 1000*(1-a4[i][d]); // a4

forall(i in N, d in D)
  (16*a5[i][d] - 1000*(a5[i][d]-1))<= w[i][d]; //a5

it sets a5==1 for all constraints.

Furthermore, w is used in the model as:

forall (i in N, d in D:q[i][d]>=1)
y[i][d] - w[i][d] <= sl[i][d]; // late arrival time soft

where y[i][d] is the arrival time variable

1 Answer 1

1

if you want w to be negative sometimes you should have

dvar int w[N][D]; 

instead of

dvar int+ w[N][D];

Plus you could use logical constraints instead of big M with hard coded 1000

range N=1..2;
range D=1..3;

dvar boolean a1[N][D];
dvar int w[N][D] in -10..10;

subject to
{
// a1[N][D] to be 1, when w[N][D] <=0, 0 otherwise
forall(n in N,d in D) a1[n][d]==(w[n][n] <=0);
}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.