Case 1: Initial demand generation

The short story

Start with something like

Config config = ConfigUtils.createConfig();
Scenario sc = ScenarioUtils.createScenario(config);

From there on, you can use command completion on sc and anything else that you have found in order to find out about additional commands.

At the end, you write to file by

MatsimWriter popWriter = new org.matsim.api.core.v01.population.PopulationWriter(population) ;
popWriter.write( filename ) 

The slightly longer story

Config config = ConfigUtils.createConfig();
Scenario sc = ScenarioUtils.createScenario(config);

Network network = sc.getNetwork();
Population population = sc.getPopulation();

PopulationFactory populationFactory = population.getFactory(); // (*)

Person person = populationFactory.createPerson(sc.createId("someId"));
population.addPerson(person) ;

Plan plan = populationFactory.createPlan();
// do something with the plan, fill it with Activities and Legs.
person.addPlan(plan);


MatsimWriter popWriter = new org.matsim.api.core.v01.population.PopulationWriter(population, network);
popWriter.write(filename);

It is important to note the (*) syntax, i.e. the creational methods are in the factory.

 

The long story

An example is under src/tutorial/programming/example8DemandGeneration.  This should also be used to obtain hints with respect to the correct syntax ... since it is automatically part of all refactorings.


Warning: Table 'watchdog' is read only query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', '<em>Table &amp;#039;sessions&amp;#039; is read only\nquery: UPDATE sessions SET uid = 0, cache = 0, hostname = &amp;#039;38.107.179.230&amp;#039;, session = &amp;#039;&amp;#039;, timestamp = 1328355256 WHERE sid = &amp;#039;e972b2ab7dd755a2094beea8ac708f02&amp;#039;</em> in <em>/home01/vsp_access/matsimwww/includes/database.mysql.inc</em> on line <em>174</em>.', 2, '', 'http://matsim.org/node/340', '', '38.107.179.230', 1328355256) in /home01/vsp_access/matsimwww/includes/database.mysql.inc on line 174