1 package org.opentrafficsim.road.gtu.lane.tactical.lmrs;
2
3 import org.djunits.value.vdouble.scalar.Acceleration;
4 import org.djunits.value.vdouble.scalar.Speed;
5 import org.opentrafficsim.base.parameters.ParameterException;
6 import org.opentrafficsim.base.parameters.ParameterTypeAcceleration;
7 import org.opentrafficsim.base.parameters.ParameterTypeSpeed;
8 import org.opentrafficsim.base.parameters.ParameterTypes;
9 import org.opentrafficsim.base.parameters.Parameters;
10 import org.opentrafficsim.core.gtu.GTUException;
11 import org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException;
12 import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
13 import org.opentrafficsim.road.gtu.lane.perception.LanePerception;
14 import org.opentrafficsim.road.gtu.lane.perception.PerceptionCollectable;
15 import org.opentrafficsim.road.gtu.lane.perception.RelativeLane;
16 import org.opentrafficsim.road.gtu.lane.perception.categories.NeighborsPerception;
17 import org.opentrafficsim.road.gtu.lane.perception.categories.TrafficPerception;
18 import org.opentrafficsim.road.gtu.lane.perception.headway.HeadwayGTU;
19 import org.opentrafficsim.road.gtu.lane.plan.operational.SimpleOperationalPlan;
20 import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel;
21 import org.opentrafficsim.road.gtu.lane.tactical.util.CarFollowingUtil;
22 import org.opentrafficsim.road.network.speed.SpeedLimitInfo;
23
24
25
26
27
28
29
30
31
32
33
34 public class AccelerationNoRightOvertake implements AccelerationIncentive
35 {
36
37
38 public static final ParameterTypeSpeed VCONG = ParameterTypes.VCONG;
39
40
41 public static final ParameterTypeAcceleration B0 = ParameterTypes.B0;
42
43
44 @Override
45 public void accelerate(final SimpleOperationalPlan simplePlan, final RelativeLane lane, final LaneBasedGTU gtu,
46 final LanePerception perception, final CarFollowingModel carFollowingModel, final Speed speed,
47 final Parameters params, final SpeedLimitInfo speedLimitInfo)
48 throws OperationalPlanException, ParameterException, GTUException
49 {
50
51 if (lane.isCurrent() && perception.getLaneStructure().getExtendedCrossSection().contains(RelativeLane.LEFT))
52 {
53 Speed vCong = params.getParameter(VCONG);
54 if (perception.getPerceptionCategory(TrafficPerception.class).getSpeed(RelativeLane.CURRENT).si > vCong.si)
55 {
56 PerceptionCollectable<HeadwayGTU, LaneBasedGTU> leaders =
57 perception.getPerceptionCategory(NeighborsPerception.class).getLeaders(RelativeLane.LEFT);
58 if (!leaders.isEmpty())
59 {
60 HeadwayGTU leader = leaders.first();
61 Speed desiredSpeed = perception.getGtu().getDesiredSpeed();
62 if (desiredSpeed.si > leader.getSpeed().si)
63 {
64 Acceleration b0 = params.getParameter(B0);
65
66 Acceleration a =
67 CarFollowingUtil.followSingleLeader(carFollowingModel, params, speed, speedLimitInfo, leader);
68 simplePlan.minimizeAcceleration(a.si < -b0.si ? b0.neg() : a);
69 }
70 }
71 }
72 }
73 }
74
75 }