MATSIM
Main Page
Related Pages
Packages
Classes
Files
File List
tutorial
programming
ownMobsim
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
;
25
import
org
.
matsim
.
api
.
core
.
v01
.
events
.
LinkLeaveEvent
;
26
import
org
.
matsim
.
api
.
core
.
v01
.
network
.
Link
;
27
import
org
.
matsim
.
api
.
core
.
v01
.
network
.
Node
;
28
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
Person
;
29
import
org
.
matsim
.
core
.
api
.
experimental
.
events
.
EventsManager
;
30
import
org
.
matsim
.
core
.
mobsim
.
framework
.
Mobsim
;
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
}
org.matsim.api.core.v01.network
Definition:
Link.java:20
org.matsim.core.mobsim.framework
Definition:
AgentSource.java:20
org.matsim.api.core.v01.population
Definition:
Activity.java:21
org.matsim.core.mobsim.framework.Mobsim
Definition:
Mobsim.java:30
org
org.matsim.core.mobsim
Definition:
DefaultMobsimModule.java:23
org.matsim.api
org.matsim.vehicles.Vehicle
Definition:
Vehicle.java:27
org.matsim.core.api.experimental.events.EventsManager.processEvent
void processEvent(final Event event)
org.matsim.core
org.matsim.api.core.v01.Scenario
Definition:
Scenario.java:76
org.matsim.vehicles
Definition:
EngineInformation.java:20
org.matsim.api.core
org.matsim.api.core.v01.events.LinkLeaveEvent
Definition:
LinkLeaveEvent.java:30
org.matsim.core.api.experimental.events
Definition:
AgentWaitingForPtEvent.java:20
org.matsim.core.api.experimental.events.EventsManager
Definition:
EventsManager.java:30
org.matsim.core.api.experimental
org.matsim.api.core.v01.events
Definition:
ActivityEndEvent.java:21
org.matsim.core.api
org.matsim
org.matsim.api.core.v01.network.Link
Definition:
Link.java:34
org.matsim.api.core.v01.population.Person
Definition:
Person.java:28
org.matsim.api.core.v01
Definition:
BasicLocation.java:20
org.matsim.api.core.v01.network.Node
Definition:
Node.java:39
Generated on Sat Oct 22 2016 11:22:52 for MATSIM by
1.8.8