@Override
  public void handleEvent(ActivityStartEvent event) {
    try {
      if (isTransitScenario) {
        if (transitDriverIds.contains(event.getPersonId())) return;
      }
      TravellerChain chain = chains.get(event.getPersonId());
      boolean beforeInPT = chain.isInPT();
      if (event.getActType().equals(PtConstants.TRANSIT_ACTIVITY_TYPE)) {
        chain.setInPT(true);

      } else {
        chain.setInPT(false);
        chain.traveling = false;
        Activity act = chain.addActivity();
        act.setCoord(network.getLinks().get(event.getLinkId()).getCoord());
        act.setFacility(event.getFacilityId());
        act.setStartTime(event.getTime());
        act.setType(event.getActType());
        // end the preceding journey
        Journey journey = chain.getJourneys().getLast();
        journey.setDest(act.getCoord());
        journey.setEndTime(event.getTime());
        journey.setToAct(act);
        if (beforeInPT) journey.getWalks().getLast().setEgressWalk(true);
      }
    } catch (Exception e) {
      System.err.println(e.getStackTrace());
      System.err.println(event.toString());
      ;
    }
  }
Пример #2
0
  @Override
  public void handleEvent(ActivityStartEvent event) {
    // store information from event to variables and print the information on console
    // String eventType = event.getEventType();
    Id<Link> linkId = event.getLinkId();
    // String linkShortened = linkId.toString().substring(0, 10) + "...";
    Id<Person> personId = event.getPersonId();
    double time = event.getTime();
    String actType = event.getActType();
    // Id facilityId =	event.getFacilityId();
    // System.out.println("Type: " + eventType + " - LinkId: " + linkShortened + " - PersonId: " +
    // personId.toString()
    //		+ " - Time: " + time/60/60 + " - ActType: " + actType + " - FacilityId: " + facilityId);

    // count number of activity starts for every agent and store these numbers in a map
    if (!activityStartCount.containsKey(personId)) {
      activityStartCount.put(personId, 1);
    } else {
      int numberOfCompletedDepartures = activityStartCount.get(personId);
      activityStartCount.put(personId, numberOfCompletedDepartures + 1);
    }
    // System.out.println("Agent " + personId + " has " + activityEndCount.get(personId) + "
    // activity ends and " + activityStartCount.get(personId) + " activity starts.");

    // add information to the object "Trip"
    Id<Trip> tripId = Id.create(personId + "_" + activityStartCount.get(personId), Trip.class);
    if (trips.get(tripId) != null) {
      trips.get(tripId).setArrivalLinkId(linkId);
      trips.get(tripId).setArrivalTime(time);
      // trips.get(tripId).setArrivalLegMode(legMode);
      trips.get(tripId).setActivityStartActType(actType);
      trips.get(tripId).setTripComplete(true);
    } else {
      this.noPreviousEndOfActivityCounter++;
    }

    // check if number of activity ends and number of activity starts are the same
    if (activityStartCount.get(personId) != activityEndCount.get(personId)) {
      // System.err.println("Activity start count differs from activity end count.");
      throw new RuntimeException("Activity start count differs from activity end count.");
    }

    // checking leg modes is not applicable here
  }
Пример #3
0
 @Override
 public void handleEvent(ActivityStartEvent event) {
   if (pIdsToExclude.contains(event.getPersonId())) {
     return;
   }
   TravellerChain chain = chains.get(event.getPersonId());
   boolean beforeInPT = chain.inPT;
   if (event.getActType().equals(PtConstants.TRANSIT_ACTIVITY_TYPE)) chain.inPT = true;
   else chain.inPT = false;
   if (!chain.inPT && !chain.walk) chain.modes.add("car");
   else if (!chain.inPT && chain.walk && !beforeInPT) chain.modes.add("walk");
   else if (chain.walk) chain.modes.add("transit_walk");
   else
     chain.modes.add(
         getMode(
             transitSchedule
                 .getTransitLines()
                 .get(chain.lineId)
                 .getRoutes()
                 .get(chain.routeId)
                 .getTransportMode(),
             chain.lineId));
   chain.times.add(event.getTime() - chain.lastTime);
 }
Пример #4
0
 @Override
 public void handleEvent(final ActivityStartEvent event) {
   starts.put(event.getPersonId(), event.getTime());
 }
Пример #5
0
 @Override
 public void handleEvent(ActivityStartEvent event) {
   startTimes.put(
       event.getPersonId(), new Tuple<String, Double>(event.getActType(), event.getTime()));
 }