Package org.opentripplanner.routing.algorithm

Examples of org.opentripplanner.routing.algorithm.GenericAStar


  private VisualTraverseVisitor traverseVisitor=null;

  @Override
  public SPTService instantiate() {
    GenericAStar ret = new GenericAStar();
    if(traverseVisitor!=null){
      ret.setTraverseVisitor(traverseVisitor);
    }
    return ret;
  }
View Full Code Here


    public GenericAStarFactory getAStarSearchFactory() {
        return new GenericAStarFactory() {

            @Override
            public GenericAStar createAStarInstance() {
                GenericAStar astar = new GenericAStar();
                astar.setTraverseVisitor(VisualTraverseVisitor.this);
                return astar;
            }
        };
    }
View Full Code Here

        assertNotNull(carlton);
       
        assertEquals(3, start.getDegreeOut());
        assertEquals(3, start.getDegreeIn());

        GenericAStar aStar = new GenericAStar();
        RoutingRequest opt = new RoutingRequest();
        opt.setRoutingContext(gg, start, end);
        ShortestPathTree spt = aStar.getShortestPathTree(opt);
        assertNotNull(spt);

        //test that the option to walk bikes on the first or last segment works
       
        opt = new RoutingRequest(new TraverseModeSet(TraverseMode.BICYCLE));
       
        //Real live cyclists tell me that they would prefer to ride around the long way than to
        //walk their bikes the short way.  If we slow down the default biking speed, that will
        //force a change in preferences.
        opt.bikeSpeed = 2;
       
        opt.setRoutingContext(gg, start, carlton);
        spt = aStar.getShortestPathTree(opt);
        assertNotNull(spt);
        /* commented out as bike walking is not supported */
        /*
        GraphPath path = spt.getPath(carlton.vertex);
        assertNotNull(path);
View Full Code Here

        return instance;
    }

    public Context() throws IOException {
        // Create a star search
        aStar = new GenericAStar();

        // Create graph
        GtfsContext context = GtfsLibrary.readGtfs(new File(ConstantsForTests.FAKE_GTFS));
        graph = spy(new Graph());
        GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
View Full Code Here

        }
       
        RoutingRequest options = prototypeOptions.clone();
        options.setRoutingContext(_graph, start, end);
       
        GenericAStar aStar = new GenericAStar();
       
        ShortestPathTree tree = aStar.getShortestPathTree(options);
        GraphPath path = tree.getPath(end, false);
        options.cleanup();
        assertNotNull(path);
       
        double startEndWeight = path.getWeight();
View Full Code Here

        long worstElapsedTimeSeconds = maxAccessTime * 60; // convert from minutes to seconds
        if (dest) worstElapsedTimeSeconds *= -1;
        rr.worstTime = (rr.dateTime + worstElapsedTimeSeconds);
        // Note that the (forward) search is intentionally unlimited so it will reach the destination
        // on-street, even though only transit boarding locations closer than req.streetDist will be used.
        GenericAStar astar = new GenericAStar();
        rr.setNumItineraries(1);
        StopFinderTraverseVisitor visitor = new StopFinderTraverseVisitor(mode, minAccessTime * 60);
        astar.setTraverseVisitor(visitor);
        astar.getShortestPathTree(rr, 5); // timeout in seconds
        // Save the routing context for later cleanup. We need its temporary edges to render street segments at the end.
        routingContexts.add(rr.rctx);
        return visitor.stopClustersFound.values();
    }
View Full Code Here

        // Impose a max time to protect against very slow searches.
        int worstElapsedTime = request.streetTime * 60;
        rr.worstTime = (rr.dateTime + worstElapsedTime);
        rr.walkSpeed = request.walkSpeed;
        rr.bikeSpeed = request.bikeSpeed;
        GenericAStar astar = new GenericAStar();
        rr.setNumItineraries(1);
        ShortestPathTree spt = astar.getShortestPathTree(rr, System.currentTimeMillis() + 5000);
        State state = spt.getState(rr.rctx.target);
        if (state != null) {
            LOG.info("Found non-transit option for mode {}", mode);
            directPaths.add(new StopAtDistance(state));
        }
View Full Code Here

        rr.walkSpeed = request.walkSpeed;
        // If max trip duration is not limited, searches are of course much slower.
        int worstElapsedTime = request.maxWalkTime * 60; // convert from minutes to seconds, assume walking at egress
        rr.worstTime = (rr.dateTime + worstElapsedTime);
        rr.batch = (true);
        GenericAStar astar = new GenericAStar();
        rr.setNumItineraries(1);
        for (TransitStop tstop : graph.index.stopVertexForStop.values()) {
            int index = tstop.getIndex();
            // Generate a tree outward from all stops that have been touched in the basic profile search
            if (mins[index] == TimeSurface.UNREACHABLE || maxs[index] == TimeSurface.UNREACHABLE) continue;
            rr.setRoutingContext(graph, tstop, null); // Set origin vertex directly instead of generating link edges
            astar.setTraverseVisitor(new ExtremaPropagationTraverseVisitor(mins[index], maxs[index]));
            ShortestPathTree spt = astar.getShortestPathTree(rr, 5);
            rr.rctx.destroy();
        }
        minSurface = new TimeSurface(this, false);
        maxSurface = new TimeSurface(this, true);
        LOG.info("done making timesurfaces.");
View Full Code Here

    Graph graph = _graphService.getGraph();
    Vertex origin = options.isArriveBy() ? toVertex : fromVertex;
    Vertex target = options.isArriveBy() ? fromVertex : toVertex;
    State init = new OBAState(time.getTime(), origin, options);
    options.remainingWeightHeuristic = new TPRemainingWeightHeuristicImpl();
    GenericAStar search = new GenericAStar();
    search.setSkipTraverseResultStrategy(new SkipVertexImpl());
    search.setSearchTerminationStrategy(new SearchTerminationStrategyImpl());
    search.setShortestPathTreeFactory(TripSequenceShortestPathTree.FACTORY);

    ShortestPathTree spt = search.getShortestPathTree(graph, init, target);
    return spt.getPaths(target, true);
  }
View Full Code Here

  private static class GenericAStarFactoryImpl implements GenericAStarFactory {

    @Override
    public GenericAStar createAStarInstance() {
      GenericAStar instance = new GenericAStar();
      instance.setSearchTerminationStrategy(new SearchTerminationStrategyImpl());
      instance.setShortestPathTreeFactory(TripSequenceShortestPathTree.FACTORY);
      return instance;
    }
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.algorithm.GenericAStar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.