1 package org.opentrafficsim.road.gtu.lane.tactical.following;
2
3 import java.util.SortedMap;
4
5 import org.djunits.unit.AccelerationUnit;
6 import org.djunits.value.vdouble.scalar.Acceleration;
7 import org.djunits.value.vdouble.scalar.Length;
8 import org.djunits.value.vdouble.scalar.Speed;
9 import org.opentrafficsim.core.gtu.behavioralcharacteristics.BehavioralCharacteristics;
10 import org.opentrafficsim.core.gtu.behavioralcharacteristics.ParameterException;
11 import org.opentrafficsim.core.gtu.behavioralcharacteristics.ParameterTypes;
12
13
14
15
16
17
18
19
20
21
22 public class IDMPlusMulti extends AbstractIDM
23 {
24
25
26 @Override
27 public final String getName()
28 {
29 return "IDM+multi";
30 }
31
32
33 @Override
34 public final String getLongName()
35 {
36 return "Intelligent Driver Model+ with multi-leader anticipation.";
37 }
38
39
40 @Override
41 protected final Acceleration combineInteractionTerm(final Acceleration aFree,
42 final BehavioralCharacteristics behavioralCharacteristics, final Speed speed, final Speed desiredSpeed,
43 final Length desiredHeadway, final SortedMap<Length, Speed> leaders) throws ParameterException
44 {
45 Acceleration a = behavioralCharacteristics.getParameter(ParameterTypes.A);
46 double aIntMulti = Double.POSITIVE_INFINITY;
47 int i = 1;
48 double cumulVehicleLengths = 0;
49 for (Length headway : leaders.keySet())
50 {
51
52
53 double sRatio =
54 dynamicDesiredHeadway(behavioralCharacteristics, speed, desiredHeadway.multiplyBy(i), leaders.get(headway)).si
55 / (headway.si - cumulVehicleLengths);
56 double aIntSingle = a.si * (1 - sRatio * sRatio);
57 aIntMulti = aIntMulti < aIntSingle ? aIntMulti : aIntSingle;
58 i++;
59 cumulVehicleLengths += 0;
60 }
61 return new Acceleration(aIntMulti < aFree.si ? aIntMulti : aFree.si, AccelerationUnit.SI);
62 }
63
64 }