Package org.opentripplanner.routing.core

Examples of org.opentripplanner.routing.core.State


        dijkstra.setShortestPathTreeFactory(MultiShortestPathTree.FACTORY);
        dijkstra.setPriorityQueueFactory(PriorityQueueImpl.FACTORY);

        TPOfflineOriginVertex origin = new TPOfflineOriginVertex(context, stop,
            instances, nearbyStopsAndWalkTimes, nearbyStopTimeInstances);
        State state = new OBAState(tFrom, origin, options);

        MultiShortestPathTree spt = (MultiShortestPathTree) dijkstra.getShortestPathTree(state);

        processTree(spt, stop, pathCountsByStop);
      }
View Full Code Here


        boolean keep = false;

        for (State state : states) {

          long t = state.getTime();
          State nextState = getNextVertex(m, pathsByVertex, t, path);
          if (nextState == null) {
            keep = true;
            break;
          }
          int duration = (int) (Math.abs(state.getTime() - state.getStartTime()) / 1000);
          double additional = ((nextState.getTime() - state.getTime()) / 1000);
          if (additional / duration > _transferPatternFrequencySlack) {
            keep = true;
            break;
          }
        }
View Full Code Here

    Collections.sort(sptVertices, _sptVertexDurationComparator);

    double bestRatio = Double.MAX_VALUE;

    for (int i = 0; i < sptVertices.size(); i++) {
      State state = sptVertices.get(i);
      double duration = getStateDuration(state);
      double weight = state.getWeight();
      double ratio = weight / duration;

      if (ratio / bestRatio > _transferPatternWeightImprovement) {
        return sptVertices.subList(0, i);
      } else {
View Full Code Here

  }

  @Override
  public State getState(Vertex dest) {
    List<State> states = getStates(dest);
    State ret = null;
    for (State s : states) {
      if (ret == null || s.betterThan(ret)) {
        ret = s;
      }
    }
View Full Code Here

    if (extraEdges.isEmpty())
      extraEdges = Collections.emptyMap();

    while (!queue.empty()) {

      State state = queue.extract_min();

      Vertex fromVertex = state.getVertex();

      closed.add(fromVertex);

      if (_vertexSkipStrategy.isVertexSkippedInFowardSearch(origin,
          originState, state, options))
View Full Code Here

    TPQueryData queryData = options.getExtension(TPQueryData.class);

    List<StopEntry> sourceStops = queryData.getSourceStops();

    State results = null;

    Collection<TransferNode> trees = tpService.getReverseTransferPatternsForStops(
        queryData.getTransferPatternData(), sourceStops, _stop);

    for (TransferNode tree : trees) {

      TPState pathState = TPState.end(queryData, tree);

      Vertex fromVertex = new TPArrivalVertex(_context, pathState);
      Vertex toVertex = new WalkFromStopVertex(_context, _stop);

      EdgeNarrative narrative = narrative(s0, fromVertex, toVertex);
      State r = s0.edit(this, narrative).makeState();
      results = r.addToExistingResultChain(results);
    }

    return results;
  }
View Full Code Here

      throw new OutOfServiceAreaServiceException();

    Vertex v = options.isArriveBy() ? toVertex : fromVertex;
    Vertex target = options.isArriveBy() ? fromVertex : toVertex;

    State state = new OBAState(targetTime, v, options);

    if (_transferPathService.isEnabled()) {
      return getTransferPatternItinerariesBetween(fromVertex, toVertex,
          new Date(targetTime), options);
    } else {
View Full Code Here

    TraverseModeSet modes = new TraverseModeSet(TraverseMode.WALK);
    options.setModes(modes);

    Vertex origin = options.isArriveBy() ? to : from;
    Vertex target = options.isArriveBy() ? from : to;
    State state = new OBAState(time.getTime(), origin, options);

    List<GraphPath> paths = _pathService.plan(state, target, 1);

    if (CollectionsLibrary.isEmpty(paths))
      return null;
View Full Code Here

    options.putExtension(TPQueryData.class, queryData);

    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);
View Full Code Here

    if (obaOpts.extraSpecialMode)
      return extraSpecialMode(s0, obaOpts);

    ArrivalAndDepartureService service = _context.getArrivalAndDepartureService();

    State results = null;

    OBAState state = (OBAState) s0;

    int maxBlockSequence = state.getMaxBlockSequence();

    if (maxBlockSequence < 0) {
      ArrivalAndDepartureInstance nextTransferStop = service.getNextTransferStopArrivalAndDeparture(_from);
      if (nextTransferStop != null) {

        long departure = _from.getBestDepartureTime();
        long arrival = nextTransferStop.getBestArrivalTime();
        int runningTime = (int) ((arrival - departure) / 1000);

        Vertex fromVertex = new BlockDepartureVertex(_context, _from);
        Vertex toVertex = new BlockArrivalVertex(_context, nextTransferStop);
        EdgeNarrative narrative = narrative(s0, fromVertex, toVertex);

        StateEditor edit = s0.edit(this, narrative);
        edit.incrementTimeInSeconds(runningTime);
        edit.incrementWeight(runningTime);

        State result = edit.makeState();
        results = result.addToExistingResultChain(results);

        maxBlockSequence = nextTransferStop.getBlockStopTime().getBlockSequence();
      } else {
        maxBlockSequence = Integer.MAX_VALUE;
      }
    }

    ArrivalAndDepartureInstance nextStop = service.getNextStopArrivalAndDeparture(_from);

    if (nextStop != null
        && nextStop.getBlockStopTime().getBlockSequence() < maxBlockSequence) {

      long departure = _from.getBestDepartureTime();
      long arrival = nextStop.getBestArrivalTime();
      int runningTime = (int) ((arrival - departure) / 1000);

      Vertex fromVertex = new BlockDepartureVertex(_context, _from);
      Vertex toVertex = new BlockArrivalVertex(_context, nextStop);
      EdgeNarrative narrative = narrative(s0, fromVertex, toVertex);

      OBAStateEditor edit = (OBAStateEditor) s0.edit(this, narrative);
      edit.incrementTimeInSeconds(runningTime);
      edit.incrementWeight(runningTime);

      if (state.getMaxBlockSequence() < 0)
        edit.setMaxBlockSequence(maxBlockSequence);

      State tr = edit.makeState();
      results = tr.addToExistingResultChain(results);
    }

    return results;
  }
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.core.State

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.