Skip to content

Commit

Permalink
Some minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
easbar committed Feb 29, 2020
1 parent 8d15708 commit 9129481
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ public void setPreparationThreads(int preparationThreads) {
public void prepare(final StorableProperties properties, final boolean closeEarly) {
ExecutorCompletionService<String> completionService = new ExecutorCompletionService<>(threadPool);
int counter = 0;
for (final PrepareContractionHierarchies prepare : getPreparations()) {
LOGGER.info((++counter) + "/" + getPreparations().size() + " calling " +
for (final PrepareContractionHierarchies prepare : preparations) {
LOGGER.info((++counter) + "/" + preparations.size() + " calling " +
"CH prepare.doWork for " + prepare.getCHProfile() + " ... (" + getMemInfo() + ")");
final String name = prepare.getCHProfile().toFileName();
completionService.submit(new Runnable() {
Expand All @@ -231,7 +231,7 @@ public void run() {
threadPool.shutdown();

try {
for (int i = 0; i < getPreparations().size(); i++) {
for (int i = 0; i < preparations.size(); i++) {
completionService.take().get();
}
} catch (Exception e) {
Expand All @@ -241,7 +241,7 @@ public void run() {
}

public void createPreparations(GraphHopperStorage ghStorage) {
if (!isEnabled() || !getPreparations().isEmpty())
if (!isEnabled() || !preparations.isEmpty())
return;
if (!hasCHProfiles())
throw new IllegalStateException("No CH profiles found");
Expand Down
22 changes: 11 additions & 11 deletions core/src/test/java/com/graphhopper/routing/RoutingAlgorithmIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ public static List<AlgoHelperEntry> createAlgos(final GraphHopper hopper, final
.setVehicle(hints.getVehicle()).setWeighting(hints.getWeighting());

AlgorithmOptions defaultOpts = AlgorithmOptions.start(new AlgorithmOptions("", weighting, tMode)).hints(defaultHints).build();
List<AlgoHelperEntry> prepare = new ArrayList<>();
prepare.add(new AlgoHelperEntry(ghStorage, AlgorithmOptions.start(defaultOpts).algorithm(ASTAR).build(), idx, "astar|beeline|" + addStr + weighting));
List<AlgoHelperEntry> algos = new ArrayList<>();
algos.add(new AlgoHelperEntry(ghStorage, AlgorithmOptions.start(defaultOpts).algorithm(ASTAR).build(), idx, "astar|beeline|" + addStr + weighting));
// later: include dijkstraOneToMany
prepare.add(new AlgoHelperEntry(ghStorage, AlgorithmOptions.start(defaultOpts).algorithm(DIJKSTRA).build(), idx, "dijkstra|" + addStr + weighting));
algos.add(new AlgoHelperEntry(ghStorage, AlgorithmOptions.start(defaultOpts).algorithm(DIJKSTRA).build(), idx, "dijkstra|" + addStr + weighting));

AlgorithmOptions astarbiOpts = AlgorithmOptions.start(defaultOpts).algorithm(ASTAR_BI).build();
astarbiOpts.getHints().put(ASTAR_BI + ".approximation", "BeelineSimplification");
AlgorithmOptions dijkstrabiOpts = AlgorithmOptions.start(defaultOpts).algorithm(DIJKSTRA_BI).build();
prepare.add(new AlgoHelperEntry(ghStorage, astarbiOpts, idx, "astarbi|beeline|" + addStr + weighting));
prepare.add(new AlgoHelperEntry(ghStorage, dijkstrabiOpts, idx, "dijkstrabi|" + addStr + weighting));
algos.add(new AlgoHelperEntry(ghStorage, astarbiOpts, idx, "astarbi|beeline|" + addStr + weighting));
algos.add(new AlgoHelperEntry(ghStorage, dijkstrabiOpts, idx, "dijkstrabi|" + addStr + weighting));

// add additional preparations if CH and LM preparation are enabled
if (hopper.getLMPreparationHandler().isEnabled()) {
final HintsMap lmHints = new HintsMap(defaultHints).put(Parameters.Landmark.DISABLE, false);
prepare.add(new AlgoHelperEntry(ghStorage, AlgorithmOptions.start(astarbiOpts).hints(lmHints).build(), idx, "astarbi|landmarks|" + weighting) {
algos.add(new AlgoHelperEntry(ghStorage, AlgorithmOptions.start(astarbiOpts).hints(lmHints).build(), idx, "astarbi|landmarks|" + weighting) {
@Override
public RoutingAlgorithmFactory createRoutingFactory() {
return hopper.getAlgorithmFactory(lmHints);
Expand All @@ -98,24 +98,24 @@ public RoutingAlgorithmFactory createRoutingFactory() {
chHints.put(Parameters.CH.DISABLE, false);
chHints.put(Parameters.Routing.EDGE_BASED, tMode.isEdgeBased());
CHProfile pickedProfile = CHProfileSelector.select(hopper.getCHPreparationHandler().getCHProfiles(), chHints);
prepare.add(new AlgoHelperEntry(ghStorage.getCHGraph(pickedProfile),
AlgorithmOptions.start(dijkstrabiOpts).hints(chHints).build(), idx, "dijkstrabi|ch|prepare|" + hints.getWeighting()) {
algos.add(new AlgoHelperEntry(ghStorage.getCHGraph(pickedProfile),
AlgorithmOptions.start(dijkstrabiOpts).hints(chHints).build(), idx, "dijkstrabi|ch|algos|" + hints.getWeighting()) {
@Override
public RoutingAlgorithmFactory createRoutingFactory() {
return hopper.getAlgorithmFactory(chHints);
}
});

prepare.add(new AlgoHelperEntry(ghStorage.getCHGraph(pickedProfile),
AlgorithmOptions.start(astarbiOpts).hints(chHints).build(), idx, "astarbi|ch|prepare|" + hints.getWeighting()) {
algos.add(new AlgoHelperEntry(ghStorage.getCHGraph(pickedProfile),
AlgorithmOptions.start(astarbiOpts).hints(chHints).build(), idx, "astarbi|ch|algos|" + hints.getWeighting()) {
@Override
public RoutingAlgorithmFactory createRoutingFactory() {
return hopper.getAlgorithmFactory(chHints);
}
});
}

return prepare;
return algos;
}

@Test
Expand Down

0 comments on commit 9129481

Please sign in to comment.