MATSIM
MyMobsim.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.* *
3  * *
4  * *********************************************************************** *
5  * *
6  * copyright : (C) 2008 by the members listed in the COPYING, *
7  * LICENSE and WARRANTY file. *
8  * email : info at matsim dot org *
9  * *
10  * *********************************************************************** *
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * See also COPYING, LICENSE and WARRANTY file *
17  * *
18  * *********************************************************************** */
19 package tutorial.programming.ownMobsim;
20 
21 import javax.inject.Inject;
22 
23 import org.matsim.api.core.v01.Id;
24 import org.matsim.api.core.v01.Scenario;
31 import org.matsim.vehicles.Vehicle;
32 
37 final class MyMobsim implements Mobsim {
38  @Inject Scenario scenario ;
39  @Inject EventsManager events ;
40 
41  @Override
42  public void run() {
43  for ( Node node : scenario.getNetwork().getNodes().values() ) {
44  // construct mobsim node from data input
45  }
46  for ( Link link : scenario.getNetwork().getLinks().values() ) {
47  // construct mobsim link from data input
48  }
49  for ( Person person : scenario.getPopulation().getPersons().values() ) {
50  // construct mobsim agents from data input
51  }
52 
53  // then run the mobsim. time-stepped is one way; obviously there are others
54  for ( long time = 0 ; time <= 36*3600 ; time++ ) {
55 
56  // ...
57 
58  // events are pushed into the events manager:
59  Id<Link> linkId = null;
60  Id<Vehicle> vehicleId = null;
61  events.processEvent(new LinkLeaveEvent(time, vehicleId, linkId));
62 
63  // ...
64  }
65 
66  }
67 
68 }