Пример #1
0
 @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) {
    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");
  }
 // 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();
   }
 }
Пример #4
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());
    }
  }
Пример #5
0
 @Override
 public void handleEvent(PersonEntersVehicleEvent 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);
   this.vehPassengers.put(vehId, (nPassengers != null) ? (nPassengers + 1) : 1);
 }
 @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());
   }
 }
  @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;
  }
Пример #8
0
 @Override
 public void handleEvent(PersonEntersVehicleEvent event) {
   List<String> activityChain = activityChains.get(event.getPersonId());
   if (activityChain != null) {
     String lastLeg = activityChain.get(activityChain.size() - 1);
     if (lastLeg.startsWith("*")) activityChain.set(activityChain.size() - 1, lastLeg + "+");
     else throw new RuntimeException("Enter vehicle without departure");
   } else throw new RuntimeException("Enter vehicle without person");
 }
 @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(PersonEntersVehicleEvent 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 {
        personId2distanceEnterValue.put(
            event.getPersonId(), driverId2totalDistance.get(event.getVehicleId()));
      }
    }
  }
 @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);
   }
 }
Пример #12
0
 @Override
 public void handleEvent(PersonEntersVehicleEvent event) {
   if (pIdsToExclude.contains(event.getPersonId())) {
     return;
   }
   if (!event.getPersonId().toString().startsWith("pt_tr"))
     if (event.getVehicleId().toString().startsWith("tr")) {
       TravellerChain chain = chains.get(event.getPersonId());
       chain.lineId = ptVehicles.get(event.getVehicleId()).lineId;
       chain.routeId = ptVehicles.get(event.getVehicleId()).routeId;
     }
 }
 @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());
   }
 }
Пример #14
0
 @Override
 public void handleEvent(final PersonEntersVehicleEvent event) {
   handleEvent(eventsPerPerson, event.getPersonId(), event);
 }
 @Override
 public void handleEvent(PersonEntersVehicleEvent event) {
   if (!event.getPersonId().toString().startsWith("pt_tr"))
     if (event.getVehicleId().toString().startsWith("tr"))
       ptVehicles.get(event.getVehicleId()).addPassenger(event.getPersonId());
 }