@Override
  public void handleEvent(final PersonLeavesVehicleEvent event) {
    if (this.analyzedTransitDrivers.contains(event.getPersonId())
        || !this.analyzedTransitVehicles.contains(event.getVehicleId())) {
      return; // ignore transit drivers or persons entering non-(analyzed-)transit vehicles
    }

    // ----------------veh_passenger-(for occupancy)--------------------------
    Id vehId = event.getVehicleId();
    double time = event.getTime();
    Integer nPassengers = this.vehPassengers.get(vehId);
    if (nPassengers == null) {
      throw new RuntimeException("null passenger-No. in vehicle ?");
    }
    this.vehPassengers.put(vehId, nPassengers - 1);
    if (this.vehPassengers.get(vehId).intValue() == 0) {
      this.vehPassengers.remove(vehId);
    }
    Integer passengers = this.vehPassengers.get(vehId);
    this.occupancyRecord.append(
        "time :\t"
            + time
            + " veh :\t"
            + vehId
            + " has Passenger\t"
            + ((passengers != null) ? passengers : 0)
            + "\n");
  }
 @Override
 public void handleEvent(PersonLeavesVehicleEvent event) {
   if (this.transitDrivers.contains(event.getPersonId())
       || !this.transitVehicles.contains(event.getVehicleId())) {
     return; // ignore transit drivers or persons entering non-transit vehicles
   }
   Id<Vehicle> vehId = event.getVehicleId();
   Integer nPassengers = this.vehPassengers.get(vehId);
   if (nPassengers != null) {
     this.vehPassengers.put(vehId, nPassengers - 1);
     if (this.vehPassengers.get(vehId) == 0) {
       this.vehPassengers.remove(vehId);
     }
   } else {
     log.fatal("negative passenger-No. in vehicle?");
   }
 }
  @Override
  public void handleEvent(PersonLeavesVehicleEvent event) {
    if (ptDrivers.contains(event.getPersonId())) {
      // ptDrivers are not considered

    } else {

      int tripNumber = personId2currentTripNumber.get(event.getPersonId());
      Map<Integer, String> tripNumber2legMode =
          personId2tripNumber2legMode.get(event.getPersonId());

      if ((tripNumber2legMode.get(tripNumber)).equals(TransportMode.car)) {
        // car drivers not considered here

      } else {
        double distanceTravelled =
            (driverId2totalDistance.get(event.getVehicleId())
                - personId2distanceEnterValue.get(event.getPersonId()));

        Map<Integer, Double> tripNumber2distance =
            personId2tripNumber2tripDistance.get(event.getPersonId());
        tripNumber2distance.put(
            tripNumber, tripNumber2distance.get(tripNumber) + distanceTravelled);

        personId2distanceEnterValue.remove(event.getPersonId());
      }
    }
  }
 @Override
 public void handleEvent(PersonLeavesVehicleEvent event) {
   if (!event.getPersonId().toString().startsWith("pt_tr")) {
     TravellerChain chain = chains.get(event.getPersonId());
     if (event.getVehicleId().toString().startsWith("tr")) {
       if (chain.modes.size() == chain.distances.size()
           && chain.modes.get(chain.modes.size() - 1).equals("pt")) {
         double stageDistance =
             ptVehicles.get(event.getVehicleId()).removePassenger(event.getPersonId());
         chain.distances.set(
             chain.distances.size() - 1,
             chain.distances.get(chain.distances.size() - 1) + stageDistance);
         chain.in = true;
       } else if (chain.modes.size() == chain.distances.size())
         throw new RuntimeException("Person is leaving a pt vehicle, but is not in a pt mode");
       else throw new RuntimeException("Modes list has not the same size of distances list (pt)");
     }
   }
 }
Example #5
0
 @Override
 public void handleEvent(PersonLeavesVehicleEvent event) {
   List<String> activityChain = activityChains.get(event.getPersonId());
   if (activityChain != null) {
     String lastLeg = activityChain.get(activityChain.size() - 1);
     if (lastLeg.startsWith("*"))
       if (lastLeg.endsWith("+") || lastLeg.endsWith("+t"))
         activityChain.set(activityChain.size() - 1, lastLeg + "-");
       else throw new RuntimeException("Leave vehicle without enter");
     else throw new RuntimeException("Leave vehicle without departure");
   } else throw new RuntimeException("Leave vehicle without person");
 }
  @Override
  public boolean doProcessEvent(Event event) {
    Id linkId = null;
    Id vehId = null;
    if (event instanceof VehicleEntersTrafficEvent) {
      VehicleEntersTrafficEvent e = (VehicleEntersTrafficEvent) event;
      linkId = e.getLinkId();
      vehId = e.getVehicleId();
    } else if (event instanceof LinkEnterEvent) {
      LinkEnterEvent e = (LinkEnterEvent) event;
      linkId = e.getLinkId();
      vehId = e.getVehicleId();
    } else if (event instanceof PersonEntersVehicleEvent) {
      PersonEntersVehicleEvent e = (PersonEntersVehicleEvent) event;
      if (e.getPersonId().toString().startsWith("pt_")) {
        return false;
      }
      if (this.networkContainedLastLinkEnterByVehicleId.containsKey(e.getVehicleId())
          && this.networkContainedLastLinkEnterByVehicleId.get(e.getVehicleId())) {
        this.countedPersonIds.add(e.getPersonId());
        return true;
      }
    } else if (event instanceof PersonLeavesVehicleEvent) {
      PersonLeavesVehicleEvent e = (PersonLeavesVehicleEvent) event;
      if (e.getPersonId().toString().startsWith("pt_")) {
        return false;
      }
      if (this.networkContainedLastLinkEnterByVehicleId.containsKey(e.getVehicleId())
          && this.networkContainedLastLinkEnterByVehicleId.get(e.getVehicleId())
          && countedPersonIds.contains(e.getPersonId())) {
        countedPersonIds.remove(e.getPersonId());
        return true;
      } else if (this.countedPersonIds.contains(e.getPersonId())) {
        countedPersonIds.remove(e.getPersonId());
        return true;
      }
    }

    if (linkId != null) {
      if (this.network.getLinks().containsKey(linkId)) {
        this.networkContainedLastLinkEnterByVehicleId.put(vehId, true);
        return true;
      } else {
        this.networkContainedLastLinkEnterByVehicleId.put(vehId, false);
        return true;
      }
    }

    return false;
  }
  @Override
  public void handleEvent(PersonLeavesVehicleEvent event) {
    if (event.getVehicleId().toString().equalsIgnoreCase(this.vehId)) {
      if (event.getTime() >= this.startTime && event.getTime() < this.stopTime) {
        AgentCountBox acb = this.enteredMap.get(event.getPersonId());
        acb.travelTimeInVehicle = event.getTime() - acb.travelTimeInVehicle;
        this.completeAgents.add(acb);
        this.enteredMap.remove(event.getPersonId());

        if (this.debug.containsKey(event.getPersonId())) {
          //					log.warn("Agent " + event.getPersonId() + " counted twice");
          this.numberOfAdditionalTripsPerformed++;
        } else {
          this.debug.put(event.getPersonId(), "");
        }
      }
    }
  }
  @Override
  public void handleEvent(PersonLeavesVehicleEvent event) {
    if (transitDriverIds.contains(event.getPersonId())) return;
    try {
      if (ptVehicles.keySet().contains(event.getVehicleId())) {
        TravellerChain chain = chains.get(event.getPersonId());
        chain.traveledVehicle = true;
        PTVehicle vehicle = ptVehicles.get(event.getVehicleId());
        double stageDistance = vehicle.removePassenger(event.getPersonId());
        Trip trip = chain.getJourneys().getLast().getTrips().getLast();
        trip.setDistance(stageDistance);
        trip.setAlightingStop(vehicle.lastStop);
      } else {
        driverIdFromVehicleId.remove(event.getVehicleId());
      }

    } catch (Exception e) {
      System.err.println(e.getStackTrace());
      System.err.println(event.toString());
    }
  }
Example #9
0
 @Override
 public void handleEvent(final PersonLeavesVehicleEvent event) {
   handleEvent(eventsPerPerson, event.getPersonId(), event);
 }