MATSIM
AStarLandmarksFactory.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * AStarLandmarksFactory
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2009 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 
26 import jakarta.inject.Inject;
27 import jakarta.inject.Singleton;
28 
36 
40 @Singleton
42 
43  private final Map<Network, PreProcessLandmarks> preProcessData = new HashMap<>();
44 
45  private final int nThreads;
46 
47  @Inject
48  public AStarLandmarksFactory(final GlobalConfigGroup globalConfigGroup) {
49  this(globalConfigGroup.getNumberOfThreads());
50  }
51 
52  public AStarLandmarksFactory(int numberOfThreads) {
53  this.nThreads = numberOfThreads;
54  }
55 
56  @Override
57  public synchronized LeastCostPathCalculator createPathCalculator(final Network network, final TravelDisutility travelCosts, final TravelTime travelTimes) {
58  PreProcessLandmarks preProcessLandmarks = this.preProcessData.get(network);
59  if (preProcessLandmarks == null) {
60  preProcessLandmarks = new PreProcessLandmarks(travelCosts);
61  preProcessLandmarks.setNumberOfThreads(nThreads);
62  preProcessLandmarks.run(network);
63  this.preProcessData.put(network, preProcessLandmarks);
64  }
65 
66  final double overdoFactor = 1.0;
67  return new AStarLandmarks(network, preProcessLandmarks, travelCosts, travelTimes, overdoFactor);
68  }
69 }
final Map< Network, PreProcessLandmarks > preProcessData
AStarLandmarksFactory(final GlobalConfigGroup globalConfigGroup)
synchronized LeastCostPathCalculator createPathCalculator(final Network network, final TravelDisutility travelCosts, final TravelTime travelTimes)