private double transportTime(TourActivity activity) { return activity.getArrTime() - prevActDeparture; }
/** * @param activity to get the time window violation from * @param route where activity needs to be part of * @return time violation of activity */ public Double getTimeWindowViolationAtActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); return Math.max(0, activity.getArrTime() - activity.getTheoreticalLatestOperationStartTime()); }
/** * @param activity to get the waiting from * @param route where activity should be part of * @return waiting time at activity */ public Double getWaitingTimeAtActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); double waitingTime = 0.; if (activityPolicy.equals(ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_TIME_WINDOW_OPENS)) { waitingTime = Math.max(0, activity.getTheoreticalEarliestOperationStartTime() - activity.getArrTime()); } return waitingTime; }
@Override public void visit(TourActivity activity) { states.putInternalTypedActivityState(activity, route.getVehicle(), InternalStates.FUTURE_WAITING, futureWaiting); if(!(activity instanceof BreakActivity)) { futureWaiting += Math.max(activity.getTheoreticalEarliestOperationStartTime() - activity.getArrTime(), 0); } }
@Override public void visit(TourActivity activity) { //waiting time & toolate double waitAtAct = 0.; double tooLate = 0.; if (activityPolicy.equals(ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_TIME_WINDOW_OPENS)) { waitAtAct = Math.max(0, activity.getTheoreticalEarliestOperationStartTime() - activity.getArrTime()); tooLate = Math.max(0, activity.getArrTime() - activity.getTheoreticalLatestOperationStartTime()); } sum_waiting_time += waitAtAct; sum_too_late += tooLate; //transport time double transportTime = activity.getArrTime() - prevActDeparture; sum_transport_time += transportTime; prevActDeparture = activity.getEndTime(); //service time sum_service_time += activityCosts.getActivityDuration(activity, activity.getArrTime(), route.getDriver(), route.getVehicle()); stateManager.putActivityState(activity, transport_time_id, sum_transport_time); }
private static void validateSolution(VehicleRoutingProblemSolution bestOf, VehicleRoutingProblem bicycleMessengerProblem, Map<String, Double> nearestMessengers) { for (VehicleRoute route : bestOf.getRoutes()) { for (TourActivity act : route.getActivities()) { if (act.getArrTime() > 3 * nearestMessengers.get(((JobActivity) act).getJob().getId())) { SolutionPrinter.print(bicycleMessengerProblem, bestOf, SolutionPrinter.Print.VERBOSE); throw new IllegalStateException("three times less than ... constraint broken. this must not be. act.getArrTime(): " + act.getArrTime() + " allowed: " + 3 * nearestMessengers.get(((JobActivity) act).getJob().getId())); } } } }
@Override public void visit(TourActivity currAct) { double timeOfNearestMessenger = bestMessengers.get(((JobActivity) currAct).getJob().getId()); double potential_latest_arrTime_at_currAct = latest_arrTime_at_prevAct - routingCosts.getBackwardTransportTime(currAct.getLocation(), prevAct.getLocation(), latest_arrTime_at_prevAct, route.getDriver(), route.getVehicle()) - currAct.getOperationTime(); double latest_arrTime_at_currAct = Math.min(3 * timeOfNearestMessenger, potential_latest_arrTime_at_currAct); stateManager.putActivityState(currAct, latest_act_arrival_time_stateId, latest_arrTime_at_currAct); assert currAct.getArrTime() <= latest_arrTime_at_currAct : "this must not be since it breaks condition; actArrTime: " + currAct.getArrTime() + " latestArrTime: " + latest_arrTime_at_currAct + " vehicle: " + route.getVehicle().getId(); latest_arrTime_at_prevAct = latest_arrTime_at_currAct; prevAct = currAct; }
c += problem.getActivityCosts().getActivityCost(act, act.getArrTime(), route.getDriver(), route.getVehicle()); costs += c; out.format(leftAlgin, routeNu, getVehicleString(route), act.getName(), jobId, Math.round(act.getArrTime()), Math.round(act.getEndTime()), Math.round(costs)); prevAct = act;
private double transportTime(TourActivity activity) { return activity.getArrTime() - prevActDeparture; }
double pickupActEndTime = startOf(pickupAct, pickupActArrTime) + activityCosts.getActivityDuration(pickupAct, pickupActArrTime, iFacts.getNewDriver(), iFacts.getNewVehicle()); double nextAfterPickupArr = pickupActEndTime + transportTime.getTransportTime(pickupAct.getLocation(), nextAfterPickup.getLocation(), pickupActArrTime, iFacts.getNewDriver(), iFacts.getNewVehicle()); additionalTimeOfNewJob += startOf(nextAfterPickup, nextAfterPickupArr) - startOf(nextAfterPickup, nextAfterPickup.getArrTime());
@Override public double getActivityDuration(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) { double activityDuration = Math.max(0, tourAct.getEndTime() - tourAct.getArrTime()); //including waiting times return activityDuration; }
@Override public double getActivityDuration(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) { double activityDuration = Math.max(0, tourAct.getEndTime() - tourAct.getArrTime()); //including waiting times return activityDuration; } };
/** * @param activity to get the time window violation from * @param route where activity needs to be part of * @return time violation of activity */ public Double getTimeWindowViolationAtActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); return Math.max(0, activity.getArrTime() - activity.getTheoreticalLatestOperationStartTime()); }
xmlConfig.setProperty(path + "(" + routeCounter + ").act(" + actCounter + ").arrTime", act.getArrTime()); xmlConfig.setProperty(path + "(" + routeCounter + ").act(" + actCounter + ").endTime", act.getEndTime()); actCounter++;
xmlConfig.setProperty(solutionPath + "(" + counter + ").routes.route(" + routeCounter + ").act(" + actCounter + ").arrTime", act.getArrTime()); xmlConfig.setProperty(solutionPath + "(" + counter + ").routes.route(" + routeCounter + ").act(" + actCounter + ").endTime", act.getEndTime()); actCounter++;
/** * @param activity to get the waiting from * @param route where activity should be part of * @return waiting time at activity */ public Double getWaitingTimeAtActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); double waitingTime = 0.; if (activityPolicy.equals(ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_TIME_WINDOW_OPENS)) { waitingTime = Math.max(0, activity.getTheoreticalEarliestOperationStartTime() - activity.getArrTime()); } return waitingTime; }
@Override public void visit(TourActivity activity) { states.putInternalTypedActivityState(activity, route.getVehicle(), InternalStates.FUTURE_WAITING, futureWaiting); if(!(activity instanceof BreakActivity)) { futureWaiting += Math.max(activity.getTheoreticalEarliestOperationStartTime() - activity.getArrTime(), 0); } }
@Override public void visit(TourActivity activity) { //waiting time & toolate double waitAtAct = 0.; double tooLate = 0.; if (activityPolicy.equals(ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_TIME_WINDOW_OPENS)) { waitAtAct = Math.max(0, activity.getTheoreticalEarliestOperationStartTime() - activity.getArrTime()); tooLate = Math.max(0, activity.getArrTime() - activity.getTheoreticalLatestOperationStartTime()); } sum_waiting_time += waitAtAct; sum_too_late += tooLate; //transport time double transportTime = activity.getArrTime() - prevActDeparture; sum_transport_time += transportTime; prevActDeparture = activity.getEndTime(); //service time sum_service_time += activityCosts.getActivityDuration(activity, activity.getArrTime(), route.getDriver(), route.getVehicle()); stateManager.putActivityState(activity, transport_time_id, sum_transport_time); }
@Override public double getCosts(VehicleRoutingProblemSolution solution) { double costs = 0.; for (VehicleRoute route : solution.getRoutes()) { costs += route.getVehicle().getType().getVehicleCostParams().fix; boolean hasBreak = false; TourActivity prevAct = route.getStart(); for (TourActivity act : route.getActivities()) { if (act instanceof BreakActivity) hasBreak = true; costs += vrp.getTransportCosts().getTransportCost(prevAct.getLocation(), act.getLocation(), prevAct.getEndTime(), route.getDriver(), route.getVehicle()); costs += vrp.getActivityCosts().getActivityCost(act, act.getArrTime(), route.getDriver(), route.getVehicle()); prevAct = act; } costs += vrp.getTransportCosts().getTransportCost(prevAct.getLocation(), route.getEnd().getLocation(), prevAct.getEndTime(), route.getDriver(), route.getVehicle()); if (route.getVehicle().getBreak() != null) { if (!hasBreak) { //break defined and required but not assigned penalty if (route.getEnd().getArrTime() > route.getVehicle().getBreak().getTimeWindow().getEnd()) { costs += 4 * (maxCosts * 2 + route.getVehicle().getBreak().getServiceDuration() * route.getVehicle().getType().getVehicleCostParams().perServiceTimeUnit); } } } } for(Job j : solution.getUnassignedJobs()){ costs += maxCosts * 2 * (11 - j.getPriority()); } return costs; } };
} else if (label.equals(Label.ARRIVAL_TIME)) { Node actNode = g.getNode(currIdentifier); actNode.addAttribute("ui.label", Time.parseSecondsToTime(act.getArrTime())); } else if (label.equals(Label.DEPARTURE_TIME)) { Node actNode = g.getNode(currIdentifier);