Package org.opentripplanner.routing.core

Examples of org.opentripplanner.routing.core.State


    }

    @Override
    public boolean visit(State s) {
        final Graph graph = s.getOptions().rctx.graph;
        final State existing = states.get(s.getVertex());
        final Edge backEdge = existing.getBackEdge();
        if (!graph.getTurnRestrictions(backEdge).isEmpty()) {
            // If the previous back edge had turn restrictions, we need to continue
            // the search because the previous path may be prevented by from reaching the end by
            // turn restrictions.
View Full Code Here


   
    @Override
    public void valueChanged(ListSelectionEvent e) {
      @SuppressWarnings("unchecked")
      JList<State> theList = (JList<State>)e.getSource();
      State st = (State)theList.getSelectedValue();
      if(st==null){
        return;
      }
     
      DefaultListModel<String> stateListModel = new DefaultListModel<String>();
      stateListModel.addElement( "weight:"+st.getWeight() );
      stateListModel.addElement( "weightdelta:"+st.getWeightDelta() );
      stateListModel.addElement( "bikeRenting:"+st.isBikeRenting() );
      stateListModel.addElement( "carParked:"+st.isCarParked() );
      stateListModel.addElement( "walkDistance:"+st.getWalkDistance() );
      stateListModel.addElement( "elapsedTime:"+st.getElapsedTimeSeconds() );
      stateListModel.addElement( "numBoardings:"+st.getNumBoardings() );
      outputList.setModel( stateListModel );
     
      lastStateClicked = st;
    }
View Full Code Here

            int extreme = minimize ? Integer.MAX_VALUE : Integer.MIN_VALUE;
            int bestResult = extreme;
            // if skip[i]...
            Sample s = indiv.sample;
            // add null s0s1 checks
            State s0 = spt.getState(s.v0);
            State s1 = spt.getState(s.v1);
            if (s0 != null)
                bestResult = evaluate(s0, s.t0);
            if (s1 != null) {
                int r = evaluate(s1, s.t1);
                if (minimize) {
View Full Code Here

        this.v1 = v1;
        this.t1 = t1;
    }

    public byte evalBoardings(ShortestPathTree spt) {
        State s0 = spt.getState(v0);
        State s1 = spt.getState(v1);
        int m0 = 255;
        int m1 = 255;
        if (s0 != null)
            m0 = (s0.getNumBoardings());
        if (s1 != null)
            m1 = (s1.getNumBoardings());
        return (byte) ((m0 < m1) ? m0 : m1);
    }
View Full Code Here

            m1 = (s1.getNumBoardings());
        return (byte) ((m0 < m1) ? m0 : m1);
    }
   
    public long eval(ShortestPathTree spt) {
        State s0 = spt.getState(v0);
        State s1 = spt.getState(v1);
        long m0 = Long.MAX_VALUE;
        long m1 = Long.MAX_VALUE;
        if (s0 != null)
            m0 = (s0.getActiveTime() + t0);
        if (s1 != null)
            m1 = (s1.getActiveTime() + t1);
        return (m0 < m1) ? m0 : m1;
    }
View Full Code Here

      if( drawEdges  ){
        strokeWeight(1);
      stroke(255,255,255); //white 
      noFill();
      while (!newSPTEdges.isEmpty()) {
        State leaf = newSPTEdges.poll();
   
        if(leaf != null){
          if( leaf.getBackEdge() != null ){
            drawEdge(leaf.getBackEdge());
          }
        }
      }

    }
View Full Code Here

        forwardOptions.bikeRentalPickupTime = 4;
        forwardOptions.bikeRentalDropoffTime = 2;
        e53.visibleTo = forwardContext;

        // Forward traversal of all edges
        State s0Forward = new State(forwardOptions);
        State s2Forward = e1.traverse(s0Forward);
        State s4Forward = e3.traverse(s2Forward);
        State s6Forward = e5.traverse(s4Forward);
        State s8Forward = e7.traverse(s6Forward);
        State s10Forward = e9.traverse(s8Forward);
        State s12Forward = e11.traverse(s10Forward);
        State s14Forward = e13.traverse(s12Forward);
        State s16Forward = e15.traverse(s14Forward);
        State s18Forward = e17.traverse(s16Forward);
        State s20Forward = e19.traverse(s18Forward);
        State s22Forward = e21.traverse(s20Forward);
        State s24Forward = e23.traverse(s22Forward);
        State s26Forward = e25.traverse(s24Forward);
        State s28Forward = e27.traverse(s26Forward);
        State s30Forward = e29.traverse(s28Forward);
        State s32Forward = e31.traverse(s30Forward);
        State s34Forward = e33.traverse(s32Forward);
        State s36Forward = e35.traverse(s34Forward);
        State s38Forward = e37.traverse(s36Forward);
        State s40Forward = e39.traverse(s38Forward);
        State s42Forward = e41.traverse(s40Forward);
        State s44Forward = e43.traverse(s42Forward);
        State s46Forward = e45.traverse(s44Forward);
        State s48Forward = e47.traverse(s46Forward);
        State s50Forward = e49.traverse(s48Forward);
        State s52Forward = e51.traverse(s50Forward);
        State s54Forward = e53.traverse(s52Forward);
        State s56Forward = e55.traverse(s54Forward);
        State s58Forward = e57.traverse(s56Forward);
        State s60Forward = e59.traverse(s58Forward);

        // Also traverse the path backward
        RoutingRequest backwardOptions = options.clone();
        RoutingContext backwardContext = new RoutingContext(backwardOptions, graph, v60, v0);

        backwardContext.serviceDays = new ArrayList<ServiceDay>(1);
        backwardContext.serviceDays.add(serviceDay);

        backwardOptions.rctx = backwardContext;
        backwardOptions.dateTime = 60L;
        backwardOptions.bikeRentalPickupTime = 4;
        backwardOptions.bikeRentalDropoffTime = 2;
        backwardOptions.setArriveBy(true);
        e53.visibleTo = backwardContext;

        // Backward traversal of all edges
        State s60Backward = new State(backwardOptions);
        State s58Backward = e59.traverse(s60Backward);
        State s56Backward = e57.traverse(s58Backward);
        State s54Backward = e55.traverse(s56Backward);
        State s52Backward = e53.traverse(s54Backward);
        State s50Backward = e51.traverse(s52Backward);
        State s48Backward = e49.traverse(s50Backward);
        State s46Backward = e47.traverse(s48Backward);
        State s44Backward = e45.traverse(s46Backward);
        State s42Backward = e43.traverse(s44Backward);
        State s40Backward = e41.traverse(s42Backward);
        State s38Backward = e39.traverse(s40Backward);
        State s36Backward = e37.traverse(s38Backward);
        State s34Backward = e35.traverse(s36Backward);
        State s32Backward = e33.traverse(s34Backward);
        State s30Backward = e31.traverse(s32Backward);
        State s28Backward = e29.traverse(s30Backward);
        State s26Backward = e27.traverse(s28Backward);
        State s24Backward = e25.traverse(s26Backward);
        State s22Backward = e23.traverse(s24Backward);
        State s20Backward = e21.traverse(s22Backward);
        State s18Backward = e19.traverse(s20Backward);
        State s16Backward = e17.traverse(s18Backward);
        State s14Backward = e15.traverse(s16Backward);
        State s12Backward = e13.traverse(s14Backward);
        State s10Backward = e11.traverse(s12Backward);
        State s8Backward = e9.traverse(s10Backward);
        State s6Backward = e7.traverse(s8Backward);
        State s4Backward = e5.traverse(s6Backward);
        State s2Backward = e3.traverse(s4Backward);
        State s0Backward = e1.traverse(s2Backward);

        // Perform a forward traversal starting onboard
        RoutingRequest onboardOptions = options.clone();
        RoutingContext onboardContext = new RoutingContext(onboardOptions, graph,
                onboardDepartVertex, v60);

        onboardContext.serviceDays = new ArrayList<ServiceDay>(1);
        onboardContext.serviceDays.add(serviceDay);

        onboardOptions.rctx = onboardContext;
        onboardOptions.dateTime = 6L;
        onboardOptions.bikeRentalPickupTime = 4;
        onboardOptions.bikeRentalDropoffTime = 2;
        e53.visibleTo = onboardContext;

        // Onboard traversal of all edges
        State s10Onboard = new State(onboardOptions);
        State s12Onboard = onBoardDepartPatternHop.traverse(s10Onboard);
        State s14Onboard = e13.traverse(s12Onboard);
        State s16Onboard = e15.traverse(s14Onboard);
        State s18Onboard = e17.traverse(s16Onboard);
        State s20Onboard = e19.traverse(s18Onboard);
        State s22Onboard = e21.traverse(s20Onboard);
        State s24Onboard = e23.traverse(s22Onboard);
        State s26Onboard = e25.traverse(s24Onboard);
        State s28Onboard = e27.traverse(s26Onboard);
        State s30Onboard = e29.traverse(s28Onboard);
        State s32Onboard = e31.traverse(s30Onboard);
        State s34Onboard = e33.traverse(s32Onboard);
        State s36Onboard = e35.traverse(s34Onboard);
        State s38Onboard = e37.traverse(s36Onboard);
        State s40Onboard = e39.traverse(s38Onboard);
        State s42Onboard = e41.traverse(s40Onboard);
        State s44Onboard = e43.traverse(s42Onboard);
        State s46Onboard = e45.traverse(s44Onboard);
        State s48Onboard = e47.traverse(s46Onboard);
        State s50Onboard = e49.traverse(s48Onboard);
        State s52Onboard = e51.traverse(s50Onboard);
        State s54Onboard = e53.traverse(s52Onboard);
        State s56Onboard = e55.traverse(s54Onboard);
        State s58Onboard = e57.traverse(s56Onboard);
        State s60Onboard = e59.traverse(s58Onboard);

        return new GraphPath[] {new GraphPath(s60Forward, false),
                new GraphPath(s0Backward, false), new GraphPath(s60Onboard, false)};
    }
View Full Code Here

        LinkedListMultimap<Integer, Coordinate> componentCoordinates = LinkedListMultimap.create();
        options.setDummyRoutingContext(graph);
        for (Vertex v : graph.getVertices()) {
            for (Edge e : v.getOutgoing()) {
                State s0 = new State(v, time, options);
                State s1 = e.traverse(s0);
                if (s1 != null) {
                    Integer component = components.find(e.getFromVertex());
                    Geometry geometry = s1.getBackEdge().getGeometry();
                    if (geometry != null) {
                        List<Coordinate> coordinates = new ArrayList<Coordinate>(Arrays.asList(geometry.getCoordinates()));
                        for (int i = 0; i < coordinates.size(); ++i) {
                            Coordinate coordinate = new Coordinate(coordinates.get(i));
                            coordinate.x = Math.round(coordinate.x * PRECISION) / PRECISION;
View Full Code Here

        for (Vertex gv : graph.getVertices()) {
            if (!(gv instanceof StreetVertex)) {
                continue;
            }
            State s0 = new State(gv, options);
            for (Edge e : gv.getOutgoing()) {
                Vertex in = gv;
                if (!(e instanceof StreetEdge || e instanceof StreetTransitLink ||
                      e instanceof ElevatorEdge || e instanceof FreeEdge)) {
                    continue;
                }
                State s1 = e.traverse(s0);
                if (s1 == null) {
                    continue;
                }
                Vertex out = s1.getVertex();

                ArrayList<Vertex> vertexList = neighborsForVertex.get(in);
                if (vertexList == null) {
                    vertexList = new ArrayList<Vertex>();
                    neighborsForVertex.put(in, vertexList);
View Full Code Here

    }
   
    @Override
    public boolean add(State state) {
        Vertex here = state.getVertex();
        State existing = states.get(here);
        if (existing == null || earlier (state, existing)) {
            states.put(here, state);
            return true;
        } else {
            // !! turn restriction code removed
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.