@Override
  public void handleEvent(LinkEnterEvent event) {

    double linkLength = this.scenario.getNetwork().getLinks().get(event.getLinkId()).getLength();

    if (ptDrivers.contains(event.getVehicleId())) {

      if (driverId2totalDistance.containsKey(event.getVehicleId())) {
        driverId2totalDistance.put(
            Id.createPersonId(event.getVehicleId()),
            driverId2totalDistance.get(Id.createPersonId(event.getVehicleId())) + linkLength);
      } else {
        driverId2totalDistance.put(Id.createPersonId(event.getVehicleId()), linkLength);
      }

    } else {
      // updating the trip Length
      int tripNumber = personId2currentTripNumber.get(event.getVehicleId());
      double distanceBefore =
          personId2tripNumber2tripDistance.get(event.getVehicleId()).get(tripNumber);
      double updatedDistance = distanceBefore + linkLength;
      Map<Integer, Double> tripNumber2tripDistance =
          personId2tripNumber2tripDistance.get(event.getVehicleId());
      tripNumber2tripDistance.put(tripNumber, updatedDistance);
      personId2tripNumber2tripDistance.put(
          Id.createPersonId(event.getVehicleId()), tripNumber2tripDistance);
    }
  }
示例#2
0
 public void handleEvent(LinkEnterEvent enter) {
   if (toll == null) this.enterTimes.put(enter.getPersonId().toString(), enter.getTime());
   else {
     if (TollTools.isInRange(enter.getLinkId(), toll))
       this.enterTimes.put(enter.getPersonId().toString(), enter.getTime());
   }
 }
示例#3
0
 @Override
 public void handleEvent(LinkEnterEvent e) {
   if (e.getLinkId().equals(id2)) {
     this.personIdLinkEnterEventMap.put(e.getPersonId(), e);
     this.vehOn1++;
   } else if (e.getLinkId().equals(id3)) {
     this.personIdLinkEnterEventMap.put(e.getPersonId(), e);
     this.vehOn2++;
   }
 }
示例#4
0
    @Override
    public void handleEvent(LinkEnterEvent event) {

      if (event.getLinkId().equals(this.fixture.id2)) {
        lastLink2EnterEvent = event;
        log.info(event);
      } else if (event.getLinkId().equals(this.fixture.id3)) {
        lastLink3EnterEvent = event;
        log.info(event);
      } else if (event.getLinkId().equals(this.fixture.id1)) {
        lastLink1EnterEvent = event;
      }
    }
  @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(LinkEnterEvent event) {
   Id<Vehicle> vehicleId = event.getVehicleId();
   if (!this.transitVehicles.contains(vehicleId)) {
     return; // ignore non-transit vehicles
   }
   String linkId = event.getLinkId().toString();
   if (linksToMonitorCache.contains(linkId)) {
     Integer count = ptCounts.get(linkId);
     Integer nPassengers = this.vehPassengers.get(vehicleId);
     if (nPassengers != null) {
       count += nPassengers;
     }
     ptCounts.put(linkId, count);
   }
 }
示例#7
0
    @Override
    public void handleEvent(LinkEnterEvent 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);
    }
示例#8
0
 @Override
 public void handleEvent(LinkEnterEvent event) {
   LinkInfo info = this.map.get(event.getLinkId());
   if (info == null) {
     return;
   }
   synchronized (info) {
     info.onLink++;
     info.text = Integer.toString(info.onLink);
     updateColor(info);
   }
 }
  void handle(LinkEnterEvent event) {
    if (event.getLinkId().equals(GlobalFlowDynamicsUpdator.FLOW_DYNAMICS_UPDATE_LINK)) {
      Id<Person> personId = this.delegate.getDriverOfVehicle(event.getVehicleId());
      double nowTime = event.getTime();

      this.updateFlow900(nowTime, this.vehicleType.getPcuEquivalents());
      this.updateSpeedTable(nowTime, personId);

      // Checking for stability
      // Making sure all agents are on the track before testing stability
      // Also waiting half an hour to let the database build itself.

      if ((this.getNumberOfDrivingAgents() == this.numberOfAgents)
          && (nowTime > InputsForFDTestSetUp.MAX_ACT_END_TIME * 2)) {
        if (!(this.speedStability)) {
          this.checkSpeedStability();
        }
        if (!(this.flowStability)) {
          this.checkFlowStability900();
        }
      }
    }
  }
    public void handle(LinkEnterEvent event) {
      if (event.getLinkId().equals(flowDynamicsMeasurementLinkId)) {
        Id<Person> personId = Id.createPersonId(event.getDriverId());
        double nowTime = event.getTime();

        this.updateFlow900(nowTime, this.vehicleType.getPcuEquivalents());
        this.updateSpeedTable(nowTime, personId);

        // Checking for stability
        // Making sure all agents are on the track before testing stability
        // Also waiting half an hour to let the database build itself.

        if ((this.getNumberOfDrivingAgents() == this.numberOfAgents)
            && (nowTime > 1800)) { // TODO empirical factor
          if (!(this.speedStability)) {
            this.checkSpeedStability();
          }
          if (!(this.flowStability)) {
            this.checkFlowStability900();
          }
        }
      }
    }
  @Override
  public void handleEvent(LinkEnterEvent event) {
    try {
      if (ptVehicles.keySet().contains(event.getVehicleId())) {
        PTVehicle ptVehicle = ptVehicles.get(event.getVehicleId());
        ptVehicle.in = true;
        ptVehicle.setLinkEnterTime(event.getTime());
      } else {
        chains
            .get(driverIdFromVehicleId.get(event.getVehicleId()))
            .setLinkEnterTime(event.getTime());
      }

    } catch (Exception e) {
      System.err.println(e.getStackTrace());
      System.err.println(event.toString());
    }
  }
示例#12
0
 @Override
 public void handleEvent(LinkEnterEvent e) {
   if (e.getLinkId().equals(Fixture.linkId2)) {
     Assert.assertEquals(link2EnterTime, e.getTime(), MatsimTestUtils.EPSILON);
   }
 }
 @Override
 public void handleEvent(LinkEnterEvent event) {
   LinkInfo linkInfo = linkInfos.get(event.getLinkId());
   linkInfo.addEvent(event);
 }
 @Override
 public void handleEvent(LinkEnterEvent event) {
   if (event.getDriverId().equals(filterEventsForAgentId)) {
     System.out.println(event.toString());
   }
 }
 @Override
 public void handleEvent(LinkEnterEvent event) { // call from
   // NetworkReadExample
   enterLink(event.getLinkId(), event.getTime());
 }
 @Override
 public void handleEvent(LinkEnterEvent event) {
   CarrierAgent carrierAgent = getCarrierAgent(event.getDriverId());
   if (carrierAgent == null) return;
   carrierAgent.handleEvent(event);
 }
示例#17
0
 @Override
 public void handleEvent(final LinkEnterEvent event) {
   if (ignoreLinkEvents) return;
   handleEvent(eventsPerPerson, event.getDriverId(), event);
 }
 @Override
 public void handleEvent(LinkEnterEvent event) {
   if (event.getVehicleId().toString().startsWith("tr"))
     ptVehicles.get(event.getVehicleId()).in = true;
   else chains.get(event.getDriverId()).in = true;
 }
    public void handleEvent(LinkEnterEvent event) {
      if (!(permanentRegime)) {
        Id<Person> personId = Id.createPersonId(event.getDriverId());

        // Disaggregated data updating methods
        String travelMode = person2Mode.get(personId);

        Id<VehicleType> transportMode = modeVehicleTypes.get(travelMode).getId();
        this.travelModesFlowData.get(transportMode).handle(event);
        double pcuVeh = modeVehicleTypes.get(travelMode).getPcuEquivalents();

        // Aggregated data update
        double nowTime = event.getTime();
        if (event.getLinkId().equals(flowDynamicsMeasurementLinkId)) {
          this.globalFlowData.updateFlow900(nowTime, pcuVeh);
          this.globalFlowData.updateSpeedTable(nowTime, personId);
          // Waiting for all agents to be on the track before studying stability
          if ((this.globalFlowData.getNumberOfDrivingAgents() == this.globalFlowData.numberOfAgents)
              && (nowTime > 1800)) { // TODO parametrize this correctly
            /*//Taking speed check out, as it is not reliable on the global speed table
             *  Maybe making a list of moving averages could be smart,
             *  but there is no reliable converging process even in that case. (ssix, 25.10.13)
             * if (!(this.globalData.isSpeedStable())){
            	this.globalData.checkSpeedStability();
            	System.out.println("Checking speed stability in global data for: "+this.globalData.getSpeedTable());
            }*/
            if (!(this.globalFlowData.isFlowStable())) {
              this.globalFlowData.checkFlowStability900();
            }

            // Checking modes stability
            boolean modesStable = true;
            for (Id<VehicleType> vehTyp : this.travelModesFlowData.keySet()) {
              if (this.travelModesFlowData.get(vehTyp).numberOfAgents != 0) {
                if (!this.travelModesFlowData.get(vehTyp).isSpeedStable()
                    || !(this.travelModesFlowData.get(vehTyp).isFlowStable())) {
                  modesStable = false;
                  break;
                }
              }
            }
            if (modesStable) {
              // Checking global stability
              if (
              /*this.globalData.isSpeedStable() &&*/ this.globalFlowData.isFlowStable()) {
                LOG.info("========== Global permanent regime is attained");
                for (Id<VehicleType> vehTyp : this.travelModesFlowData.keySet()) {
                  this.travelModesFlowData.get(vehTyp).saveDynamicVariables();
                }
                this.globalFlowData.setPermanentAverageVelocity(
                    this.globalFlowData.getActualAverageVelocity());
                // this.permanentFlow = this.getActualFlow();
                this.globalFlowData.setPermanentFlow(this.globalFlowData.getCurrentHourlyFlow());
                double globalDensity = 0.;
                for (TravelModesFlowDynamicsUpdator mode : this.travelModesFlowData.values()) {
                  globalDensity += mode.getPermanentDensity();
                }
                this.globalFlowData.setPermanentDensity(globalDensity);
                this.permanentRegime = true;
              }
            }
          }
        }
      }
    }