Hello,
I am doing an Vehicle Routing Problem with Time Windows and I have a question about this.
I formulated two decision variables:
}
Variable X {
IndexDomain: (iLocations,jLocations,k) | iLocations<>jLocations | iLocations<>Numberoflocations+1 | jLocations<>0;
Range: binary;
}
Variable S {
IndexDomain: (iLocations,k);
Range: nonnegative;
X(iLocations,jLocations,k) represents whether vehicle k goes from location i to location j, where i cannot be equal to the returning depot and j cannot be equal to the home depot.
S(iLocations,k) represents the time vehicle k starts to serve location i.
I also have the following parameters and constraints:
}
Parameter A {
IndexDomain: iCustomerlocations;
Range: nonnegative;
}
Parameter B {
IndexDomain: iCustomerlocations;
Range: nonnegative;
}
Parameter t {
IndexDomain: (iLocations,jLocations)| iLocations<>jLocations | iLocations<>Numberoflocations+1 | jLocations<>0;
Range: nonnegative;
}
Constraint Arrivaltime {
IndexDomain: (iLocations,jLocations,k);
Definition: (S(iLocations,k) + t(iLocations,jLocations) - Largenumber * (1-X(iLocations,jLocations,k))) <= S(jLocations,k);
}
Constraint Timewindow {
IndexDomain: (iCustomerlocations, k);
Definition: A(iCustomerlocations) <= S(iCustomerlocations,k) <= B(iCustomerlocations);
}
Constraint Workinghours {
IndexDomain: (iLocations,k)| iLocations=Numberoflocations+1;
Definition: S(iLocations,k)<=10;
A and B are the lower bound and upper bound of the time window in which customer i has to be served.
T(iLocations,jLocations) represents the time it takes to go from location i to location j.
Constraint Arrivaltime means that the time vehicle k arrives at location j is greater or equal to S(iLocations,k)+t(iLocations,jLocations), when the vehicle goes from i to j.
Constraint Timewindow means that the time vehicle k starts with the service at customer i is between the time window of that specific customer.
Constraint Workinghours means that vehicle k has to be back at the returning at the latest at 10 hours, because this is the maximum number of working hours.
The model is working, but the results for variable S are not how I want them to be.
My question: which formula do I have to add or which adjustments to the formulas do I have to make such that the vehicles leave the customer locations immediately after they have visited them.
For example, one route is as follows: home depot -> location 2 -> location 3 -> returning depot
The time
window of customer2 is [0,3] and the time window of customer 3 is [0,6].
T(0,2)=2, T(2,3)=2, T(3,4)=3.
The results for variable S are: S(2,k)=2, S(3,k)=6 and S(4,k)=9. However, this should be S(2,k)=2,
S(3,k)=4, S(4,k)=7.
Thank you in advance!
Kind regards,
Claire
S(i, k) + t(i, j) = S(j, k) if X(i, j, k) = 1
Constraint Arrivaltime {
IndexDomain: (iLocations,jLocations,k);
Definition: (S(iLocations,k) + t(iLocations,jLocations) - Largenumber * (1-X(iLocations,jLocations,k))) <= S(jLocations,k);
}
Constraint Arrivaltime_2 {
IndexDomain: (iLocations,jLocations,k);
Definition: (S(iLocations,k) + t(iLocations,jLocations) + Largenumber * (1-X(iLocations,jLocations,k))) >= S(jLocations,k);
}
S(iLocations,k) + t(iLocations,jLocations) - Largenumber * (0) <= S(jLocations,k)
S(iLocations,k) + t(iLocations,jLocations) + Largenumber * (0) >= S(jLocations,k)
S(iLocations,k) + t(iLocations,jLocations) = S(jLocations,k)
S(iLocations,k) + t(iLocations,jLocations) - Largenumber * (1) <= S(jLocations,k)
S(iLocations,k) + t(iLocations,jLocations) + Largenumber * (1) >= S(jLocations,k)
- Largenumber * (1) <= S(jLocations,k)- S(iLocations, k) - t(iLocations, jLocations)
Largenumber * (1) >= S(jLocations,k) + S(iLocations,k) + t(iLocations,jLocations)
This should solve your problem. Constraint OneDestination {
IndexDomain: (iLocations,k);
Definition: sum[jLocations, X(iLocations, jLocations, k)] <= 1;
}