@Override public void visit(TourActivity activity) { stateManager.putActivityState(activity, last_transport_distance_id, distance(activity)); stateManager.putActivityState(activity, last_transport_time_id, transportTime(activity)); stateManager.putActivityState(activity, last_transport_cost_id, transportCost(activity)); prevAct = activity; prevActDeparture = activity.getEndTime(); }
@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 void visit(TourActivity activity) { double distance = distanceCalculator.getDistance(prevAct.getLocation(), activity.getLocation()); sum_distance += distance; stateManager.putActivityState(activity, distance_id, sum_distance); prevAct = activity; }
@Override public void visit(TourActivity activity) { // shipment if (activity instanceof PickupShipment) { openShipments.put(((PickupShipment) activity).getJob().getId(), (PickupShipment) activity); } else if (activity instanceof DeliverShipment) { String jobId = ((DeliverShipment) activity).getJob().getId(); if (!openShipments.containsKey(jobId)) { // deliverShipment without pickupShipment stateManager.putActivityState(activity, shipment_id, true); shipmentConstraintOnRouteViolated = true; } else { PickupShipment removed = openShipments.remove(jobId); stateManager.putActivityState(removed, shipment_id, false); stateManager.putActivityState(activity, shipment_id, false); } } else stateManager.putActivityState(activity, shipment_id, false); // backhaul if (activity instanceof DeliverService && pickupOccured) { stateManager.putActivityState(activity, backhaul_id, true); backhaulConstraintOnRouteViolated = true; } else { if (activity instanceof PickupService || activity instanceof ServiceActivity || activity instanceof PickupShipment) { pickupOccured = true; stateManager.putActivityState(activity, backhaul_id, false); } else stateManager.putActivityState(activity, backhaul_id, false); } }
@Override public void finish() { // shipment // pickups without deliveries for (TourActivity act : openShipments.values()) { stateManager.putActivityState(act, shipment_id, true); shipmentConstraintOnRouteViolated = true; } stateManager.putRouteState(route, shipment_id, shipmentConstraintOnRouteViolated); // backhaul stateManager.putRouteState(route, backhaul_id, backhaulConstraintOnRouteViolated); }
@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); }