Search in sources :

Example 1 with SearchTerminationStrategy

use of org.opentripplanner.routing.algorithm.astar.strategies.SearchTerminationStrategy in project OpenTripPlanner by opentripplanner.

the class AStarTest method testMultipleTargets.

@Test
public void testMultipleTargets() {
    RoutingRequest options = new RoutingRequest();
    options.walkSpeed = 1.0;
    options.setRoutingContext(graph, graph.getVertex("56th_24th"), graph.getVertex("leary_20th"));
    Set<Vertex> targets = new HashSet<Vertex>();
    targets.add(graph.getVertex("shilshole_22nd"));
    targets.add(graph.getVertex("market_russell"));
    targets.add(graph.getVertex("56th_20th"));
    targets.add(graph.getVertex("leary_20th"));
    SearchTerminationStrategy strategy = new MultiTargetTerminationStrategy(targets);
    ShortestPathTree tree = new AStar().getShortestPathTree(options, -1, strategy);
    for (Vertex v : targets) {
        GraphPath path = tree.getPath(v, false);
        assertNotNull("No path found for target " + v.getLabel(), path);
    }
}
Also used : SimpleConcreteVertex(org.opentripplanner.routing.graph.SimpleConcreteVertex) Vertex(org.opentripplanner.routing.graph.Vertex) ShortestPathTree(org.opentripplanner.routing.spt.ShortestPathTree) AStar(org.opentripplanner.routing.algorithm.astar.AStar) GraphPath(org.opentripplanner.routing.spt.GraphPath) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) SearchTerminationStrategy(org.opentripplanner.routing.algorithm.astar.strategies.SearchTerminationStrategy) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

HashSet (java.util.HashSet)1 Test (org.junit.Test)1 AStar (org.opentripplanner.routing.algorithm.astar.AStar)1 SearchTerminationStrategy (org.opentripplanner.routing.algorithm.astar.strategies.SearchTerminationStrategy)1 RoutingRequest (org.opentripplanner.routing.api.request.RoutingRequest)1 SimpleConcreteVertex (org.opentripplanner.routing.graph.SimpleConcreteVertex)1 Vertex (org.opentripplanner.routing.graph.Vertex)1 GraphPath (org.opentripplanner.routing.spt.GraphPath)1 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)1