@Override
 public void handleEvent(PersonEntersVehicleEvent event) {
   if (event.getVehicleId().toString().equalsIgnoreCase(this.vehId)) {
     if (event.getTime() >= this.startTime && event.getTime() < this.stopTime) {
       AgentCountBox acb = this.departedMap.get(event.getPersonId());
       acb.waitingTime = event.getTime() - acb.waitingTime;
       acb.travelTimeInVehicle = event.getTime();
       this.enteredMap.put(event.getPersonId(), acb);
       this.departedMap.remove(event.getPersonId());
     }
   }
 }
  @Override
  public void handleEvent(final PersonEntersVehicleEvent 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(), stopId = this.vehStops.get(vehId);
    double time = event.getTime();
    Integer nPassengers = this.vehPassengers.get(vehId);
    this.vehPassengers.put(vehId, (nPassengers != null) ? (nPassengers + 1) : 1);
    this.occupancyRecord.append(
        "time :\t"
            + time
            + " veh :\t"
            + vehId
            + " has Passenger\t"
            + this.vehPassengers.get(vehId)
            + " \tat stop :\t"
            + stopId
            + " ENTERING PERSON :\t"
            + event.getPersonId()
            + "\n");
  }
 @Override
 public void handleEvent(PersonEntersVehicleEvent event) {
   Double startWaitingTime = agentsWaitingData.get(event.getPersonId());
   if (startWaitingTime != null) {
     int legs = 0, currentLeg = agentsCurrentLeg.get(event.getPersonId());
     PLAN_ELEMENTS:
     for (PlanElement planElement :
         population.getPersons().get(event.getPersonId()).getSelectedPlan().getPlanElements())
       if (planElement instanceof Leg) {
         if (currentLeg == legs) {
           String[] leg = (((Leg) planElement).getRoute()).getRouteDescription().split(SEPARATOR);
           WaitTimeData data =
               waitTimes
                   .get(
                       new Tuple<Id<TransitLine>, Id<TransitRoute>>(
                           Id.create(leg[2], TransitLine.class),
                           Id.create(leg[3], TransitRoute.class)))
                   .get(Id.create(leg[1], TransitStopFacility.class));
           data.addWaitTime(
               (int) (startWaitingTime / timeSlot), event.getTime() - startWaitingTime);
           agentsWaitingData.remove(event.getPersonId());
           break PLAN_ELEMENTS;
         } else legs++;
       }
   }
 }
 @Override
 public void handleEvent(final PersonEntersVehicleEvent event) {
   try {
     writer.newLine();
     final Id linkId = lastDepartureLinkForAgent.remove(event.getPersonId());
     writer.write(
         event.getPersonId()
             + "\t"
             + linkId
             + "\t"
             + network.getLinks().get(linkId).getFromNode().getCoord().getX()
             + "\t"
             + network.getLinks().get(linkId).getFromNode().getCoord().getY()
             + "\t"
             + lastDepartureModeForAgent.remove(event.getPersonId())
             + "\t"
             + event.getVehicleId()
             + "\t"
             + lastDepartureTimeForAgent.remove(event.getPersonId())
             + "\t"
             + event.getTime());
   } catch (IOException e) {
     throw new UncheckedIOException(e);
   }
 }
 // Methods
 @Override
 public void handleEvent(PersonEntersVehicleEvent event) {
   List<PTStage> stages = publicTransportStages.get(event.getPersonId());
   if (stages != null) {
     PTStage stage = stages.get(publicTransportStages.get(event.getPersonId()).size() - 1);
     stage.teleported = false;
     stage.beginTravelInstant = event.getTime();
   }
 }
Beispiel #6
0
  public void handleEvent(PersonEntersVehicleEvent event) {
    Id perId = event.getPersonId();
    double enterVehTime /* [s] */ = event.getTime();
    Id vehId = event.getVehicleId();

    List<Tuple<Double, Integer>> enterVehTimeList = enterVehTimes.get(vehId);
    if (enterVehTimeList == null) enterVehTimeList = new ArrayList<Tuple<Double, Integer>>();

    try {
      double arrTimeAtStop = departures.remove(perId) /*
															 * departureTime/arrivalTimeAtBusStop
															 */;

      int timeBin = (int) arrTimeAtStop / this.binSize;
      enterVehTimeList.add(new Tuple<Double, Integer>(enterVehTime, timeBin));
      enterVehTimes.put(vehId, enterVehTimeList);

      double waitTimeOutOfBus = enterVehTime - arrTimeAtStop;

      // vehIdTimeBins.put(vehId, timeBin);

      // Double wtobSum = wtobSums.get(timeBin);
      // if (wtobSum == null)
      // wtobSum = 0.0;
      // wtobSums.put(timeBin, waitTimeOutOfBus + wtobSum);

      Map<Integer, Double> tmpWtobSums = WtobSumsOfVeh.get(vehId);
      if (tmpWtobSums == null) tmpWtobSums = new TreeMap<Integer, Double>();
      Double tmpWtobSum = tmpWtobSums.get(timeBin);
      if (tmpWtobSum == null) tmpWtobSum = 0.0;
      tmpWtobSums.put(timeBin, waitTimeOutOfBus + tmpWtobSum);
      WtobSumsOfVeh.put(vehId, tmpWtobSums);

      // Integer wtobCount = wtobCounts.get(timeBin);
      // if (wtobCount == null)
      // wtobCount = 0;
      // wtobCounts.put(timeBin, ++wtobCount);

      Map<Integer, Integer> tmpWtobCounts = WtobCountsOfVeh.get(vehId);
      if (tmpWtobCounts == null) tmpWtobCounts = new TreeMap<Integer, Integer>();
      Integer tmpWtobCount = tmpWtobCounts.get(timeBin);
      if (tmpWtobCount == null) tmpWtobCount = 0;
      tmpWtobCounts.put(timeBin, ++tmpWtobCount);
      WtobCountsOfVeh.put(vehId, tmpWtobCounts);

      // System.out.println(">>>>>wtobCounts put\ttimeBin\t" + timeBin
      // + "\twtobCount\t" + wtobCount);

    } catch (NullPointerException npe) {
      System.err.println(
          "WARN:\tthere is not the departure time record of agent:\t"
              + perId
              + "\twith event\t"
              + event.toString());
    }
  }
 @Override
 public void handleEvent(PersonEntersVehicleEvent event) {
   try {
     if (transitDriverIds.contains(event.getPersonId())) return;
     if (ptVehicles.keySet().contains(event.getVehicleId())) {
       TravellerChain chain = chains.get(event.getPersonId());
       Journey journey = chain.getJourneys().getLast();
       // first, handle the end of the wait
       journey.getWaits().getLast().setEndTime(event.getTime());
       // now, create a new trip
       ptVehicles.get(event.getVehicleId()).addPassenger(event.getPersonId());
       Trip trip = journey.addTrip();
       PTVehicle vehicle = ptVehicles.get(event.getVehicleId());
       trip.setLine(vehicle.transitLineId);
       trip.setMode(
           transitSchedule
               .getTransitLines()
               .get(vehicle.transitLineId)
               .getRoutes()
               .get(vehicle.transitRouteId)
               .getTransportMode());
       trip.setBoardingStop(vehicle.lastStop);
       trip.setOrig(journey.getWaits().getLast().getCoord());
       trip.setRoute(ptVehicles.get(event.getVehicleId()).transitRouteId);
       trip.setStartTime(event.getTime());
       // check for the end of a transfer
       if (journey.getPossibleTransfer() != null) {
         journey.getPossibleTransfer().setToTrip(trip);
         journey.getPossibleTransfer().setEndTime(event.getTime());
         journey.addTransfer(journey.getPossibleTransfer());
         journey.setPossibleTransfer(null);
       }
     } else {
       // add the person to the map that keeps track of who drives what
       // vehicle
       driverIdFromVehicleId.put(event.getVehicleId(), event.getPersonId());
     }
   } catch (Exception e) {
     System.err.println(e.getStackTrace());
     System.err.println(event.toString());
   }
 }
 @Override
 public void handleEvent(PersonEntersVehicleEvent event) {
   Double startWaitingTime = agentsWaitingData.get(event.getPersonId().toString());
   if (startWaitingTime != null) {
     Tuple<String, String> lineRoute = linesRoutesOfVehicle.get(event.getVehicleId().toString());
     WaitTimeData data =
         waitTimes.get(lineRoute).get(stopOfVehicle.get(event.getVehicleId().toString()));
     data.addWaitTime((int) (startWaitingTime / timeSlot), event.getTime() - startWaitingTime);
     agentsWaitingData.remove(event.getPersonId().toString());
   }
 }