Class PercentSpeedCap
java.lang.Object
rgu.transport.util.PercentSpeedCap
Can apply a speed cap and default speed to a graph. The maximum speed is specified for a predicate, and all edges for which one or both vertices test true will be limited to the given speed.
The maximum speed edges are set to the cap if the original value was over, and all other edges are reduced by the same percentage. If the original maximum in the graph was under the stated maximum, then no edges are reduced. Any edges which did have any specified speed will be set to the minimum resulting speed of any other edge.
Edges which are not inside the predicate will be capped to a maximum speed of the minimum speed within any of the predicates.
If predicates overlap, then the first one added takes priority.
-
Constructor Summary
ConstructorsConstructorDescriptionPercentSpeedCap(Graph<GeoLocation, RoadEdge> graph) Creates an instance of percent speed cap. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(String name, Predicate<GeoLocation> predicate, Speed maximum) Adds a predicate with a speed cap.apply()Applies the speed cap to the given graph, returning a new speed-capped graph.apply(boolean verbose) Applies the speed cap to the given graph, returning a new speed-capped graph.
-
Constructor Details
-
PercentSpeedCap
Creates an instance of percent speed cap.- Parameters:
graph- the graph, not null
-
-
Method Details
-
add
Adds a predicate with a speed cap.- Parameters:
name- the name, not empty, not null, uniquepredicate- the predicate for vertices, not nullmaximum- the maximum for the predicate, >= 0
-
apply
Applies the speed cap to the given graph, returning a new speed-capped graph.- Returns:
- the speed-capped graph
-
apply
Applies the speed cap to the given graph, returning a new speed-capped graph.- Parameters:
verbose- if true, extra information will be printed to STDOUT.- Returns:
- the speed-capped graph
-