Skip to content

fix a bug of getLargestTimeWindow() and add a function of failing to take different time windows of different vehicle types into account. #516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ private TimeWindow getLargestTimeWindow(Activity act) {
if (timeWindow == null) timeWindow = tw;
else if (tw.larger(timeWindow)) timeWindow = tw;
}

if(timeWindow!=null){
return TimeWindow.newInstance(timeWindow.getStart(),timeWindow.getEnd());
}

return TimeWindow.newInstance(0, Double.MAX_VALUE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,43 @@ public VehicleDependentTimeWindowConstraints(RouteAndActivityStateGetter states,
@Override
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
double latestVehicleArrival = iFacts.getNewVehicle().getLatestArrival();
double earliestVehicleDeparture = iFacts.getNewVehicle().getEarliestDeparture();
/**
* fail to take different time windows of different vehicle types into account.
* for example, original vehicle's time window is 07:00-12:00
* obviously it cannot delivery the first order with 13:00-21:00 in current route,
* but currently it omits this kind of checking logic and only does for time windows among preAct, newAct, nextAct and newVehicle
*/
Location startPoint;
if(prevAct instanceof Start){
startPoint = prevAct.getLocation();
}
else{
startPoint = iFacts.getRoute().getStart().getLocation();
}
TourActivity tmpFirstAct,tmpEndAct;
if(iFacts.getRoute().getActivities().size() == 0) {
tmpFirstAct = newAct;
tmpEndAct = newAct;
}
else{
tmpFirstAct = iFacts.getRoute().getActivities().get(0);
tmpEndAct = iFacts.getRoute().getActivities().get(iFacts.getRoute().getActivities().size()-1);
}
double eta = earliestVehicleDeparture + routingCosts.getTransportTime(startPoint, tmpFirstAct.getLocation(), prevActDepTime, iFacts.getNewDriver(), iFacts.getNewVehicle());
if (eta > tmpFirstAct.getTheoreticalLatestOperationStartTime()
|| latestVehicleArrival < tmpFirstAct.getArrTime()
|| latestVehicleArrival < tmpEndAct.getArrTime()) {
return ConstraintsStatus.NOT_FULFILLED_BREAK;
}
if(iFacts.getNewVehicle().isReturnToDepot()){
eta = tmpEndAct.getEndTime() + routingCosts.getTransportTime(tmpEndAct.getLocation(), iFacts.getNewVehicle().getEndLocation(), tmpEndAct.getEndTime(), iFacts.getNewDriver(), iFacts.getNewVehicle());
if(latestVehicleArrival < eta){
return ConstraintsStatus.NOT_FULFILLED_BREAK;
}
}


Double latestArrTimeAtNextAct;
Location prevLocation = prevAct.getLocation();
if (prevAct instanceof ActWithoutStaticLocation) ((ActWithoutStaticLocation) prevAct).getPreviousLocation();
Expand Down