1 package org.opentrafficsim.road.gtu.lane.tactical.lmrs;
2
3 import java.util.function.Predicate;
4
5 import org.djunits.value.vdouble.scalar.Length;
6 import org.djunits.value.vdouble.scalar.Speed;
7 import org.opentrafficsim.base.parameters.ParameterException;
8 import org.opentrafficsim.base.parameters.Parameters;
9 import org.opentrafficsim.core.gtu.GtuException;
10 import org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException;
11 import org.opentrafficsim.core.network.Link;
12 import org.opentrafficsim.core.network.route.Route;
13 import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
14 import org.opentrafficsim.road.gtu.lane.perception.FilteredIterable;
15 import org.opentrafficsim.road.gtu.lane.perception.LanePerception;
16 import org.opentrafficsim.road.gtu.lane.perception.RelativeLane;
17 import org.opentrafficsim.road.gtu.lane.perception.headway.HeadwayLaneBasedObject;
18 import org.opentrafficsim.road.gtu.lane.plan.operational.SimpleOperationalPlan;
19 import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel;
20 import org.opentrafficsim.road.network.speed.SpeedLimitInfo;
21
22
23
24
25
26
27
28
29
30
31 public interface AccelerationIncentive
32 {
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 void accelerate(SimpleOperationalPlan simplePlan, RelativeLane lane, Length mergeDistance, LaneBasedGtu gtu,
50 LanePerception perception, CarFollowingModel carFollowingModel, Speed speed, Parameters params,
51 SpeedLimitInfo speedLimitInfo) throws OperationalPlanException, ParameterException, GtuException;
52
53
54
55
56
57
58
59
60
61 default <T extends HeadwayLaneBasedObject> Iterable<T> onRoute(final Iterable<T> iterable, final LaneBasedGtu gtu)
62 {
63 Route route = gtu.getStrategicalPlanner().getRoute();
64 return new FilteredIterable<>(iterable, new Predicate<T>()
65 {
66
67 @Override
68 public boolean test(final T t)
69 {
70 if (route == null)
71 {
72 return true;
73 }
74 Link link = t.getLane().getLink();
75 if (route.contains(link.getStartNode()) && route.contains(link.getEndNode()))
76 {
77 return route.indexOf(link.getEndNode()) - route.indexOf(link.getStartNode()) == 1;
78 }
79 return false;
80 }
81 });
82 }
83
84 }