public static void main(String[] args) throws IOException {
    List<Setting> settings = new ArrayList<>();
    for (double w = 2.9; w < 3; w += 0.05) {
      settings.add(new Setting(w, 3, 3, 500, 0, w, w));
    }
    for (double w = .4; w < 3; w += 0.2) {
      settings.add(new Setting(3, 3, w, 500, 0, w, w));
    }
    for (double w = 0.8; w <= 3; w += 0.2) {
      settings.add(new Setting(w, 3, 3, 500, 0, w, w));
    }

    AbstractCANetwork.EMIT_VIS_EVENTS = false;
    USE_SPH = true;
    for (int R = 12; R <= 12; R++) {
      CASingleLaneDensityEstimatorSPH.H = R;
      CAMultiLaneDensityEstimatorSPH.H = R;
      CASingleLaneDensityEstimatorSPA.RANGE = R;
      CASingleLaneDensityEstimatorSPHII.H = R;
      CASingleLaneDensityEstimatorSPAII.RANGE = R;
      try {
        bw =
            new BufferedWriter(
                new FileWriter(new File("/Users/laemmel/devel/bipedca/ant/uni" + R)));
      } catch (IOException e) {
        e.printStackTrace();
      }

      for (Setting s : settings) {
        System.out.println(s);
        Config c = ConfigUtils.createConfig();
        c.global().setCoordinateSystem("EPSG:3395");
        Scenario sc = ScenarioUtils.createScenario(c);

        // VIS only
        Sim2DConfig conf2d = Sim2DConfigUtils.createConfig();
        Sim2DScenario sc2d = Sim2DScenarioUtils.createSim2dScenario(conf2d);
        sc.addScenarioElement(Sim2DScenario.ELEMENT_NAME, sc2d);

        Network net = sc.getNetwork();
        ((NetworkImpl) net).setCapacityPeriod(1);
        NetworkFactory fac = net.getFactory();

        int l = 8;
        int res = 20;
        Node n0 = fac.createNode(Id.createNodeId("0"), new CoordImpl(20 - res, 0));
        Node n1 = fac.createNode(Id.createNodeId("1"), new CoordImpl(20, 0));
        Node n2 = fac.createNode(Id.createNodeId("2"), new CoordImpl(24, 0));
        Node n2ex = fac.createNode(Id.createNodeId("2ex"), new CoordImpl(24, 20));
        Node n3 = fac.createNode(Id.createNodeId("3"), new CoordImpl(24 + l, 0));
        Node n3ex = fac.createNode(Id.createNodeId("3ex"), new CoordImpl(24 + l, -20));
        Node n4 = fac.createNode(Id.createNodeId("4"), new CoordImpl(24 + 4 + l, 0));
        Node n5 = fac.createNode(Id.createNodeId("5"), new CoordImpl(24 + 4 + res + l, 0));
        net.addNode(n5);
        net.addNode(n4);
        net.addNode(n3ex);
        net.addNode(n3);
        net.addNode(n2ex);
        net.addNode(n2);
        net.addNode(n1);
        net.addNode(n0);

        Link l0 = fac.createLink(Id.createLinkId("0"), n0, n1);
        Link l0rev = fac.createLink(Id.createLinkId("0rev"), n1, n0);
        Link l1 = fac.createLink(Id.createLinkId("1"), n1, n2);
        Link l1rev = fac.createLink(Id.createLinkId("1rev"), n2, n1);
        Link l2 = fac.createLink(Id.createLinkId("2"), n2, n3);
        Link l2rev = fac.createLink(Id.createLinkId("2rev"), n3, n2);
        Link l2ex = fac.createLink(Id.createLinkId("2ex"), n2, n2ex);
        Link l3 = fac.createLink(Id.createLinkId("3"), n3, n4);
        Link l3ex = fac.createLink(Id.createLinkId("3ex"), n3, n3ex);
        Link l3rev = fac.createLink(Id.createLinkId("3rev"), n4, n3);
        Link l4 = fac.createLink(Id.createLinkId("4"), n4, n5);
        Link l4rev = fac.createLink(Id.createLinkId("4rev"), n5, n4);

        l0.setLength(res);
        l1.setLength(4);

        l0rev.setLength(res);
        l1rev.setLength(4);

        l2rev.setLength(l);
        l2.setLength(l);

        l3rev.setLength(4);
        l3.setLength(4);
        l4rev.setLength(res);
        l4.setLength(res);
        l3ex.setLength(20);
        l2ex.setLength(20);

        net.addLink(l4);
        net.addLink(l4rev);
        net.addLink(l1);
        net.addLink(l0);
        net.addLink(l2);
        net.addLink(l2rev);
        net.addLink(l1rev);
        net.addLink(l0rev);
        net.addLink(l3rev);
        net.addLink(l3);
        net.addLink(l3ex);
        net.addLink(l2ex);

        double bl = s.bL;
        double bc = s.bCor;
        double br = s.bR;
        double bexR = s.bexR;
        double bexL = s.bexL;

        l0.setCapacity(5);
        l0rev.setCapacity(5);
        l1.setCapacity(bl);
        l1rev.setCapacity(bl);
        l2.setCapacity(bc);
        l2rev.setCapacity(bc);
        l3.setCapacity(br);
        l3rev.setCapacity(br);
        l4.setCapacity(5);
        l4rev.setCapacity(5);
        l3ex.setCapacity(bexR);
        l2ex.setCapacity(bexL);

        List<Link> linksLR = new ArrayList<Link>();
        linksLR.add(l0);
        linksLR.add(l1);
        linksLR.add(l2);
        linksLR.add(l3ex);
        List<Link> linksRL = new ArrayList<Link>();
        linksRL.add(l4rev);
        linksRL.add(l3rev);
        linksRL.add(l2rev);
        linksRL.add(l2ex);

        for (int i = 0; i < 1; i++) {
          for (double th = 1; th <= 1; th += 0.15) {
            runIt(net, linksLR, linksRL, sc, th, s);
          }
          // for (double th = .26; th <= .4; th += 0.01) {
          // runIt(net, linksLR, sc, th);
          // }
          // for (double th = .45; th < .5; th += 0.05) {
          // runIt(net, linksLR, sc, th);
          // }
          // for (double th = .5; th <= 1.; th += 0.1) {
          // runIt(net, linksLR, sc, th);
          // }
        }
      }
      bw.close();
    }
  }
예제 #2
0
 @Override
 public void addScenarioElement(String name, Object o) {
   delegate.addScenarioElement(name, o);
 }