예제 #1
0
  @Override
  public void notifyBeforeMobsim(final BeforeMobsimEvent event) {
    if ((writePlansInterval > 0)
        && ((event.getIteration() % writePlansInterval == 0)
            || (event.getIteration() == (firstIteration + 1)))) {
      stopwatch.beginOperation("dump all plans");
      log.info("dumping plans...");
      final String inputCRS = config.plans().getInputCRS();
      final String internalCRS = config.global().getCoordinateSystem();

      if (inputCRS == null) {
        new PopulationWriter(population, network)
            .write(controlerIO.getIterationFilename(event.getIteration(), "plans.xml.gz"));
      } else {
        log.info(
            "re-projecting population from " + internalCRS + " to " + inputCRS + " for export");

        final CoordinateTransformation transformation =
            TransformationFactory.getCoordinateTransformation(internalCRS, inputCRS);

        new PopulationWriter(transformation, population, network)
            .write(controlerIO.getIterationFilename(event.getIteration(), "plans.xml.gz"));
      }
      log.info("finished plans dump.");
      stopwatch.endOperation("dump all plans");
    }
  }
 public void writeStats(final int iter) {
   try {
     write(io.getIterationFilename(iter, "weightsForDrivers.dat.gz"), weightsForDrivers);
     write(io.getIterationFilename(iter, "weightsForPassengers.dat.gz"), weightsForPassengers);
   } catch (IOException e) {
     throw new UncheckedIOException(e);
   }
 }
예제 #3
0
  @Override
  public void notifyAfterMobsim(AfterMobsimEvent event) {
    if (!trackIteration) return;

    try {
      DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();

      Document document = documentBuilder.newDocument();
      Element schedules = document.createElement("services");
      document.appendChild(schedules);

      for (Service service : services) {
        schedules.appendChild(buildXmlService(document, service));
      }

      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      Transformer transformer = transformerFactory.newTransformer();
      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
      transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

      DOMSource source = new DOMSource(document);

      this.openFile(controlerIO.getIterationFilename(event.getIteration(), "av_services.xml.gz"));
      StreamResult result = new StreamResult(this.writer);

      transformer.transform(source, result);
    } catch (ParserConfigurationException
        | TransformerFactoryConfigurationError
        | TransformerException e) {
      throw new RuntimeException("Error while dumping AV schedules");
    } finally {
      this.close();
    }
  }
예제 #4
0
 private void dumpJointPlans() {
   JointPlansXmlWriter.write(
       scenario.getPopulation(),
       jointPlans,
       controlerIO.getOutputFilename("output_jointPlans.xml.gz"));
 }