MATSIM
MultiNodeDijkstraFactory.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * MultiNodeDijkstraFactory.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2013 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 
21 package org.matsim.core.router;
22 
23 import java.util.HashMap;
24 import java.util.Map;
25 
32 
34 
35  private final boolean searchAllEndNodes;
36  private final boolean usePreProcessData;
37  private final Map<Network, PreProcessDijkstra> preProcessData = new HashMap<>();
38 
40  this.searchAllEndNodes = false;
41  this.usePreProcessData = false;
42  }
43 
44  public MultiNodeDijkstraFactory(final boolean searchAllEndNodes) {
45  this.searchAllEndNodes = searchAllEndNodes;
46  this.usePreProcessData = false;
47  }
48 
49  public MultiNodeDijkstraFactory(final boolean usePreProcessData, final boolean searchAllEndNodes) {
50  this.usePreProcessData = usePreProcessData;
51  this.searchAllEndNodes = searchAllEndNodes;
52  }
53 
54  @Override
55  public synchronized LeastCostPathCalculator createPathCalculator(final Network network, final TravelDisutility travelCosts, final TravelTime travelTimes) {
56  if (this.usePreProcessData) {
57  PreProcessDijkstra preProcessDijkstra = this.preProcessData.get(network);
58  if (preProcessDijkstra == null) {
59  preProcessDijkstra = new PreProcessDijkstra();
60  preProcessDijkstra.run(network);
61  this.preProcessData.put(network, preProcessDijkstra);
62  }
63  return new MultiNodeDijkstra(network, travelCosts, travelTimes, preProcessDijkstra, this.searchAllEndNodes);
64  }
65 
66  return new MultiNodeDijkstra(network, travelCosts, travelTimes, this.searchAllEndNodes);
67  }
68 }
final Map< Network, PreProcessDijkstra > preProcessData
synchronized LeastCostPathCalculator createPathCalculator(final Network network, final TravelDisutility travelCosts, final TravelTime travelTimes)
MultiNodeDijkstraFactory(final boolean usePreProcessData, final boolean searchAllEndNodes)