Skip to content

Commit

Permalink
Makes use of config objects.
Browse files Browse the repository at this point in the history
Signed-off-by: ammagamma <contactammagamma@gmail.com>
  • Loading branch information
easbar committed May 17, 2018
1 parent 21b7870 commit b28e760
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 61 deletions.
Expand Up @@ -60,7 +60,7 @@ public class CHAlgoFactoryDecorator implements RoutingAlgorithmFactoryDecorator
private int preparationNeighborUpdates = -1; private int preparationNeighborUpdates = -1;
private int preparationContractedNodes = -1; private int preparationContractedNodes = -1;
private double preparationLogMessages = -1; private double preparationLogMessages = -1;
private PMap options = new PMap(); private PrepareContractionHierarchies.Config chConfig = new PrepareContractionHierarchies.Config();


public CHAlgoFactoryDecorator() { public CHAlgoFactoryDecorator() {
setPreparationThreads(1); setPreparationThreads(1);
Expand Down Expand Up @@ -145,10 +145,6 @@ public CHAlgoFactoryDecorator setPreparationNeighborUpdates(int prepareNeighborU
return this; return this;
} }


public void setOptions(PMap options) {
this.options = options;
}

@Override @Override
public final boolean isEnabled() { public final boolean isEnabled() {
return enabled; return enabled;
Expand Down Expand Up @@ -323,7 +319,7 @@ public void createPreparations(GraphHopperStorage ghStorage, TraversalMode trave
for (Weighting weighting : getWeightings()) { for (Weighting weighting : getWeightings()) {
PrepareContractionHierarchies tmpPrepareCH = new PrepareContractionHierarchies( PrepareContractionHierarchies tmpPrepareCH = new PrepareContractionHierarchies(
new GHDirectory("", DAType.RAM_INT), ghStorage, ghStorage.getGraph(CHGraph.class, weighting), new GHDirectory("", DAType.RAM_INT), ghStorage, ghStorage.getGraph(CHGraph.class, weighting),
weighting, traversalMode, options); weighting, traversalMode, chConfig);
tmpPrepareCH.setPeriodicUpdates(preparationPeriodicUpdates). tmpPrepareCH.setPeriodicUpdates(preparationPeriodicUpdates).
setLazyUpdates(preparationLazyUpdates). setLazyUpdates(preparationLazyUpdates).
setNeighborUpdates(preparationNeighborUpdates). setNeighborUpdates(preparationNeighborUpdates).
Expand Down
Expand Up @@ -39,20 +39,15 @@
public class EdgeBasedNodeContractor extends AbstractNodeContractor { public class EdgeBasedNodeContractor extends AbstractNodeContractor {
// todo: modify code such that logging does not alter performance // todo: modify code such that logging does not alter performance
private static final Logger LOGGER = LoggerFactory.getLogger(EdgeBasedNodeContractor.class); private static final Logger LOGGER = LoggerFactory.getLogger(EdgeBasedNodeContractor.class);
// public static SearchType searchType = SearchType.LEGACY_AGGRESSIVE;
public static SearchType searchType = SearchType.AGGRESSIVE;
public static boolean arrayBasedWitnessPathFinder = true;
public static float edgeQuotientWeight = 1;
public static float originalEdgeQuotientWeight = 3;
public static float hierarchyDepthWeight = 2;
private final TurnWeighting turnWeighting; private final TurnWeighting turnWeighting;
private final SimpleSearch simpleSearch = new SimpleSearch(); private final SimpleSearch simpleSearch = new SimpleSearch();
private final ShortcutHandler addingShortcutHandler = new AddingShortcutHandler(); private final ShortcutHandler addingShortcutHandler = new AddingShortcutHandler();
private final ShortcutHandler countingShortcutHandler = new CountingShortcutHandler(); private final ShortcutHandler countingShortcutHandler = new CountingShortcutHandler();
private ShortcutHandler activeShortcutHandler;
private final Config config;
private final StopWatch dijkstraSW = new StopWatch(); private final StopWatch dijkstraSW = new StopWatch();
private int dijkstraCount; private int dijkstraCount;
private int addedShortcutsCount; private int addedShortcutsCount;
private ShortcutHandler activeShortcutHandler;
private int[] hierarchyDepths; private int[] hierarchyDepths;
private LegacyWitnessPathFinder legacyWitnessPathFinder; private LegacyWitnessPathFinder legacyWitnessPathFinder;
private WitnessPathSearcher witnessPathSearcher; private WitnessPathSearcher witnessPathSearcher;
Expand All @@ -78,20 +73,20 @@ public class EdgeBasedNodeContractor extends AbstractNodeContractor {
private int numSearches; private int numSearches;


public EdgeBasedNodeContractor(Directory dir, GraphHopperStorage ghStorage, CHGraph prepareGraph, public EdgeBasedNodeContractor(Directory dir, GraphHopperStorage ghStorage, CHGraph prepareGraph,
TurnWeighting turnWeighting, PMap options) { TurnWeighting turnWeighting, Config config) {
super(dir, ghStorage, prepareGraph, turnWeighting); super(dir, ghStorage, prepareGraph, turnWeighting);
this.turnWeighting = turnWeighting; this.turnWeighting = turnWeighting;
this.encoder = turnWeighting.getFlagEncoder(); this.encoder = turnWeighting.getFlagEncoder();
this.witnessSearchStrategy = new TurnReplacementSearch(); this.witnessSearchStrategy = new TurnReplacementSearch();
this.config = config;
} }


@Override @Override
public void initFromGraph() { public void initFromGraph() {
super.initFromGraph(); super.initFromGraph();
int maxLevel = prepareGraph.getNodes(); int maxLevel = prepareGraph.getNodes();
legacyWitnessPathFinder = arrayBasedWitnessPathFinder ? legacyWitnessPathFinder =
new ArrayBasedLegacyWitnessPathFinder(prepareGraph, turnWeighting, TraversalMode.EDGE_BASED_2DIR, maxLevel) : new ArrayBasedLegacyWitnessPathFinder(prepareGraph, turnWeighting, TraversalMode.EDGE_BASED_2DIR, maxLevel);
new MapBasedLegacyWitnessPathFinder(prepareGraph, turnWeighting, TraversalMode.EDGE_BASED_2DIR, maxLevel);
WitnessPathSearcher.Config config = new WitnessPathSearcher.Config(); WitnessPathSearcher.Config config = new WitnessPathSearcher.Config();
witnessPathSearcher = new WitnessPathSearcher(ghStorage, prepareGraph, turnWeighting, config); witnessPathSearcher = new WitnessPathSearcher(ghStorage, prepareGraph, turnWeighting, config);
DefaultEdgeFilter inEdgeFilter = new DefaultEdgeFilter(encoder, true, false); DefaultEdgeFilter inEdgeFilter = new DefaultEdgeFilter(encoder, true, false);
Expand Down Expand Up @@ -150,9 +145,9 @@ public float calculatePriority(int node) {
// the more edges will be removed when contracting this node the earlier we want to contract the node // the more edges will be removed when contracting this node the earlier we want to contract the node
// System.out.printf("node: %d, eq: %d / %d = %f, oeq: %d / %d = %f, depth: %d --> %f\n", node, numEdges, numPrevEdges, edgeQuotient, // System.out.printf("node: %d, eq: %d / %d = %f, oeq: %d / %d = %f, depth: %d --> %f\n", node, numEdges, numPrevEdges, edgeQuotient,
// numOrigEdges, numPrevOrigEdges, origEdgeQuotient, hierarchyDepth, result); // numOrigEdges, numPrevOrigEdges, origEdgeQuotient, hierarchyDepth, result);
return edgeQuotientWeight * (numEdges / (float) numPrevEdges) + return config.getEdgeQuotientWeight() * (numEdges / (float) numPrevEdges) +
originalEdgeQuotientWeight * (numOrigEdges / (float) numPrevOrigEdges) + config.getOriginalEdgeQuotientWeight() * (numOrigEdges / (float) numPrevOrigEdges) +
hierarchyDepthWeight * hierarchyDepths[node]; config.getHierarchyDepthWeight() * hierarchyDepths[node];
} }


@Override @Override
Expand Down Expand Up @@ -180,9 +175,9 @@ public int getNumSearches() {
private int findAndHandleShortcuts(int node) { private int findAndHandleShortcuts(int node) {
numPolledEdges = 0; numPolledEdges = 0;
numSearches = 0; numSearches = 0;
if (searchType == SearchType.AGGRESSIVE) { if (config.searchType == SearchType.AGGRESSIVE) {
return findAndHandleShortcutsAggressive(node); return findAndHandleShortcutsAggressive(node);
} else if (searchType == SearchType.LEGACY_AGGRESSIVE) { } else if (config.searchType == SearchType.LEGACY_AGGRESSIVE) {
return findAndHandleShortcutsLegacyAggressive(node); return findAndHandleShortcutsLegacyAggressive(node);
} else { } else {
return findAndHandleShortcutsClassic(node); return findAndHandleShortcutsClassic(node);
Expand Down Expand Up @@ -266,6 +261,10 @@ private int findAndHandleShortcutsAggressive(int node) {
return 0; return 0;
} }


public void setSearchType(SearchType searchType) {
config.setSearchType(searchType);
}

private static class AddedShortcut { private static class AddedShortcut {
int startNode; int startNode;
int startEdge; int startEdge;
Expand Down Expand Up @@ -543,7 +542,7 @@ public String getStatisticsString() {
String result = String.format("searches: %10s, polled-edges: %10s, stats(calc): %s, stats(contract): %s, %s", String result = String.format("searches: %10s, polled-edges: %10s, stats(calc): %s, stats(contract): %s, %s",
nf(totalNumSearches), nf(totalNumPolledEdges), nf(totalNumSearches), nf(totalNumPolledEdges),
countingShortcutHandler.getStats(), addingShortcutHandler.getStats(), countingShortcutHandler.getStats(), addingShortcutHandler.getStats(),
searchType == SearchType.AGGRESSIVE ? witnessPathSearcher.getStatisticsString() : legacyWitnessPathFinder.getStatusString()); config.searchType == SearchType.AGGRESSIVE ? witnessPathSearcher.getStatisticsString() : legacyWitnessPathFinder.getStatusString());
countingShortcutHandler.resetStats(); countingShortcutHandler.resetStats();
addingShortcutHandler.resetStats(); addingShortcutHandler.resetStats();
legacyWitnessPathFinder.resetStats(); legacyWitnessPathFinder.resetStats();
Expand Down Expand Up @@ -1023,6 +1022,44 @@ public static long twoIntsInLong(int p, int q) {
return (((long) p << 32) | (q & 0xFFFFFFFFL)); return (((long) p << 32) | (q & 0xFFFFFFFFL));
} }


public static class Config {
public SearchType searchType = SearchType.AGGRESSIVE;
public float edgeQuotientWeight = 1;
public float originalEdgeQuotientWeight = 3;
public float hierarchyDepthWeight = 2;

public SearchType getSearchType() {
return searchType;
}

public void setSearchType(SearchType searchType) {
this.searchType = searchType;
}

public float getEdgeQuotientWeight() {
return edgeQuotientWeight;
}

public void setEdgeQuotientWeight(float edgeQuotientWeight) {
this.edgeQuotientWeight = edgeQuotientWeight;
}

public float getOriginalEdgeQuotientWeight() {
return originalEdgeQuotientWeight;
}

public void setOriginalEdgeQuotientWeight(float originalEdgeQuotientWeight) {
this.originalEdgeQuotientWeight = originalEdgeQuotientWeight;
}

public float getHierarchyDepthWeight() {
return hierarchyDepthWeight;
}

public void setHierarchyDepthWeight(float hierarchyDepthWeight) {
this.hierarchyDepthWeight = hierarchyDepthWeight;
}
}
private static class Stats { private static class Stats {
int nodes; int nodes;
long shortcutsChecked; long shortcutsChecked;
Expand Down
Expand Up @@ -43,8 +43,8 @@ public class ManualPrepareContractionHierarchies extends PrepareContractionHiera
private int lastShortcutCount; private int lastShortcutCount;


public ManualPrepareContractionHierarchies(Directory dir, GraphHopperStorage ghStorage, CHGraph chGraph, Weighting weighting, public ManualPrepareContractionHierarchies(Directory dir, GraphHopperStorage ghStorage, CHGraph chGraph, Weighting weighting,
TraversalMode traversalMode, PMap options) { TraversalMode traversalMode, Config config) {
super(dir, ghStorage, chGraph, weighting, traversalMode, options); super(dir, ghStorage, chGraph, weighting, traversalMode, config);
} }


public ManualPrepareContractionHierarchies setContractionOrder(List<Integer> contractionOrder) { public ManualPrepareContractionHierarchies setContractionOrder(List<Integer> contractionOrder) {
Expand Down
Expand Up @@ -76,18 +76,18 @@ public class PrepareContractionHierarchies extends AbstractAlgoPreparation imple
private int neighborUpdatePercentage = 20; private int neighborUpdatePercentage = 20;
protected double nodesContractedPercentage = 100; protected double nodesContractedPercentage = 100;
protected double logMessagesPercentage = 20; protected double logMessagesPercentage = 20;
private final PMap options; private final Config config;
private int initSize; private int initSize;
private int checkCounter; private int checkCounter;


public PrepareContractionHierarchies(Directory dir, GraphHopperStorage ghStorage, CHGraph chGraph, public PrepareContractionHierarchies(Directory dir, GraphHopperStorage ghStorage, CHGraph chGraph,
Weighting weighting, TraversalMode traversalMode, PMap options) { Weighting weighting, TraversalMode traversalMode, Config config) {
this.dir = dir; this.dir = dir;
this.ghStorage = ghStorage; this.ghStorage = ghStorage;
this.prepareGraph = (CHGraphImpl) chGraph; this.prepareGraph = (CHGraphImpl) chGraph;
this.traversalMode = traversalMode; this.traversalMode = traversalMode;
this.weighting = weighting; this.weighting = weighting;
this.options = options; this.config = config;
prepareWeighting = new PreparationWeighting(weighting); prepareWeighting = new PreparationWeighting(weighting);
} }


Expand Down Expand Up @@ -463,7 +463,8 @@ public String toString() {
private NodeContractor createNodeContractor(Graph graph, TraversalMode traversalMode) { private NodeContractor createNodeContractor(Graph graph, TraversalMode traversalMode) {
if (traversalMode.isEdgeBased()) { if (traversalMode.isEdgeBased()) {
TurnWeighting chTurnWeighting = createTurnWeightingForEdgeBased(graph); TurnWeighting chTurnWeighting = createTurnWeightingForEdgeBased(graph);
return new EdgeBasedNodeContractor(dir, ghStorage, prepareGraph, chTurnWeighting, options); return new EdgeBasedNodeContractor(dir, ghStorage, prepareGraph, chTurnWeighting,
config.getEdgeBasedNodeContractorConfig());
} else { } else {
return new NodeBasedNodeContractor(dir, ghStorage, prepareGraph, weighting); return new NodeBasedNodeContractor(dir, ghStorage, prepareGraph, weighting);
} }
Expand Down Expand Up @@ -491,4 +492,16 @@ private void logStats(int updateCounter) {
nodeContractor.getStatisticsString(), nodeContractor.getStatisticsString(),
Helper.getMemInfo())); Helper.getMemInfo()));
} }

public static class Config {
EdgeBasedNodeContractor.Config edgeBasedNodeContractorConfig = new EdgeBasedNodeContractor.Config();

public EdgeBasedNodeContractor.Config getEdgeBasedNodeContractorConfig() {
return edgeBasedNodeContractorConfig;
}

public void setEdgeBasedNodeContractorConfig(EdgeBasedNodeContractor.Config edgeBasedNodeContractorConfig) {
this.edgeBasedNodeContractorConfig = edgeBasedNodeContractorConfig;
}
}
} }
Expand Up @@ -52,7 +52,7 @@ protected GraphHopperStorage createGHStorage(
public RoutingAlgorithmFactory createFactory(GraphHopperStorage ghStorage, AlgorithmOptions opts) { public RoutingAlgorithmFactory createFactory(GraphHopperStorage ghStorage, AlgorithmOptions opts) {
PrepareContractionHierarchies ch = new PrepareContractionHierarchies( PrepareContractionHierarchies ch = new PrepareContractionHierarchies(
new GHDirectory("", DAType.RAM_INT), ghStorage, getGraph(ghStorage, opts.getWeighting()), opts.getWeighting(), new GHDirectory("", DAType.RAM_INT), ghStorage, getGraph(ghStorage, opts.getWeighting()), opts.getWeighting(),
TraversalMode.EDGE_BASED_2DIR, new PMap()); TraversalMode.EDGE_BASED_2DIR, new PrepareContractionHierarchies.Config());
ch.doWork(); ch.doWork();
return ch; return ch;
} }
Expand Down
Expand Up @@ -57,7 +57,7 @@ protected GraphHopperStorage createGHStorage(EncodingManager em,
public RoutingAlgorithmFactory createFactory(GraphHopperStorage ghStorage, AlgorithmOptions opts) { public RoutingAlgorithmFactory createFactory(GraphHopperStorage ghStorage, AlgorithmOptions opts) {
PrepareContractionHierarchies ch = new PrepareContractionHierarchies(new GHDirectory("", DAType.RAM_INT), PrepareContractionHierarchies ch = new PrepareContractionHierarchies(new GHDirectory("", DAType.RAM_INT),
ghStorage, getGraph(ghStorage, opts.getWeighting()), ghStorage, getGraph(ghStorage, opts.getWeighting()),
opts.getWeighting(), TraversalMode.NODE_BASED, new PMap()); opts.getWeighting(), TraversalMode.NODE_BASED, new PrepareContractionHierarchies.Config());
ch.doWork(); ch.doWork();
return ch; return ch;
} }
Expand Down Expand Up @@ -104,7 +104,7 @@ public void testPathRecursiveUnpacking() {


AlgorithmOptions opts = new AlgorithmOptions(Parameters.Algorithms.DIJKSTRA_BI, weighting); AlgorithmOptions opts = new AlgorithmOptions(Parameters.Algorithms.DIJKSTRA_BI, weighting);
Path p = new PrepareContractionHierarchies(new GHDirectory("", DAType.RAM_INT), Path p = new PrepareContractionHierarchies(new GHDirectory("", DAType.RAM_INT),
ghStorage, g2, weighting, TraversalMode.NODE_BASED, new PMap()). ghStorage, g2, weighting, TraversalMode.NODE_BASED, new PrepareContractionHierarchies.Config()).
createAlgo(g2, opts).calcPath(0, 7); createAlgo(g2, opts).calcPath(0, 7);


assertEquals(Helper.createTList(0, 2, 5, 7), p.calcNodes()); assertEquals(Helper.createTList(0, 2, 5, 7), p.calcNodes());
Expand Down Expand Up @@ -260,7 +260,7 @@ private void runTestWithDirectionDependentEdgeSpeed(


private RoutingAlgorithm createCHAlgo(GraphHopperStorage graph, CHGraph chGraph, boolean withSOD, AlgorithmOptions algorithmOptions) { private RoutingAlgorithm createCHAlgo(GraphHopperStorage graph, CHGraph chGraph, boolean withSOD, AlgorithmOptions algorithmOptions) {
PrepareContractionHierarchies ch = new PrepareContractionHierarchies(new GHDirectory("", DAType.RAM_INT), PrepareContractionHierarchies ch = new PrepareContractionHierarchies(new GHDirectory("", DAType.RAM_INT),
graph, chGraph, algorithmOptions.getWeighting(), TraversalMode.NODE_BASED, new PMap()); graph, chGraph, algorithmOptions.getWeighting(), TraversalMode.NODE_BASED, new PrepareContractionHierarchies.Config());
if (!withSOD) { if (!withSOD) {
algorithmOptions.getHints().put("stall_on_demand", false); algorithmOptions.getHints().put("stall_on_demand", false);
} }
Expand Down
Expand Up @@ -44,7 +44,7 @@ protected GraphHopperStorage createGHStorage(
public RoutingAlgorithmFactory createFactory(GraphHopperStorage ghStorage, AlgorithmOptions opts) { public RoutingAlgorithmFactory createFactory(GraphHopperStorage ghStorage, AlgorithmOptions opts) {
PrepareContractionHierarchies ch = new PrepareContractionHierarchies( PrepareContractionHierarchies ch = new PrepareContractionHierarchies(
new GHDirectory("", DAType.RAM_INT), ghStorage, getGraph(ghStorage, opts.getWeighting()), opts.getWeighting(), new GHDirectory("", DAType.RAM_INT), ghStorage, getGraph(ghStorage, opts.getWeighting()), opts.getWeighting(),
TraversalMode.EDGE_BASED_2DIR, new PMap()); TraversalMode.EDGE_BASED_2DIR, new PrepareContractionHierarchies.Config());
ch.doWork(); ch.doWork();
return ch; return ch;
} }
Expand Down
Expand Up @@ -714,15 +714,15 @@ private Path findPathUsingCH(int from, int to, List<Integer> contractionOrder) {
private RoutingAlgorithmFactory prepareCH(List<Integer> contractionOrder) { private RoutingAlgorithmFactory prepareCH(List<Integer> contractionOrder) {
LOGGER.debug("Calculating CH with contraction order {}", contractionOrder); LOGGER.debug("Calculating CH with contraction order {}", contractionOrder);
ManualPrepareContractionHierarchies ch = new ManualPrepareContractionHierarchies( ManualPrepareContractionHierarchies ch = new ManualPrepareContractionHierarchies(
new RAMDirectory(""), graph, chGraph, weighting, TraversalMode.EDGE_BASED_2DIR, new PMap()) new RAMDirectory(""), graph, chGraph, weighting, TraversalMode.EDGE_BASED_2DIR, new PrepareContractionHierarchies.Config())
.setContractionOrder(contractionOrder); .setContractionOrder(contractionOrder);
ch.doWork(); ch.doWork();
return ch; return ch;
} }


private RoutingAlgorithmFactory automaticPrepareCH() { private RoutingAlgorithmFactory automaticPrepareCH() {
PrepareContractionHierarchies ch = new PrepareContractionHierarchies( PrepareContractionHierarchies ch = new PrepareContractionHierarchies(
new RAMDirectory(""), graph, chGraph, weighting, TraversalMode.EDGE_BASED_2DIR, new PMap()); new RAMDirectory(""), graph, chGraph, weighting, TraversalMode.EDGE_BASED_2DIR, new PrepareContractionHierarchies.Config());
ch.setPeriodicUpdates(20); ch.setPeriodicUpdates(20);
ch.setLazyUpdates(100); ch.setLazyUpdates(100);
ch.setNeighborUpdates(4); ch.setNeighborUpdates(4);
Expand Down
Expand Up @@ -1193,9 +1193,8 @@ public void testNodeContraction_randomGraph_checkStatistics() {
buildRandomGraph(seed); buildRandomGraph(seed);
System.out.println("graph for legacy aggressive search"); System.out.println("graph for legacy aggressive search");
GHUtility.printGraphForUnitTest(graph, encoder); GHUtility.printGraphForUnitTest(graph, encoder);
EdgeBasedNodeContractor.searchType = SearchType.LEGACY_AGGRESSIVE;


EdgeBasedNodeContractor nodeContractor = createNodeContractor(); EdgeBasedNodeContractor nodeContractor = createNodeContractor(SearchType.LEGACY_AGGRESSIVE);
nodeContractor.contractNode(0); nodeContractor.contractNode(0);
int numEdgesPolledL = nodeContractor.getNumPolledEdges(); int numEdgesPolledL = nodeContractor.getNumPolledEdges();
int numSearchesL = nodeContractor.getNumSearches(); int numSearchesL = nodeContractor.getNumSearches();
Expand All @@ -1207,9 +1206,8 @@ public void testNodeContraction_randomGraph_checkStatistics() {
buildRandomGraph(seed); buildRandomGraph(seed);
System.out.println("graph for aggressive search"); System.out.println("graph for aggressive search");
GHUtility.printGraphForUnitTest(graph, encoder); GHUtility.printGraphForUnitTest(graph, encoder);
EdgeBasedNodeContractor.searchType = SearchType.AGGRESSIVE;


nodeContractor = createNodeContractor(); nodeContractor = createNodeContractor(SearchType.AGGRESSIVE);
nodeContractor.contractNode(0); nodeContractor.contractNode(0);
int numEdgesPolledA = nodeContractor.getNumPolledEdges(); int numEdgesPolledA = nodeContractor.getNumPolledEdges();
int numSearchesA = nodeContractor.getNumSearches(); int numSearchesA = nodeContractor.getNumSearches();
Expand Down Expand Up @@ -1271,8 +1269,14 @@ private void contractNodes(int... nodes) {
} }


private EdgeBasedNodeContractor createNodeContractor() { private EdgeBasedNodeContractor createNodeContractor() {
return createNodeContractor(SearchType.AGGRESSIVE);
}

private EdgeBasedNodeContractor createNodeContractor(SearchType searchType) {
EdgeBasedNodeContractor.Config config = new EdgeBasedNodeContractor.Config();
config.setSearchType(searchType);
Directory dir = new GHDirectory("", DAType.RAM_INT); Directory dir = new GHDirectory("", DAType.RAM_INT);
EdgeBasedNodeContractor nodeContractor = new EdgeBasedNodeContractor(dir, graph, chGraph, chTurnWeighting, new PMap()); EdgeBasedNodeContractor nodeContractor = new EdgeBasedNodeContractor(dir, graph, chGraph, chTurnWeighting, config);
nodeContractor.initFromGraph(); nodeContractor.initFromGraph();
return nodeContractor; return nodeContractor;
} }
Expand Down
Expand Up @@ -160,7 +160,7 @@ public void testAddShortcuts() {
} }


private PrepareContractionHierarchies createPrepareContractionHierarchies(GraphHopperStorage g, CHGraph lg) { private PrepareContractionHierarchies createPrepareContractionHierarchies(GraphHopperStorage g, CHGraph lg) {
return new PrepareContractionHierarchies(dir, g, lg, weighting, tMode, new PMap()); return new PrepareContractionHierarchies(dir, g, lg, weighting, tMode, new PrepareContractionHierarchies.Config());
} }


@Test @Test
Expand Down Expand Up @@ -483,7 +483,7 @@ public void testMultiplePreparationsDifferentView() {


void checkPath(GraphHopperStorage ghStorage, Weighting w, int expShortcuts, double expDistance, IntIndexedContainer expNodes) { void checkPath(GraphHopperStorage ghStorage, Weighting w, int expShortcuts, double expDistance, IntIndexedContainer expNodes) {
CHGraph lg = ghStorage.getGraph(CHGraph.class, w); CHGraph lg = ghStorage.getGraph(CHGraph.class, w);
PrepareContractionHierarchies prepare = new PrepareContractionHierarchies(dir, ghStorage, lg, w, tMode, new PMap()); PrepareContractionHierarchies prepare = new PrepareContractionHierarchies(dir, ghStorage, lg, w, tMode, new PrepareContractionHierarchies.Config());
prepare.doWork(); prepare.doWork();
assertEquals(w.toString(), expShortcuts, prepare.getShortcuts()); assertEquals(w.toString(), expShortcuts, prepare.getShortcuts());
RoutingAlgorithm algo = prepare.createAlgo(lg, new AlgorithmOptions(DIJKSTRA_BI, w, tMode)); RoutingAlgorithm algo = prepare.createAlgo(lg, new AlgorithmOptions(DIJKSTRA_BI, w, tMode));
Expand Down
Expand Up @@ -904,7 +904,7 @@ public void testGetWeightingForCH() {


private PrepareContractionHierarchies createPrepareContractionHierarchies(RAMDirectory ramDir, GraphHopperStorage storage, Weighting fwSimpleTruck) { private PrepareContractionHierarchies createPrepareContractionHierarchies(RAMDirectory ramDir, GraphHopperStorage storage, Weighting fwSimpleTruck) {
return new PrepareContractionHierarchies(ramDir, storage, storage.getGraph(CHGraph.class, fwSimpleTruck), return new PrepareContractionHierarchies(ramDir, storage, storage.getGraph(CHGraph.class, fwSimpleTruck),
fwSimpleTruck, TraversalMode.NODE_BASED, new PMap()); fwSimpleTruck, TraversalMode.NODE_BASED, new PrepareContractionHierarchies.Config());
} }


@Test @Test
Expand Down

0 comments on commit b28e760

Please sign in to comment.