public static void main(String[] args) {

    MutableScenario scenario =
        (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig());
    MatsimReader populationReader = new PopulationReader(scenario);
    MatsimNetworkReader networkReader = new MatsimNetworkReader(scenario.getNetwork());
    networkReader.readFile(args[1]);
    populationReader.readFile(args[2]);

    ObjectAttributes bla = new ObjectAttributes();

    new ObjectAttributesXmlReader(bla).readFile(args[0]);

    for (Person p : scenario.getPopulation().getPersons().values()) {
      String act = "home";
      if (bla.getAttribute(p.getId().toString(), "earliestEndTime_leisure") != null)
        act = act + ",leisure";
      //	if (bla.getAttribute(p.getId().toString(), "earliestEndTime_work") != null)
      //		act = act + ",work";
      if (bla.getAttribute(p.getId().toString(), "earliestEndTime_shop") != null)
        act = act + ",shop";
      //	if (bla.getAttribute(p.getId().toString(), "earliestEndTime_education") != null)
      //		act = act + ",education";

      bla.putAttribute(p.getId().toString(), "activities", act);
    }

    ObjectAttributesXmlWriter betaWriter = new ObjectAttributesXmlWriter(bla);
    betaWriter.writeFile(args[3]);
  }
예제 #2
0
 // does not matter which distribution is chosen here
 private void assignKValuesPersons() {
   for (Person p : this.scenario.getPopulation().getPersons().values()) {
     this.personsKValues.putAttribute(p.getId().toString(), "k", rnd.getUniform(1.0));
   }
   // write person k values
   ObjectAttributesXmlWriter attributesWriter = new ObjectAttributesXmlWriter(this.personsKValues);
   attributesWriter.writeFile(config.controler().getOutputDirectory() + pkValuesFile);
 }
예제 #3
0
 private void assignKValuesAlternatives() {
   for (ActivityFacility facility :
       this.scenario.getActivityFacilities().getFacilities().values()) {
     this.facilitiesKValues.putAttribute(facility.getId().toString(), "k", rnd.getUniform(1.0));
   }
   ObjectAttributesXmlWriter attributesWriter =
       new ObjectAttributesXmlWriter(this.facilitiesKValues);
   attributesWriter.writeFile(config.controler().getOutputDirectory() + fkValuesFile);
 }
예제 #4
0
  /**
   * Writes the population and their attributes to file.
   *
   * @param outputfolder
   */
  public void writePopulation(String outputfolder) {
    if (this.sc.getPopulation().getPersons().size() == 0 || this.personAttributes == null) {
      throw new RuntimeException("Either no persons or person attributes to write.");
    } else {
      LOG.info("Writing population to file...");
      PopulationWriter pw = new PopulationWriter(this.sc.getPopulation(), this.sc.getNetwork());
      pw.writeV5(outputfolder + "Population.xml");

      LOG.info("Writing person attributes to file...");
      ObjectAttributesXmlWriter oaw = new ObjectAttributesXmlWriter(this.personAttributes);
      oaw.setPrettyPrint(true);
      oaw.writeFile(outputfolder + "PersonAttributes.xml");
    }
  }
예제 #5
0
  /**
   * Writes the households and their attributes to file.
   *
   * @param outputfolder
   */
  public void writeHouseholds(String outputfolder) {
    if (this.households == null || this.householdAttributes == null) {
      throw new RuntimeException("Either no households or household attributes to write.");
    } else {
      LOG.info("Writing households to file...");
      HouseholdsWriterV10 hw = new HouseholdsWriterV10(this.households);
      hw.setPrettyPrint(true);
      hw.writeFile(outputfolder + "Households.xml");

      LOG.info("Writing household attributes to file...");
      ObjectAttributesXmlWriter oaw = new ObjectAttributesXmlWriter(householdAttributes);
      oaw.setPrettyPrint(true);
      oaw.writeFile(outputfolder + "HouseholdAttributes.xml");
    }
  }