private static VolumesAnalyzer readVolumes(final Network network, final String eventsFile) {
   final VolumesAnalyzer volumes = new VolumesAnalyzer(3600, 24 * 3600 - 1, network);
   final EventsManager events = EventsUtils.createEventsManager();
   events.addHandler(volumes);
   new MatsimEventsReader(events).readFile(eventsFile);
   return volumes;
 }
示例#2
0
 // Main
 public static void main(String[] args) throws IOException {
   final String CSV_SEPARATOR = "\t";
   EventsManager events = EventsUtils.createEventsManager();
   TypeActivityAnalyzer typeActivityAnalyzer = new TypeActivityAnalyzer(300, 30 * 3600);
   events.addHandler(typeActivityAnalyzer);
   new EventsReaderXMLv1(events).parse(args[0]);
   typeActivityAnalyzer.finishActivities();
   PrintWriter writer = new PrintWriter(new File("./data/durationsByType.txt"));
   for (String type : typeActivityAnalyzer.getDurations().keySet()) {
     for (Entry<Double, Integer> count : typeActivityAnalyzer.getDurations().get(type).entrySet())
       writer.println(
           Time.writeTime(count.getKey())
               + CSV_SEPARATOR
               + type
               + CSV_SEPARATOR
               + count.getValue());
   }
   writer.close();
   writer = new PrintWriter(new File("./data/performingByType.txt"));
   for (String type : typeActivityAnalyzer.getPeoplePerforming().keySet()) {
     for (Entry<Double, Integer> count :
         typeActivityAnalyzer.getPeoplePerforming().get(type).entrySet())
       writer.println(
           Time.writeTime(count.getKey())
               + CSV_SEPARATOR
               + type
               + CSV_SEPARATOR
               + count.getValue());
   }
   writer.close();
 }
  public void readEvents(String filename) {
    EventsManager events = EventsUtils.createEventsManager();
    Collections.sort(this.timeSteps);

    this.handlerList = new LinkedList<DelayHandler>();

    for (int i = 0; i < this.timeSteps.size(); i++) {

      if (i == 0) {
        DelayHandler handler = new DelayHandler(0.0, this.timeSteps.get(i).doubleValue());
        events.addHandler(handler);
        this.handlerList.add(handler);
      } else {
        DelayHandler handler =
            new DelayHandler(
                this.timeSteps.get(i - 1).doubleValue(), this.timeSteps.get(i).doubleValue());
        events.addHandler(handler);
        this.handlerList.add(handler);
      }
    }

    DelayHandler handler =
        new DelayHandler(
            this.timeSteps.get(this.timeSteps.size() - 1).doubleValue(), Double.MAX_VALUE);
    events.addHandler(handler);
    this.handlerList.add(handler);

    EventsReaderXMLv1 reader = new EventsReaderXMLv1(events);
    reader.readFile(filename);
  }
 private void processCongestions(String eventFile) {
   EventsManager eventsManager = EventsUtils.createEventsManager();
   MatsimEventsReader eventsReader = new MatsimEventsReader(eventsManager);
   this.congestionPerLinkHandler = new ExperiencedDelayHandler(scenario, noOfTimeBins);
   eventsManager.addHandler(this.congestionPerLinkHandler);
   eventsReader.readFile(eventFile);
 }
 private void processEmissions(String emissionFile) {
   EventsManager eventsManager = EventsUtils.createEventsManager();
   EmissionEventsReader emissionReader = new EmissionEventsReader(eventsManager);
   this.warmHandler = new EmissionsPerLinkWarmEventHandler(this.simulationEndTime, noOfTimeBins);
   eventsManager.addHandler(this.warmHandler);
   emissionReader.parse(emissionFile);
 }
  public MeanQueueLengthCalculator() throws Exception {
    scenario = (ScenarioImpl) ScenarioUtils.createScenario(ConfigUtils.createConfig());
    new MatsimNetworkReader(scenario).readFile(networkFile);

    linkInfos = new HashMap<Id, LinkInfo>();

    counts = new HashMap<Id, AtomicInteger>();
    sumCountsPerHour = new HashMap<Id, AtomicInteger>();
    meanCounts = new HashMap<Id, double[]>();

    for (Link link : scenario.getNetwork().getLinks().values()) {
      linkInfos.put(link.getId(), new LinkInfo(link.getId()));

      counts.put(link.getId(), new AtomicInteger());
      sumCountsPerHour.put(link.getId(), new AtomicInteger());
      meanCounts.put(link.getId(), new double[hours]);
    }

    log.info("start reading events file...");
    EventsManager eventsManager = (EventsManager) EventsUtils.createEventsManager();
    eventsManager.addHandler(this);

    MatsimEventsReader eventsReader = new MatsimEventsReader(eventsManager);
    eventsReader.readFile(eventsFile);
    log.info("done.");

    for (LinkInfo linkInfo : linkInfos.values()) {
      getLinkStatistic(linkInfo);
    }

    log.info("start writing file...");
    writeFile();
    log.info("done.");
  }
示例#7
0
  @Override
  public void run() {
    String eventsFile1 = "output/ITERS/it.10/10.events.xml.gz";
    String eventsFile2 = "outputBridgeClosed/ITERS/it.20/20.events.xml.gz";
    EventsManager before = EventsUtils.createEventsManager();
    EventsManager after = EventsUtils.createEventsManager();

    String network = "output/output_network.xml.gz";
    MutableScenario scenario =
        (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig());
    new MatsimNetworkReader(scenario).readFile(network);

    for (Entry<Id<Link>, ? extends Link> entry : scenario.getNetwork().getLinks().entrySet()) {
      linkDeltas.put(entry.getKey(), new AnalysisLink());
    }

    before.addHandler(new Before());
    after.addHandler(new After());

    new MatsimEventsReader(before).readFile(eventsFile1);
    new MatsimEventsReader(after).readFile(eventsFile2);

    initFeatureType();

    ArrayList<SimpleFeature> features = new ArrayList<SimpleFeature>();
    for (Entry<Id<Link>, ? extends Link> entry : scenario.getNetwork().getLinks().entrySet()) {
      features.add(getFeature(entry.getValue()));
    }

    ShapeFileWriter.writeGeometries(features, "output/delta-network");
  }
  public static void main(String[] args) throws Exception {
    Config config = ConfigUtils.loadConfig(configFile, new EmissionsConfigGroup());

    Scenario scenario = ScenarioUtils.loadScenario(config);

    // following is only for backward compatibility in which vehicle description is null;
    // for the new scenarios, setting vehicle description should be preferred.; Amit, sep 2016.
    EmissionsConfigGroup ecg =
        (EmissionsConfigGroup) scenario.getConfig().getModule(EmissionsConfigGroup.GROUP_NAME);
    ecg.setUsingVehicleTypeIdAsVehicleDescription(true);

    EmissionModule emissionModule = new EmissionModule(scenario);
    emissionModule.createLookupTables();
    emissionModule.createEmissionHandler();

    EventsManager eventsManager = EventsUtils.createEventsManager();
    eventsManager.addHandler(emissionModule.getWarmEmissionHandler());
    eventsManager.addHandler(emissionModule.getColdEmissionHandler());

    EventWriterXML emissionEventWriter = new EventWriterXML(emissionEventOutputFile);
    emissionModule.getEmissionEventsManager().addHandler(emissionEventWriter);

    MatsimEventsReader matsimEventsReader = new MatsimEventsReader(eventsManager);
    matsimEventsReader.readFile(eventsFile);

    emissionEventWriter.closeFile();

    emissionModule.writeEmissionInformation(emissionEventOutputFile);
  }
  private void readEvents() {
    reset(0);

    EventsManager eventsManager = (EventsManager) EventsUtils.createEventsManager();
    eventsManager.addHandler(this);
    MatsimEventsReader reader = new MatsimEventsReader(eventsManager);
    reader.readFile(eventsFile);
  }
示例#10
0
  public static void main(String[] args) {

    // Dummy MATSim scenario including dummy network
    Config conf = ConfigUtils.createConfig();
    conf.global().setCoordinateSystem("EPSG:3395");
    Scenario sc = ScenarioUtils.createScenario(conf);
    //		Sim2DConfig conf2d = Sim2DConfigUtils.createConfig();
    //		Sim2DScenario sc2d = Sim2DScenarioUtils.createSim2dScenario(conf2d);
    //		sc.addScenarioElement(Sim2DScenario.ELEMENT_NAME,sc2d);
    Network net = sc.getNetwork();
    NetworkFactory fac = net.getFactory();
    Node n0 = fac.createNode(Id.create("0", Node.class), new Coord(minX, minY));
    Node n1 = fac.createNode(Id.create("1", Node.class), new Coord(minX, maxY));
    Node n2 = fac.createNode(Id.create("2", Node.class), new Coord(maxX, maxY));
    Node n3 = fac.createNode(Id.create("3", Node.class), new Coord(maxX, minY));
    net.addNode(n0);
    net.addNode(n1);
    net.addNode(n2);
    net.addNode(n3);

    // visualization stuff
    EventsManager em = new EventsManagerImpl();
    EventBasedVisDebuggerEngine vis = new EventBasedVisDebuggerEngine(sc);
    em.addHandler(vis);

    // routing algorithm - for now standard Dijkstra could be replaced by A*  in future
    Dijkstra d = new Dijkstra(env);

    // dummy data
    int number = 20;
    for (double time = 0; time <= 1000; time++) {
      List<XYVxVyEventImpl> events = createDummyData(MatsimRandom.getRandom().nextInt(21), time);

      List<TwoDObject> objs = new ArrayList<TwoDObject>();
      for (XYVxVyEventImpl e : events) {
        em.processEvent(e); // needed for visualization
        objs.add(e);
      }

      System.out.println("");
      LinearQuadTreeLD quad = new LinearQuadTreeLD(objs, env, em);

      // routing
      List<Quad> fromL = quad.query(new Envelope(0, 0.1, 0, 0.1));
      Quad from = fromL.get(0);
      List<Quad> toL = quad.query(new Envelope(19.9, 20, 19.9, 20));
      Quad to = toL.get(0);
      LinkedList<Quad> path = d.computeShortestPath(quad, from, to);
      path.addFirst(from);
      draw(path, em);
      //			to.getEnvelope().get
      try {
        Thread.sleep(2000); // to slow it down a bit
      } catch (InterruptedException e1) {
        e1.printStackTrace();
      }
    }
  }
  public static void main(final String[] args) {
    final String eventFile = args[0];
    final String outFile = args[1];

    final Handler handler = new Handler(outFile);
    final EventsManager events = EventsUtils.createEventsManager();
    events.addHandler(handler);
    new EventsReaderXMLv1(events).parse(eventFile);
    handler.close();
  }
  @Override
  public void preProcessData() {

    double simulationEndTime = LoadMyScenarios.getSimulationEndTime(this.configFile);
    this.handler = new TollInfoHandler(simulationEndTime, noOfTimeBin);

    EventsManager events = EventsUtils.createEventsManager();
    MatsimEventsReader reader = new MatsimEventsReader(events);
    events.addHandler(handler);
    reader.readFile(eventsFile);
  }
 private void runEventReader(File eventFile) {
   this.eventHandler = null;
   EventsManager e = EventsUtils.createEventsManager();
   EventsReaderXMLv1 reader = new EventsReaderXMLv1(e);
   this.readerThread =
       new Thread(new EventReaderThread(reader, eventFile.toString()), "readerthread");
   this.eventHandler =
       new EventHandler(eventFile.getName(), this.sc, this.getGridSize(), this.readerThread);
   e.addHandler(this.eventHandler);
   this.readerThread.run();
 }
示例#14
0
 private void splitEventsToMultipleSortedFiles() {
   EventsManager events = EventsUtils.createEventsManager();
   SplitEventsToMultipleSortedFiles setmsf =
       new SplitEventsToMultipleSortedFiles(outputPath + "\\sorted_", 100000);
   events.addHandler(setmsf);
   EventsReaderXMLv1 reader = new EventsReaderXMLv1(events);
   reader.setValidating(false);
   reader.parse(inFileName);
   setmsf.writeQueue();
   setmsf.closeFile();
 }
示例#15
0
  private void run() {
    EventsManager eventsManager = EventsUtils.createEventsManager();
    EventWriterXML mew = new EventWriterXML(morningFile);
    EventWriterXML eew = new EventWriterXML(eveningFile);
    eventsManager.addHandler(new ManteuffelEmissionEventsFilter(mew, eew));

    EmissionEventsReader emissionEventsReader = new EmissionEventsReader(eventsManager);
    emissionEventsReader.parse(emissionEventsFile);

    mew.closeFile();
    eew.closeFile();
  }
示例#16
0
  @Override
  public void preProcessData() {

    EventsManager manager = EventsUtils.createEventsManager();
    MatsimEventsReader reader = new MatsimEventsReader(manager);

    for (String eventsFile : this.eventsFiles) {
      StuckEventsHandler h = new StuckEventsHandler();
      handlers.add(h);
      manager.addHandler(h);
      reader.readFile(eventsFile);
    }
  }
示例#17
0
  /** @param args */
  public static void main(String[] args) {
    String eventsFilename =
        "../berlin-bvg09/pt/m2_schedule_delay/m2_out_100a_opt/m2_out_100a_opt/ITERS/it.1000/1000.events.xml.gz";

    EventsManager em = (EventsManager) EventsUtils.createEventsManager();
    WaitOrSeatInBus wosib = new WaitOrSeatInBus(30);
    em.addHandler(wosib);

    new MatsimEventsReader(em).readFile(eventsFilename);

    wosib.write(
        "../berlin-bvg09/pt/m2_schedule_delay/m2_out_100a_opt/m2_out_100a_opt/ITERS/it.1000/m2_out_100a_opt.1000.wosib.");
  }
  @Test
  @Ignore
  public void testNoEvents() {

    KNAnalysisEventsHandler testee = new KNAnalysisEventsHandler(this.scenario);

    EventsManager events = EventsUtils.createEventsManager();
    events.addHandler(testee);

    // add events to handle here

    this.runTest(testee);
  }
  private void run() {
    LegModeRouteDistanceDistributionHandler lmdfed =
        new LegModeRouteDistanceDistributionHandler(sc);

    EventsManager manager = EventsUtils.createEventsManager();
    MatsimEventsReader reader = new MatsimEventsReader(manager);
    manager.addHandler(lmdfed);
    reader.readFile(eventsFile);

    this.mode2PersonId2RouteDist = lmdfed.getMode2PersonId2TravelDistances();
    getUserGroupDistanceMeanAndMeadian();
    createBoxPlotData(lmdfed.getLegMode2PersonId2TotalTravelDistance().get(mainMode));
    writeResults(this.outputDir + "/analysis/");
  }
示例#20
0
  private void test1PersonStartingOnLane(boolean reduceCap) {
    fixture.create1PersonFromLink1Population();

    if (reduceCap) {
      fixture.sc.getConfig().qsim().setStartTime(3500.0);
      fixture.sc.getConfig().qsim().setEndTime(7200.0);
      LaneDefinitions20 lanes = fixture.sc.getLanes();
      Lane lane1 =
          lanes.getLanesToLinkAssignments().get(fixture.id1).getLanes().get(fixture.laneId1);
      lane1.setCapacityVehiclesPerHour(1800.0);
      Lane lane1ol =
          lanes
              .getLanesToLinkAssignments()
              .get(fixture.id1)
              .getLanes()
              .get(fixture.link1FirstLaneId);
      lane1ol.setCapacityVehiclesPerHour(1800.0);
    }

    EventsManager events = EventsUtils.createEventsManager();
    MixedLanesEventsHandler handler = new MixedLanesEventsHandler(this.fixture);
    events.addHandler(handler);
    QSim qsim = QSimUtils.createDefaultQSim(this.fixture.sc, events);
    qsim.run();
    Assert.assertNotNull(handler.lastAgentDepartureEvent);
    Assert.assertEquals(3600.0, handler.lastAgentDepartureEvent.getTime(), testUtils.EPSILON);

    Assert.assertNull(handler.lastLink1EnterEvent);

    Assert.assertNull(handler.lastLane1olEnterEvent);
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT, handler.lastLane1olLeaveEvent.getTime(), testUtils.EPSILON);
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT, handler.lastLane1EnterEvent.getTime(), testUtils.EPSILON);
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT + laneTTlane1,
        handler.lastLane1LeaveEvent.getTime(),
        testUtils.EPSILON);

    Assert.assertNotNull(handler.lastLink2EnterEvent);
    Assert.assertEquals(
        this.fixture.pid1, handler.vehId2DriverId.get(handler.lastLink2EnterEvent.getVehicleId()));
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT + laneTTlane1,
        handler.lastLink2EnterEvent.getTime(),
        testUtils.EPSILON);

    Assert.assertNull(handler.lastLink3EnterEvent);
  }
  /**
   * Parses an events file, checking for {@link LinkEnterEvent}s on a given set of {@link Link}s.
   * The events are handled in a way to provide a {@link Map} of people entering the observed links,
   * as well as their accumulated toll;
   *
   * @param eventsFile
   * @param linkList
   * @param breakList a {@link List} of {@link Person} {@link Id}s that mark the upper limit (not
   *     including) of the category of agents. (JJ, I guess we assume the list is sorted in
   *     ascending order).
   * @param scheme the {@link RoadPricingSchemeImpl}
   * @return a {@link List} of {@link Map}s (one for each agent category) of people that entered
   *     (one or more times) an observed link, as well as the <i>number</i> of times that agent
   *     entered observed links.
   * @see MyTollPotentialEventHandler
   */
  public void processEventsFile(
      String eventsFile,
      List<Id<Link>> linkList,
      List<Id<Person>> breakList,
      RoadPricingScheme scheme) {
    log.info("Processing events from " + eventsFile);
    EventsManager em = EventsUtils.createEventsManager();
    MyTollPotentialEventHandler eh = new MyTollPotentialEventHandler(linkList, breakList, scheme);
    em.addHandler(eh);
    MatsimEventsReader mer = new MatsimEventsReader(em);
    mer.readFile(eventsFile);

    this.valueMaps = eh.getValueMaps();
    this.countMaps = eh.getCountMaps();
  }
  public static void main(String[] args) {

    if (args != null && args.length != 0) {
      inputFile = args[0];
    }

    EventsManager em = EventsUtils.createEventsManager();
    EventWriterXML eventWriter = new EventWriterXML(outputFile);
    em.addHandler(eventWriter);

    EventsConverterXML converter = new EventsConverterXML(em);
    converter.readFile(inputFile);

    eventWriter.closeFile();
  }
  public static void main(final String[] args) throws Exception {
    final String inputEventsFile = args[0];
    final String inputNetworkFile = args[1];
    final String outputXyFile = args[2];

    final Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig());
    new MatsimNetworkReader(sc.getNetwork()).readFile(inputNetworkFile);

    final BufferedWriter writer = IOUtils.getBufferedWriter(outputXyFile);
    final EventsManager events = EventsUtils.createEventsManager();
    events.addHandler(new Handler(sc.getNetwork(), writer));

    new MatsimEventsReader(events).readFile(inputEventsFile);
    writer.close();
  }
示例#24
0
  private LinkDemandEventHandler analyzeEvents(String outputDirectory, String configFile) {

    Config config = ConfigUtils.loadConfig(configFile);
    Scenario scenario = ScenarioUtils.loadScenario(config);

    EventsManager eventsManager = EventsUtils.createEventsManager();

    LinkDemandEventHandler handler = new LinkDemandEventHandler(scenario.getNetwork());
    eventsManager.addHandler(handler);

    MatsimEventsReader reader = new MatsimEventsReader(eventsManager);
    reader.readFile(outputDirectory + "/ITERS/it.10/10.events.xml.gz");

    return handler;
  }
 /**
  * @param args
  * @throws IOException
  */
 public static void main(String[] args) throws IOException {
   Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig());
   new MatsimNetworkReader(scenario.getNetwork())
       .parse("./data/MATSim-Sin-2.0/input/network/singapore7.xml");
   PublicTranportTeleportAnalizer publicTranportTeleportAnalizer =
       new PublicTranportTeleportAnalizer();
   EventsManager events = (EventsManager) EventsUtils.createEventsManager();
   events.addHandler(publicTranportTeleportAnalizer);
   new MatsimEventsReader(events)
       .readFile("./data/MATSim-Sin-2.0/output/ITERS/it.50/50.events.xml.gz");
   System.out.println("Events read");
   int numPersons = 0, numPersonsTeleported = 0, numPtStages = 0, numPtTeleportedStages = 0;
   Map<Id<Link>, Double> linkWeights = new HashMap<Id<Link>, Double>();
   Collection<Id<Link>> linkIds = new ArrayList<Id<Link>>();
   Collection<Double> startTimes = new ArrayList<Double>();
   Collection<Double> endTimes = new ArrayList<Double>();
   for (List<PTStage> stages : publicTranportTeleportAnalizer.publicTransportStages.values()) {
     numPersons++;
     boolean teleported = false;
     for (PTStage stage : stages) {
       numPtStages++;
       if (stage.teleported) {
         numPtTeleportedStages++;
         teleported = true;
         linkWeights.put(
             stage.linkId,
             (linkWeights.get(stage.linkId) == null ? 0 : linkWeights.get(stage.linkId)) + 1);
         linkIds.add(stage.linkId);
         startTimes.add(stage.beginInstant);
         endTimes.add(stage.beginTravelInstant);
       }
     }
     if (teleported) numPersonsTeleported++;
   }
   System.out.println(
       numPersons + ":" + numPersonsTeleported + " " + numPtStages + ":" + numPtTeleportedStages);
   VariableSizeSelectionNetworkPainter networkPainter =
       new VariableSizeSelectionNetworkPainter(scenario.getNetwork());
   networkPainter.setlinkWeights(linkWeights);
   JFrame window = new SimpleNetworkWindow("Links where people is waiting", networkPainter);
   window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   window.setVisible(true);
   /*DynamicVariableSizeSelectionNetworkPainter networkPainter2 = new DynamicVariableSizeSelectionNetworkPainter(scenario.getNetwork());
   networkPainter2.setlinkWeights(linkIds, startTimes, endTimes);
   JFrame window2 = new SimpleDynamicNetworkWindow("Links where people is waiting dynamic", networkPainter2);
   window2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   window2.setVisible(true);*/
 }
示例#26
0
  @Override
  public void endLegAndComputeNextState(double now) {
    // Post this event here.

    events.processEvent(new PersonArrivalEvent(now, id, currentLinkId, leg.getMode()));
    super.endLegAndComputeNextState(now);
  }
示例#27
0
  public void runEventReader(File eventFile) {

    this.eventHandler = null;
    EventsManager e = EventsUtils.createEventsManager();
    EventsReaderXMLv1 reader = new EventsReaderXMLv1(e);
    this.readerThread =
        new Thread(new EventReaderThread(reader, eventFile.toString()), "readerthread");
    this.eventHandler =
        new EventHandler(
            useCellCount,
            eventFile.getName(),
            this.controller.getScenario(),
            this.gridSize,
            this.readerThread);
    e.addHandler(this.eventHandler);
    this.readerThread.run();
  }
  public static void runEventsProcessing(Properties properties) {
    boolean isTransit = false;
    MutableScenario scenario =
        (MutableScenario)
            ScenarioUtils.createScenario(
                ConfigUtils.loadConfig(properties.get("configFile").toString()));
    scenario.getConfig().transit().setUseTransit(true);
    if (!properties.get("transitScheduleFile").toString().equals("")) {
      new TransitScheduleReader(scenario)
          .readFile(properties.get("transitScheduleFile").toString());
      isTransit = true;
    }
    new MatsimNetworkReader(scenario).readFile(properties.get("networkFile").toString());

    EventsManager eventsManager = EventsUtils.createEventsManager();
    EventsToTravelDiaries test;
    // if(linkTrafficComponent.isSelected()){
    // test = new EventsToPlanElements(
    // scenario.getTransitSchedule(), scenario.getNetwork(),
    // scenario.getConfig(),new File(postgresPropertiesComponent.getText())
    // ,tableSuffixComponent.getText());
    // }else{
    if (isTransit) {
      test =
          new EventsToTravelDiaries(
              scenario.getTransitSchedule(), scenario.getNetwork(), scenario.getConfig());

    } else {
      test = new EventsToTravelDiaries(scenario);
    }
    // }
    eventsManager.addHandler(test);
    new MatsimEventsReader(eventsManager).readFile(properties.get("eventsFile").toString());

    try {

      test.writeSimulationResultsToTabSeparated(
          properties.get("outputPath").toString(), properties.get("tableSuffix").toString());

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    System.out.println("Number of stuck vehicles/passengers: " + test.getStuck());
  }
示例#29
0
  public CongestionAnalysisHandler analyseScenario(String eventsFile, Scenario scenario) {

    BasicPersonTripAnalysisHandler basicHandler = new BasicPersonTripAnalysisHandler(scenario);
    CongestionAnalysisHandler congestionHandler = new CongestionAnalysisHandler(basicHandler);

    EventsManager events = EventsUtils.createEventsManager();
    events.addHandler(basicHandler);
    events.addHandler(congestionHandler);

    log.info("Reading the events file...");
    MatsimEventsReader reader = new MatsimEventsReader(events);
    reader.readFile(eventsFile);
    CongestionEventsReader congestionEventsReader = new CongestionEventsReader(events);
    congestionEventsReader.parse(eventsFile);
    log.info("Reading the events file... Done.");

    return congestionHandler;
  }
示例#30
0
 /**
  * @param args 0 - Transit schedule file 1 - Last iteration 2 - Iterations interval with events 3
  *     - Output folder 4 - Distance bins file 5 - Distribution result folder
  * @throws java.io.IOException
  */
 public static void main(String[] args) throws IOException {
   ScenarioImpl scenario = (ScenarioImpl) ScenarioUtils.createScenario(ConfigUtils.createConfig());
   scenario.getConfig().transit().setUseTransit(true);
   new TransitScheduleReader(scenario).readFile(args[0]);
   int lastIteration = new Integer(args[1]);
   int iterationsInterval = new Integer(args[2]);
   for (int i = 0; i <= lastIteration; i += iterationsInterval) {
     EventsManager eventsManager = EventsUtils.createEventsManager();
     TimeDistributionStage timeDistribution =
         new TimeDistributionStage(scenario.getTransitSchedule(), new HashSet<Id>());
     eventsManager.addHandler(timeDistribution);
     new MatsimEventsReader(eventsManager)
         .readFile(args[3] + "/ITERS/it." + i + "/" + i + ".events.xml.gz");
     timeDistribution.printDistribution(
         timeDistribution.getDistribution(
             args[4], new String[] {"car", "bus", "mrt", "lrt", "transit_walk", "walk", "other"}),
         args[5] + "/timeDistribution." + i + ".csv");
   }
 }