コード例 #1
0
ファイル: GRIPSAnalyzer.java プロジェクト: sebhoerl/matsim
 public static void main(String[] args) throws IOException {
   String events = "/Users/laemmel/devel/hhw_hybrid/output/ITERS/it.100/100.events.xml.gz";
   EventsManagerImpl m = new EventsManagerImpl();
   GRIPSAnalyzer handl = new GRIPSAnalyzer();
   m.addHandler(handl);
   new EventsReaderXMLv1(m).parse(events);
   BufferedWriter w =
       new BufferedWriter(new FileWriter(new File("/Users/laemmel/devel/hhw_hybrid/plots/ne")));
   System.out.println(handl);
   w.append(handl.toString());
   w.close();
 }
コード例 #2
0
 public void runJDEQSim(Scenario scenario) {
   EventsManagerImpl events = new EventsManagerImpl();
   events.addHandler(new PersonEventCollector());
   events.initProcessing();
   new JDEQSimulation(
           ConfigUtils.addOrGetModule(
               scenario.getConfig(), JDEQSimConfigGroup.NAME, JDEQSimConfigGroup.class),
           scenario,
           events)
       .run();
   events.finishProcessing();
 }
コード例 #3
0
ファイル: Debugger2.java プロジェクト: matsim-org/matsim
  public static void main(String[] args) {

    CTRunner.DEBUG = true;

    Config c = ConfigUtils.createConfig();

    c.global().setCoordinateSystem("EPSG:3395");
    Scenario sc = ScenarioUtils.createScenario(c);

    createNetwork(sc);
    EventsManagerImpl em = new EventsManagerImpl();

    if (CTRunner.DEBUG) {
      //			Sim2DConfig conf2d = Sim2DConfigUtils.createConfig();
      //			Sim2DScenario sc2d = Sim2DScenarioUtils.createSim2dScenario(conf2d);
      //
      //
      //			sc.addScenarioElement(Sim2DScenario.ELEMENT_NAME, sc2d);
      EventBasedVisDebuggerEngine dbg = new EventBasedVisDebuggerEngine(sc);
      InfoBox iBox = new InfoBox(dbg, sc);
      dbg.addAdditionalDrawer(iBox);
      //		dbg.addAdditionalDrawer(new Branding());
      QSimDensityDrawer qDbg = new QSimDensityDrawer(sc);
      dbg.addAdditionalDrawer(qDbg);

      em.addHandler(qDbg);
      em.addHandler(dbg);
    }

    CTNetwork net = new CTNetwork(sc.getNetwork(), em, null);
    double coeff = 0.05;
    int nrPeds = 0;
    {
      CTLink link = net.getLinks().get(Id.createLinkId("0"));
      List<Id<Link>> links = new ArrayList<>();
      links.add(Id.createLinkId(0));
      links.add(Id.createLinkId(1));
      links.add(Id.createLinkId(2));
      links.add(Id.createLinkId(3));
      for (CTCell cell : link.getCells()) {

        int n = cell.getN();
        int rnd =
            (int)
                (n
                    * coeff
                    * MatsimRandom.getRandom()
                        .nextDouble()); /// 4;//n/3;//(int)
                                        // (MatsimRandom.getRandom().nextInt(n)*.5);
        for (int i = 0; i < rnd; i++) {

          DriverAgent walker = new SimpleCTNetworkWalker(links, Id.createPersonId("r" + nrPeds++));

          CTPed ped = new CTPed(cell, walker);
          cell.jumpOnPed(ped, 0);
        }
        cell.updateIntendedCellJumpTimeAndChooseNextJumper(0);
      }
    }
    {
      CTLink link = net.getLinks().get(Id.createLinkId("1"));
      List<Id<Link>> links = new ArrayList<>();

      links.add(Id.createLinkId(1));
      links.add(Id.createLinkId(2));
      links.add(Id.createLinkId(3));
      links.add(Id.createLinkId(0));
      for (CTCell cell : link.getCells()) {

        int n = cell.getN();
        int rnd =
            (int)
                (n
                    * coeff
                    * MatsimRandom.getRandom()
                        .nextDouble()); /// 4;//n/3;//(int)
                                        // (MatsimRandom.getRandom().nextInt(n)*.5);
        for (int i = 0; i < rnd; i++) {

          DriverAgent walker = new SimpleCTNetworkWalker(links, Id.createPersonId("r" + nrPeds++));

          CTPed ped = new CTPed(cell, walker);
          cell.jumpOnPed(ped, 0);
        }
        cell.updateIntendedCellJumpTimeAndChooseNextJumper(0);
      }
    }
    {
      CTLink link = net.getLinks().get(Id.createLinkId("2"));
      List<Id<Link>> links = new ArrayList<>();

      links.add(Id.createLinkId(2));
      links.add(Id.createLinkId(3));
      links.add(Id.createLinkId(0));
      links.add(Id.createLinkId(1));
      for (CTCell cell : link.getCells()) {

        int n = cell.getN();
        int rnd =
            (int)
                (n
                    * coeff
                    * MatsimRandom.getRandom()
                        .nextDouble()); /// 4;//n/3;//(int)
                                        // (MatsimRandom.getRandom().nextInt(n)*.5);
        for (int i = 0; i < rnd; i++) {

          DriverAgent walker = new SimpleCTNetworkWalker(links, Id.createPersonId("r" + nrPeds++));

          CTPed ped = new CTPed(cell, walker);
          cell.jumpOnPed(ped, 0);
        }
        cell.updateIntendedCellJumpTimeAndChooseNextJumper(0);
      }
    }
    {
      CTLink link = net.getLinks().get(Id.createLinkId("3"));
      List<Id<Link>> links = new ArrayList<>();

      links.add(Id.createLinkId(3));
      links.add(Id.createLinkId(0));
      links.add(Id.createLinkId(1));
      links.add(Id.createLinkId(2));
      for (CTCell cell : link.getCells()) {

        int n = cell.getN();
        int rnd =
            (int)
                (n
                    * coeff
                    * MatsimRandom.getRandom()
                        .nextDouble()); /// 4;//n/3;//(int)
                                        // (MatsimRandom.getRandom().nextInt(n)*.5);
        for (int i = 0; i < rnd; i++) {

          DriverAgent walker = new SimpleCTNetworkWalker(links, Id.createPersonId("r" + nrPeds++));

          CTPed ped = new CTPed(cell, walker);
          cell.jumpOnPed(ped, 0);
        }
        cell.updateIntendedCellJumpTimeAndChooseNextJumper(0);
      }
    }
    {
      CTLink link = net.getLinks().get(Id.createLinkId("4"));
      List<Id<Link>> links = new ArrayList<>();

      links.add(Id.createLinkId(4));
      links.add(Id.createLinkId(7));
      links.add(Id.createLinkId(6));
      links.add(Id.createLinkId(5));
      for (CTCell cell : link.getCells()) {
        int n = cell.getN();
        int rnd =
            (int)
                (n
                    * coeff
                    * MatsimRandom.getRandom()
                        .nextDouble()); /// 4;//n/3;//(int)
                                        // (MatsimRandom.getRandom().nextInt(n)*.5);
        for (int i = 0; i < rnd; i++) {

          DriverAgent walker = new SimpleCTNetworkWalker(links, Id.createPersonId("b" + nrPeds++));

          CTPed ped = new CTPed(cell, walker);
          cell.jumpOnPed(ped, 0);
        }
        cell.updateIntendedCellJumpTimeAndChooseNextJumper(0);
      }
    }
    {
      CTLink link = net.getLinks().get(Id.createLinkId("5"));
      List<Id<Link>> links = new ArrayList<>();

      links.add(Id.createLinkId(5));
      links.add(Id.createLinkId(4));
      links.add(Id.createLinkId(7));
      links.add(Id.createLinkId(6));
      for (CTCell cell : link.getCells()) {
        int n = cell.getN();
        int rnd =
            (int)
                (n
                    * coeff
                    * MatsimRandom.getRandom()
                        .nextDouble()); /// 4;//n/3;//(int)
                                        // (MatsimRandom.getRandom().nextInt(n)*.5);
        for (int i = 0; i < rnd; i++) {

          DriverAgent walker = new SimpleCTNetworkWalker(links, Id.createPersonId("b" + nrPeds++));

          CTPed ped = new CTPed(cell, walker);
          cell.jumpOnPed(ped, 0);
        }
        cell.updateIntendedCellJumpTimeAndChooseNextJumper(0);
      }
    }
    {
      CTLink link = net.getLinks().get(Id.createLinkId("6"));
      List<Id<Link>> links = new ArrayList<>();
      links.add(Id.createLinkId(6));
      links.add(Id.createLinkId(5));
      links.add(Id.createLinkId(4));
      links.add(Id.createLinkId(7));
      for (CTCell cell : link.getCells()) {
        int n = cell.getN();
        int rnd =
            (int)
                (n
                    * coeff
                    * MatsimRandom.getRandom()
                        .nextDouble()); /// 4;//n/3;//(int)
                                        // (MatsimRandom.getRandom().nextInt(n)*.5);
        for (int i = 0; i < rnd; i++) {

          DriverAgent walker = new SimpleCTNetworkWalker(links, Id.createPersonId("b" + nrPeds++));

          CTPed ped = new CTPed(cell, walker);
          cell.jumpOnPed(ped, 0);
        }
        cell.updateIntendedCellJumpTimeAndChooseNextJumper(0);
      }
    }
    {
      CTLink link = net.getLinks().get(Id.createLinkId("7"));
      List<Id<Link>> links = new ArrayList<>();
      links.add(Id.createLinkId(7));
      links.add(Id.createLinkId(6));
      links.add(Id.createLinkId(5));
      links.add(Id.createLinkId(4));
      for (CTCell cell : link.getCells()) {
        int n = cell.getN();
        int rnd =
            (int)
                (n
                    * coeff
                    * MatsimRandom.getRandom()
                        .nextDouble()); /// 4;//n/3;//(int)
                                        // (MatsimRandom.getRandom().nextInt(n)*.5);
        for (int i = 0; i < rnd; i++) {

          DriverAgent walker = new SimpleCTNetworkWalker(links, Id.createPersonId("b" + nrPeds++));

          CTPed ped = new CTPed(cell, walker);
          cell.jumpOnPed(ped, 0);
        }
        cell.updateIntendedCellJumpTimeAndChooseNextJumper(0);
      }
    }
    System.out.println(nrPeds);
    long start = System.nanoTime();
    net.run();
    long stop = System.nanoTime();
    System.out.println("sim took:" + ((stop - start) / 1000. / 1000.) + " ms");
    //		LineSegment ls = new LineSegment();
    //		ls.x0 = 0;
    //		ls.x1 = 0;
    //		ls.y1 = 0;
    //		ls.x1 = -10;
    //		LineEvent le = new LineEvent(0,ls,true,0,128,128,255,0);
    //		em.processEvent(le);

  }