MATSIM
Main Page
Related Pages
Packages
Classes
Files
File List
tutorial
programming
ownMobsimAgentUsingRouter
MyGuidance.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.ownMobsimAgentUsingRouter;
20
21
import
org
.
matsim
.
api
.
core
.
v01
.Id;
22
import
org
.
matsim
.
api
.
core
.
v01
.
Scenario
;
23
import
org
.
matsim
.
api
.
core
.
v01
.
TransportMode
;
24
import
org
.
matsim
.
api
.
core
.
v01
.
network
.
Link
;
25
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
Leg
;
26
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
Person
;
27
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
PlanElement
;
28
import
org
.
matsim
.
core
.
population
.
routes
.
NetworkRoute
;
29
import
org
.
matsim
.
core
.
router
.
LinkWrapperFacility
;
30
import
org
.
matsim
.
core
.
router
.
TripRouter
;
31
import
org
.
matsim
.
facilities
.
ActivityFacility
;
32
import
org
.
matsim
.
facilities
.Facility;
33
34
import
java.util.List;
35
39
class
MyGuidance {
40
41
private
final
TripRouter
router;
42
private
final
Scenario
scenario;
43
44
MyGuidance(
TripRouter
router,
Scenario
scenario) {
45
this.router = router;
46
this.scenario = scenario;
47
}
48
49
public
Id<Link> getBestOutgoingLink(Id<Link> linkId, Id<Link> destinationLinkId,
double
now) {
50
Person
person = null;
// does this work?
51
double
departureTime = now;
52
String mainMode =
TransportMode
.
car
;
53
Facility<ActivityFacility> fromFacility =
new
LinkWrapperFacility
(this.scenario.
getNetwork
().
getLinks
().get(linkId));
54
Facility<ActivityFacility> toFacility =
new
LinkWrapperFacility
(this.scenario.
getNetwork
().
getLinks
().get(destinationLinkId));
55
List<? extends PlanElement> trip = router.
calcRoute
(mainMode, fromFacility, toFacility, departureTime, person);
56
57
Leg
leg = (
Leg
) trip.get(0);
// test: either plan element 0 or 1 will be a car leg
58
59
NetworkRoute
route = (
NetworkRoute
) leg.
getRoute
();
60
61
return
route.
getLinkIds
().get(0);
// entry number 0 should be link connected to next intersection (?)
62
}
63
64
}
org.matsim.facilities.ActivityFacility
Definition:
ActivityFacility.java:27
org.matsim.api.core.v01.network
Definition:
Link.java:20
org.matsim.core.population.routes
Definition:
AbstractRoute.java:21
org.matsim.core.population.routes.NetworkRoute
Definition:
NetworkRoute.java:37
org.matsim.core.router.TripRouter.calcRoute
List<?extends PlanElement > calcRoute(final String mainMode, final Facility fromFacility, final Facility toFacility, final double departureTime, final Person person)
Definition:
TripRouter.java:166
org.matsim.api.core.v01.population
Definition:
Activity.java:21
org.matsim.facilities
Definition:
ActivityFacilities.java:20
org.matsim.api.core.v01.TransportMode.car
static final String car
Definition:
TransportMode.java:33
org
org.matsim.api.core.v01.population.Leg.getRoute
Route getRoute()
org.matsim.core.population
Definition:
ActivityImpl.java:21
org.matsim.api.core.v01.population.PlanElement
Definition:
PlanElement.java:26
org.matsim.api
org.matsim.core.router.TripRouter
Definition:
TripRouter.java:57
org.matsim.core.population.routes.NetworkRoute.getLinkIds
List< Id< Link > > getLinkIds()
org.matsim.core
org.matsim.core.router
Definition:
AbstractFastRouterDelegate.java:21
org.matsim.api.core.v01.TransportMode
Definition:
TransportMode.java:31
org.matsim.api.core.v01.Scenario
Definition:
Scenario.java:76
org.matsim.api.core
org.matsim.api.core.v01.network.Network.getLinks
Map< Id< Link >,?extends Link > getLinks()
org.matsim.api.core.v01.population.Leg
Definition:
Leg.java:24
org.matsim.core.router.LinkWrapperFacility
Definition:
LinkWrapperFacility.java:14
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.Scenario.getNetwork
Network getNetwork()
org.matsim.api.core.v01
Definition:
BasicLocation.java:20
Generated on Sat Oct 22 2016 11:22:52 for MATSIM by
1.8.8