21 package org.matsim.utils.leastcostpathtree;
23 import java.util.Comparator;
25 import java.util.PriorityQueue;
60 private double dTime = Double.NaN;
79 this.origin1 = origin;
86 this.nodeData.
put(origin.
getId(), d);
88 ComparatorCost comparator =
new ComparatorCost(this.nodeData);
89 PriorityQueue<Node> pendingNodes =
new PriorityQueue<>(500, comparator);
91 while (!pendingNodes.isEmpty()) {
92 Node n = pendingNodes.poll();
103 private double cost = Double.MAX_VALUE;
106 void visit(
final Id<Node> comingFromNodeId,
final double cost1,
final double time1) {
107 this.prevId = comingFromNodeId;
125 static class ComparatorCost
implements Comparator<Node> {
133 public int compare(
final Node n1,
final Node n2) {
173 double currTime = nData.
getTime();
174 double currCost = nData.
getCost();
176 Node nn = l.getToNode();
178 if (nnData == null) {
180 this.nodeData.
put(nn.
getId(), nnData);
183 double visitTime = currTime + ttFunction.
getLinkTravelTime(l, currTime, PERSON, VEHICLE);
186 if (visitCost < nnData.
getCost()) {
187 pendingNodes.remove(nn);
188 nnData.visit(n.
getId(), visitCost, visitTime);
190 pendingNodes.add(nn);
203 public static void main(String[] args) {
211 st.calculate(network, origin, 8*3600);
219 System.out.println(
id +
"\t" + d.
getTime() +
"\t" + d.
getCost() +
"\t" +
"0");
Map< Id< Node >, ? extends Node > getNodes()
Set< Map.Entry< Id< T >, V > > entrySet()
static void main(String[] args)
final TravelTime ttFunction
double getLinkTravelTime(Link link, double time, Person person, Vehicle vehicle)
final double getDepartureTime()
static< T > Id< T > create(final long key, final Class< T > type)
final TravelDisutility tcFunction
TravelTimeCalculatorConfigGroup travelTimeCalculator()
double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle vehicle)
IdMap< Node, NodeData > nodeData
Person createPerson(Id< Person > id)
Id< Node > getPrevNodeId()
LeastCostPathTree(TravelTime tt, TravelDisutility tc)
static VehicleType createDefaultVehicleType()
void relaxNode(final Node n, PriorityQueue< Node > pendingNodes)
TravelTime getLinkTravelTimes()
Vehicle createVehicle(Id< Vehicle > id, VehicleType type)
void additionalComputationsHook(Link link, double currTime)
final Network getNetwork()
final IdMap< Node, NodeData > getTree()
V put(Id< T > key, V value)
Map< Id< Link >, ? extends Link > getOutLinks()
static Scenario createScenario(final Config config)
static PopulationFactory getFactory()
void calculate(final Network network, final Node origin, final double time)
static VehiclesFactory getFactory()
static Config createConfig(final String context)