public class InterleavedBidirectionalHeuristic extends Object implements RemainingWeightHeuristic
doSomeWork()
method. During the main graph search, this
heuristic estimates remaining weights of vertices by returning the lower bound weights at
vertices found during the heuristic initialization and doSomeWork method.
The limits encountered are currently either the RoutingRequest.maxWalkDistance
or the
RoutingRequest.maxPreTransitTime
. The maxWalkDistance currently applies to both walking
and bicycling. When traversing the network in a car, the maxWalkDistance is not incremented.
To mask off excessive travel by car, the maxPreTransitTime is used as a limiter. However for
driving a car after using transit (for example with either a TNC, car rental or ride and kiss)
a limitation is added in streetSearch(org.opentripplanner.routing.core.RoutingRequest, boolean, long)
to stop searching
through the graph once the origin has been found.
In order for this heuristic to return the proper estimated weights during the main graph search,
it must be sensitive to the current mode of the current state in the main graph search. For
example, in Park and Ride searches, the initialization of the heuristic will have explored many
more vertices while driving compared to the number of vertices explored by walking from the
origin/destination. Therefore in the
estimateRemainingWeight(org.opentripplanner.routing.core.State)
method, a mode-specific weight
is returned when a non-transit vertex is being evaluated.
Shown below are a few visualizations of what the heuristic will do in various searches.
Key:
O = origin vertex
D = destination vertex
W = reachable by walking up to maxWalkDistance
C = reachable by car up to the maxPreTransitTime
B = reachable by car or walking
- = vertices unreachable by either mode
In a simple TRANSIT,WALK search, only the vertices within walking distance are marked as
reachable by the heuristic.
----------------
----WWW-----WWW-
----WOW-----WDW-
----WWW-----WWW-
----------------
In a TRANSIT,WALK,CAR (park and ride) search, there will be vertices reachable by both walking
and driving, some only by walking and some only reachable by driving. The park and ride search
does not allow driving after transit, so the vertices around the destination are only reachable
by walking.
----CCC---------
---CBBBC----WWW-
---CBOWCC---WDW-
---CBWWCC---WWW-
----CCCC--------
In a TRANSIT,WALK,CAR_HAIL (transit + TNC) search, there are many more vertices explored while
searching from the destination in this current implementation. The preTransitVertices may still
look about the same as the above graphic, but the postTransitVertices could look as follows:
--------CCCCCCC-
------CCCCCCBBBC
-----OCCCC--WDBC
------CCCCC-BWBC
-------CCCCCCCCC
This heuristic is espeically useful for large graphs, but could be turned off entirely for small
graphs.Constructor and Description |
---|
InterleavedBidirectionalHeuristic() |
Modifier and Type | Method and Description |
---|---|
void |
doSomeWork()
Move backward N steps through the transit network.
|
double |
estimateRemainingWeight(State s)
This function supplies the main search with an (under)estimate of the remaining path weight to the target.
|
void |
initialize(RoutingRequest request,
long abortTime)
Before the main search begins, the heuristic must search on the streets around the origin and destination.
|
void |
reset()
Reset any cached data in the heuristic, before reuse in a search with the same destination.
|
public void initialize(RoutingRequest request, long abortTime)
initialize
in interface RemainingWeightHeuristic
abortTime
- time since the Epoch in milliseconds at which we should bail out of initialization,
or Long.MAX_VALUE for no limit.public double estimateRemainingWeight(State s)
estimateRemainingWeight
in interface RemainingWeightHeuristic
public void reset()
RemainingWeightHeuristic
reset
in interface RemainingWeightHeuristic
public void doSomeWork()
doSomeWork
in interface RemainingWeightHeuristic
Copyright © 2019. All rights reserved.