@Override public void handleEvent(LinkLeaveEvent event) { // store information from event to variables // String eventType = event.getEventType(); Id<Link> linkId = event.getLinkId(); // String linkShortened = linkId.toString().substring(0, 10) + "..."; Id<Person> personId = event.getDriverId(); // double time = event.getTime(); // Id vehicleId = event.getVehicleId(); // add information concerning passed links to the object "Trip" Id<Trip> tripId = Id.create(personId + "_" + activityEndCount.get(personId), Trip.class); if (trips.get(tripId).getLinks().isEmpty()) { if (trips.get(tripId).getDepartureLinkId().equals(linkId)) { trips.get(tripId).getLinks().add(linkId); // System.out.println("Added first link to trip " + tripId); } else { // System.err.println("First route link different from departure link!"); throw new RuntimeException("First route link different from departure link!"); } } else { trips.get(tripId).getLinks().add(linkId); // System.out.println("Added another link to trip " + tripId); // System.out.println("List of trip " + tripId + " has now " + // trips.get(tripId).getLinks().size() + " elements"); } }
@Override public void handleEvent(LinkLeaveEvent event) { // ignore non-car travelers if (!this.carAgents.contains(event.getPersonId())) return; // call from NetworkReadExample linkLeave(event.getLinkId(), event.getTime()); }
public void handleEvent(LinkLeaveEvent leave) { Double enterTime = this.enterTimes.remove(leave.getPersonId().toString()); if (enterTime != null) { Link l = this.network.getLinks().get(leave.getLinkId()); if (l != null) { this.lengthSum += l.getLength() / 1000.0; this.timeSum += (leave.getTime() - enterTime.doubleValue()) / 3600.0; } } }
@Override public void handleEvent(LinkLeaveEvent e) { LinkEnterEvent enterEvent = null; if (e.getLinkId().equals(id4)) { enterEvent = this.personIdLinkEnterEventMap.get(e.getPersonId()); this.vehOn1--; } else if (e.getLinkId().equals(id5)) { enterEvent = this.personIdLinkEnterEventMap.get(e.getPersonId()); this.vehOn2--; } }
@Override public void handleEvent(LinkLeaveEvent event) { Id<Person> driverId = vehicleToDriver.get(event.getVehicleId()); if (!eventsByPerson.containsKey(driverId)) { eventsByPerson.put(driverId, new LinkedList<Event>()); } eventsByPerson.get(driverId).add(event); allEvents.add(event); }
@Override public void handleEvent(LinkLeaveEvent event) { if (event.getVehicleId().toString().startsWith("tr")) { PTVehicle vehicle = ptVehicles.get(event.getVehicleId()); if (vehicle.in) { vehicle.in = false; vehicle.incDistance(network.getLinks().get(event.getLinkId()).getLength()); } } else { TravellerChain chain = chains.get(event.getDriverId()); if (chain == null) { chain = new TravellerChain(); chains.put(event.getDriverId(), chain); chain.modes.add("car"); chain.distances.add(0.0); } else { if (chain.in) { chain.in = false; if (chain.modes.size() == chain.distances.size() && chain.modes.get(chain.modes.size() - 1).equals("car")) { double linkDistance = network.getLinks().get(event.getLinkId()).getLength(); chain.distances.set( chain.distances.size() - 1, chain.distances.get(chain.distances.size() - 1) + linkDistance); } else if (chain.modes.size() == chain.distances.size()) throw new RuntimeException("Person is leaving a link, but is not in a car mode"); else throw new RuntimeException("Modes list has not the same size of distances list (car)"); } else { chain.modes.add("car"); chain.distances.add(0.0); } } } }
@Override public void handleEvent(LinkLeaveEvent event) { LinkInfo info = this.map.get(event.getLinkId()); if (info == null) { return; } // if (event.getLinkId().toString().contains("el")){ // throw new RuntimeException("ERROR"); // } synchronized (info) { info.onLink--; info.text = Integer.toString(info.onLink); updateColor(info); } }
@Override public void handleEvent(LinkLeaveEvent event) { try { if (ptVehicles.keySet().contains(event.getVehicleId())) { PTVehicle vehicle = ptVehicles.get(event.getVehicleId()); if (vehicle.in) vehicle.in = false; vehicle.incDistance(network.getLinks().get(event.getLinkId()).getLength()); } else { TravellerChain chain = chains.get(driverIdFromVehicleId.get(event.getVehicleId())); if (chain.inCar) { Journey journey = chain.getJourneys().getLast(); journey.incrementCarDistance(network.getLinks().get(event.getLinkId()).getLength()); } } } catch (Exception e) { System.err.println(e.getStackTrace()); System.err.println(event.toString()); } }
@Override public void handleEvent(LinkLeaveEvent event) { LinkInfo linkInfo = linkInfos.get(event.getLinkId()); linkInfo.addEvent(event); }
@Override public void handleEvent(LinkLeaveEvent event) { // System.out.println("leaveEvent"); /*-------*/ Id personId = event.getPersonId(); Id linkId = event.getLinkId(); /*-------*/ double time = event.getTime(); int hour = calculateTimeClass(time); double hourd = (double) hour; // String timePeriod = timeClassToTimePeriode(hour); /*-------*/ LinkImpl link = (LinkImpl) this.network.getLinks().get(linkId); double freeSpeedInMs = link.getFreespeed(time); double freeSpeedInKmh = freeSpeedInMs * 3.6; /*-------*/ // calculation of vehicles per hour; this method works well but I cannot use it for computing // noise emissions // therefore I create and fill a second Map linkId2hourd2vehicles below // Map: linkId2hour2vehicles // if the linkId doesn't exist in the map: add it with an 24x2 array: 24 hours x totalvehicles // and HDV, set totalvehicles and HDV to zero if (!linkId2hour2vehicles.containsKey(linkId)) { double[][] hour2vehicles = new double[24][3]; for (int i = 0; i < 24; ++i) { hour2vehicles[i][0] = 0.0; // first element includes cars hour2vehicles[i][1] = 0.0; // the second element includes HDV hour2vehicles[i][2] = freeSpeedInKmh; } linkId2hour2vehicles.put(linkId, hour2vehicles); } int index = hour - 1; if (index < 24) { /*check if it is a heavy duty vehicle, example event from events file: <event time="580.0" type="left link" person="gv_5327" link="12132-12230-554320342-12221" vehicle="gv_5327" /> other activity types for gv: actend, departure, PersonEntersVehicle, wait2link, entered link*/ if (personId.toString().contains("gv_")) { // increment HDV // ++ linkId2hour2vehicles.get(linkId)[index][0] ; ++linkId2hour2vehicles.get(linkId)[index][1]; } else { ++linkId2hour2vehicles.get(linkId)[index][0]; // increment cars } } // end calculation of vehicles per hour version one with hour as integer /*-------*/ // 2nd version start, in analogy to FH: linkId2timePeriod2trafficInfo if (!linkId2hourd2vehicles.containsKey(linkId)) { double[] trafficInfo = new double[3]; // initialize the array trafficInfo[0] = freeSpeedInKmh; // the first element of the array contains freespeed trafficInfo[1] = 1.0; // the second element of the array contains the total number of vehicles if (personId.toString().contains("gv_")) { trafficInfo[2] = 1.0; // the third element contains the number of heavy duty vehicles } else { trafficInfo[2] = 0.0; } // FH: Map<String, double[]> timeToTrafficInfo = new TreeMap<String, double[]>(); Map<Double, double[]> timeToTrafficInfo = new TreeMap<Double, double[]>(); timeToTrafficInfo.put(hourd, trafficInfo); linkId2hourd2vehicles.put(linkId, timeToTrafficInfo); } else { if (!linkId2hourd2vehicles.get(linkId).containsKey(hourd)) { double[] trafficInfo = new double[3]; trafficInfo[0] = freeSpeedInKmh; // the first element of the array contains freespeed trafficInfo[1] = 1.0; // the second element of the array contains the total number of vehicles if (personId.toString().contains("gv_")) { trafficInfo[2] = 1.0; // the third element contains the number of HDV } else { trafficInfo[2] = 0.0; } linkId2hourd2vehicles.get(linkId).put(hourd, trafficInfo); } else { if (personId.toString().contains("gv_")) { ++linkId2hourd2vehicles.get(linkId).get(hourd)[2]; } ++linkId2hourd2vehicles.get(linkId).get(hourd)[1]; } } }
@Override public void handleEvent(final LinkLeaveEvent event) { if (ignoreLinkEvents) return; handleEvent(eventsPerPerson, event.getDriverId(), event); }
@Override public void handleEvent(LinkLeaveEvent event) { linkDeltas.get(event.getLinkId()).delta--; }
@Override public void handleEvent(LinkLeaveEvent event) { if (event.getDriverId().equals(filterEventsForAgentId)) { System.out.println(event.toString()); } }
@Override public void handleEvent(LinkLeaveEvent event) { if (vehicleIds.contains(event.getVehicleId())) { delegate.handleEvent(event); } }