Search in sources :

Example 1 with SearchTerminationStrategy

use of org.opentripplanner.routing.algorithm.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.batch = true;
    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) GraphPath(org.opentripplanner.routing.spt.GraphPath) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest) MultiTargetTerminationStrategy(org.opentripplanner.routing.algorithm.strategies.MultiTargetTerminationStrategy) SearchTerminationStrategy(org.opentripplanner.routing.algorithm.strategies.SearchTerminationStrategy) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

HashSet (java.util.HashSet)1 Test (org.junit.Test)1 MultiTargetTerminationStrategy (org.opentripplanner.routing.algorithm.strategies.MultiTargetTerminationStrategy)1 SearchTerminationStrategy (org.opentripplanner.routing.algorithm.strategies.SearchTerminationStrategy)1 RoutingRequest (org.opentripplanner.routing.core.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