CarrierDriverAgent getDriver(Id driverId) { CarrierAgent carrierAgent = getCarrierAgent(driverId); if (carrierAgent == null) throw new IllegalStateException( "missing carrier agent. cannot find carrierAgent to driver " + driverId); return carrierAgent.getDriver(driverId); }
/** * Returns the entire set of selected carrier plans. * * @return collection of plans * @see Plan, CarrierPlan */ Collection<MobSimVehicleRoute> createPlans() { List<MobSimVehicleRoute> vehicleRoutes = new ArrayList<MobSimVehicleRoute>(); for (CarrierAgent carrierAgent : carrierAgents) { List<MobSimVehicleRoute> plansForCarrier = carrierAgent.createFreightDriverPlans(); vehicleRoutes.addAll(plansForCarrier); } return vehicleRoutes; }
private CarrierAgent findCarrierAgent(Id id) { for (CarrierAgent agent : carrierAgents) { if (agent.getId().equals(id)) { return agent; } } return null; }
private CarrierAgent getCarrierAgent(Id driverId) { if (driverAgentMap.containsKey(driverId)) { return driverAgentMap.get(driverId); } for (CarrierAgent ca : carrierAgents) { if (ca.getDriverIds().contains(driverId)) { driverAgentMap.put(driverId, ca); return ca; } } return null; }
/** Request all carrier agents to score their plans. */ public void scoreSelectedPlans() { for (Carrier carrier : carriers.getCarriers().values()) { CarrierAgent agent = findCarrierAgent(carrier.getId()); agent.scoreSelectedPlan(); } }
@Override public void handleEvent(PersonDepartureEvent event) { CarrierAgent carrierAgent = getCarrierAgent(event.getPersonId()); if (carrierAgent == null) return; carrierAgent.handleEvent(event); }
@Override public void handleEvent(ActivityStartEvent event) { CarrierAgent carrierAgent = getCarrierAgent(event.getPersonId()); if (carrierAgent == null) return; carrierAgent.handleEvent(event); }
@Override public void handleEvent(LinkEnterEvent event) { CarrierAgent carrierAgent = getCarrierAgent(event.getDriverId()); if (carrierAgent == null) return; carrierAgent.handleEvent(event); }