private double savings( VehicleRoute route, TourActivity actBefore, TourActivity actToEval, TourActivity act) { double savings = c(actBefore, actToEval, route.getVehicle()) + c(actToEval, act, route.getVehicle()) - c(actBefore, act, route.getVehicle()); return Math.max(0, savings + noiseMaker.makeNoise()); }
/** * @param route to get the capacity violation from (at end of the route) * @return violation, i.e. all dimensions and their corresponding violation. For example, if * vehicle has two capacity dimension with dimIndex=0 and dimIndex=1 and dimIndex=1 is * violated by 4 units then this method returns * [[dimIndex=0][dimValue=0][dimIndex=1][dimValue=4]] */ public Capacity getCapacityViolationAtEnd(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); Capacity atEnd = getLoadAtEnd(route); return Capacity.max( Capacity.Builder.newInstance().build(), Capacity.subtract(atEnd, route.getVehicle().getType().getCapacityDimensions())); }
private Set<String> getInitialVehicleIds(VehicleRoutingProblem vehicleRoutingProblem) { Set<String> ids = new HashSet<String>(); for (VehicleRoute r : vehicleRoutingProblem.getInitialVehicleRoutes()) { ids.add(r.getVehicle().getId()); } return ids; }
@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); }
/** * @param route to get the capacity violation from (at activity of the route) * @return violation, i.e. all dimensions and their corresponding violation. For example, if * vehicle has two capacity dimension with dimIndex=0 and dimIndex=1 and dimIndex=1 is * violated by 4 units then this method returns * [[dimIndex=0][dimValue=0][dimIndex=1][dimValue=4]] */ public Capacity getCapacityViolationAfterActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); Capacity afterAct = getLoadRightAfterActivity(activity, route); return Capacity.max( Capacity.Builder.newInstance().build(), Capacity.subtract(afterAct, route.getVehicle().getType().getCapacityDimensions())); }
private double transportCost(TourActivity activity) { return transportCost.getTransportCost( prevAct.getLocation(), activity.getLocation(), prevActDeparture, route.getDriver(), route.getVehicle()); }
@Override public void visit(TourActivity activity) { boolean violatedAtActivity = false; if (activity instanceof TourActivity.JobActivity) { Set<String> requiredForActivity = ((TourActivity.JobActivity) activity).getJob().getRequiredSkills().values(); for (String skill : requiredForActivity) { if (!route.getVehicle().getSkills().containsSkill(skill)) { violatedAtActivity = true; skillConstraintViolatedOnRoute = true; } } } stateManager.putActivityState(activity, skill_id, violatedAtActivity); }
/** * @param route to get the fixed costs from * @return fixed costs of route, i.e. fixed costs of employed vehicle on this route. */ public Double getFixedCosts(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return route.getVehicle().getType().getVehicleCostParams().fix; }