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();
          }
        }
      }
    }
Ejemplo n.º 2
0
 @Override
 public void handleEvent(LinkEnterEvent event) {
   CarrierAgent carrierAgent = getCarrierAgent(event.getDriverId());
   if (carrierAgent == null) return;
   carrierAgent.handleEvent(event);
 }
    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;
              }
            }
          }
        }
      }
    }
Ejemplo n.º 4
0
 @Override
 public void handleEvent(final LinkEnterEvent event) {
   if (ignoreLinkEvents) return;
   handleEvent(eventsPerPerson, event.getDriverId(), event);
 }
 @Override
 public void handleEvent(LinkEnterEvent event) {
   if (event.getDriverId().equals(filterEventsForAgentId)) {
     System.out.println(event.toString());
   }
 }
 @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;
 }