예제 #1
0
 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);
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 private CarrierAgent findCarrierAgent(Id id) {
   for (CarrierAgent agent : carrierAgents) {
     if (agent.getId().equals(id)) {
       return agent;
     }
   }
   return null;
 }
예제 #4
0
 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;
 }
예제 #5
0
 /** Request all carrier agents to score their plans. */
 public void scoreSelectedPlans() {
   for (Carrier carrier : carriers.getCarriers().values()) {
     CarrierAgent agent = findCarrierAgent(carrier.getId());
     agent.scoreSelectedPlan();
   }
 }
예제 #6
0
 @Override
 public void handleEvent(PersonDepartureEvent event) {
   CarrierAgent carrierAgent = getCarrierAgent(event.getPersonId());
   if (carrierAgent == null) return;
   carrierAgent.handleEvent(event);
 }
예제 #7
0
 @Override
 public void handleEvent(ActivityStartEvent event) {
   CarrierAgent carrierAgent = getCarrierAgent(event.getPersonId());
   if (carrierAgent == null) return;
   carrierAgent.handleEvent(event);
 }
예제 #8
0
 @Override
 public void handleEvent(LinkEnterEvent event) {
   CarrierAgent carrierAgent = getCarrierAgent(event.getDriverId());
   if (carrierAgent == null) return;
   carrierAgent.handleEvent(event);
 }