View Javadoc
1   package org.opentrafficsim.core.gtu.behavioralcharacteristics;
2   
3   import static org.opentrafficsim.core.gtu.behavioralcharacteristics.AbstractParameterType.Check.NEGATIVE;
4   import static org.opentrafficsim.core.gtu.behavioralcharacteristics.AbstractParameterType.Check.POSITIVE;
5   import static org.opentrafficsim.core.gtu.behavioralcharacteristics.AbstractParameterType.Check.POSITIVEZERO;
6   
7   import org.djunits.unit.AccelerationUnit;
8   import org.djunits.unit.DurationUnit;
9   import org.djunits.unit.LengthUnit;
10  import org.djunits.unit.SpeedUnit;
11  import org.djunits.value.vdouble.scalar.Acceleration;
12  import org.djunits.value.vdouble.scalar.Duration;
13  import org.djunits.value.vdouble.scalar.Length;
14  import org.djunits.value.vdouble.scalar.Speed;
15  
16  import nl.tudelft.simulation.language.Throw;
17  
18  /**
19   * Predefined list of common parameter types.
20   * <p>
21   * Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
22   * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
23   * <p>
24   * @version $Revision$, $LastChangedDate$, by $Author$, initial version Apr 13, 2016 <br>
25   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
26   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
27   */
28  @SuppressWarnings("checkstyle:finalclass")
29  public class ParameterTypes
30  {
31      /** Do not create instance. */
32      private ParameterTypes()
33      {
34          //
35      }
36  
37      /** Fixed model time step. */
38      public static final ParameterTypeDuration DT =
39              new ParameterTypeDuration("dt", "Fixed model time step.", new Duration(0.5, DurationUnit.SI), POSITIVE);
40  
41      /** Car-following stopping distance. */
42      public static final ParameterTypeLength S0;
43  
44      /** Maximum (desired) car-following acceleration. */
45      public static final ParameterTypeAcceleration A;
46  
47      /** Maximum comfortable car-following deceleration. */
48      public static final ParameterTypeAcceleration B;
49  
50      /** Maximum critical deceleration, e.g. stop/go at traffic light. */
51      public static final ParameterTypeAcceleration BCRIT;
52  
53      /** Maximum adjustment deceleration, e.g. when speed limit drops. */
54      public static final ParameterTypeAcceleration B0;
55  
56      /** Current car-following headway. */
57      public static final ParameterTypeDuration T;
58  
59      /** Minimum car-following headway. */
60      public static final ParameterTypeDuration TMIN;
61  
62      /** Maximum car-following headway. */
63      public static final ParameterTypeDuration TMAX;
64  
65      /** Headway relaxation time. */
66      public static final ParameterTypeDuration TAU;
67  
68      /** Look-ahead time for mandatory lane changes. */
69      public static final ParameterTypeDuration T0;
70  
71      /** Look-ahead distance. */
72      public static final ParameterTypeLength LOOKAHEAD;
73  
74      /** Look-back distance. */
75      public static final ParameterTypeLength LOOKBACK;
76  
77      // TODO remove LOOKBACKOLD
78      /** Look-back distance, for old MOBIL code only. */
79      public static final ParameterTypeLength LOOKBACKOLD;
80  
81      /** Speed limit adherence factor. */
82      public static final ParameterTypeDouble FSPEED;
83  
84      /** Speed threshold below which traffic is considered congested. */
85      public static final ParameterTypeSpeed VCONG;
86  
87      /** Regular lane change duration. */
88      public static final ParameterTypeDuration LCDUR;
89  
90      /** Length of mental map ahead. */
91      public static final ParameterTypeLength PERCEPTION;
92  
93      /** Reaction time. */
94      public static final ParameterTypeDuration TR;
95  
96      static
97      {
98  
99          /** {@formatter:off} */
100 
101         S0 = new ParameterTypeLength("s0", "Car-following stopping distance.", new Length(3.0, LengthUnit.SI), POSITIVE);
102 
103         A = new ParameterTypeAcceleration("a", "Maximum (desired) car-following acceleration.", 
104             new Acceleration(1.25, AccelerationUnit.SI), POSITIVE);
105 
106         B = new ParameterTypeAcceleration("b", "Maximum comfortable car-following deceleration.", 
107             new Acceleration(2.09, AccelerationUnit.SI), POSITIVE)
108         {
109             /** */
110             private static final long serialVersionUID = 20170203L;
111 
112             public void check(final Acceleration value, final BehavioralCharacteristics bc) throws ParameterException
113             {
114                 Throw.when(bc.contains(B0) && value.si <= bc.getParameter(B0).si, ParameterException.class,
115                         "Value of b is below or equal to b0.");
116                 Throw.when(bc.contains(BCRIT) && value.si >= bc.getParameter(BCRIT).si, ParameterException.class,
117                         "Value of b is above or equal to bCrit.");
118             }
119         };
120 
121         BCRIT = new ParameterTypeAcceleration("bCrit", "Maximum critical deceleration, e.g. stop/go at traffic light.",
122             new Acceleration(3.5, AccelerationUnit.SI), POSITIVE)
123         {
124             /** */
125             private static final long serialVersionUID = 20170203L;
126 
127             public void check(final Acceleration value, final BehavioralCharacteristics bc) throws ParameterException
128             {
129                 Throw.when(bc.contains(B0) && value.si <= bc.getParameter(B0).si, ParameterException.class,
130                         "Value of bCrit is below or equal to b0.");
131                 Throw.when(bc.contains(B) && value.si <= bc.getParameter(B).si, ParameterException.class,
132                         "Value of bCrit is below or equal to b.");
133             }
134         };
135 
136         B0 = new ParameterTypeAcceleration("b0", "Maximum adjustment deceleration, e.g. when speed limit drops.",
137             new Acceleration(0.5, AccelerationUnit.SI), POSITIVE)
138             {
139                 /** */
140                 private static final long serialVersionUID = 20170203L;
141     
142                 public void check(final Acceleration value, final BehavioralCharacteristics bc) throws ParameterException
143                 {
144                     Throw.when(bc.contains(B) && value.si >= bc.getParameter(B).si, ParameterException.class,
145                             "Value of b0 is above or equal to b.");
146                     Throw.when(bc.contains(BCRIT) && value.si >= bc.getParameter(BCRIT).si, ParameterException.class,
147                             "Value of b0 is above or equal to bCrit.");
148                 }
149             };
150 
151         T = new ParameterTypeDuration("T", "Current car-following headway.", new Duration(1.2, DurationUnit.SI), POSITIVE);
152 
153         TMIN = new ParameterTypeDuration("Tmin", "Minimum car-following headway.", new Duration(0.56, DurationUnit.SI), POSITIVE)
154             {
155                 /** */
156                 private static final long serialVersionUID = 20160400L;
157 
158                 @Override
159                 public void check(final Duration value, final BehavioralCharacteristics bc) throws ParameterException
160                 {
161                     Throw.when(bc.contains(ParameterTypes.TMAX) && value.si >= bc.getParameter(ParameterTypes.TMAX).si,
162                         ParameterException.class, "Value of Tmin is above or equal to Tmax.");
163                 }
164             };
165 
166         TMAX = new ParameterTypeDuration("Tmax", "Maximum car-following headway.", new Duration(1.2, DurationUnit.SI), POSITIVE)
167         {
168             /** */
169             private static final long serialVersionUID = 20160400L;
170 
171             @Override
172             public void check(final Duration value, final BehavioralCharacteristics bc) throws ParameterException
173             {
174                 Throw.when(bc.contains(ParameterTypes.TMIN) && value.si <= bc.getParameter(ParameterTypes.TMIN).si,
175                     ParameterException.class, "Value of Tmax is below or equal to Tmin.");
176             }
177         };
178 
179         TAU = new ParameterTypeDuration("tau", "Headway relaxation time.", new Duration(25.0, DurationUnit.SI), POSITIVE);
180 
181         T0 = new ParameterTypeDuration("t0", "Look-ahead time for mandatory lane changes.", new Duration(43.0, DurationUnit.SI),
182                 POSITIVE);
183 
184         LOOKAHEAD = new ParameterTypeLength("Look-ahead", "Look-ahead distance.", new Length(295.0, LengthUnit.SI), POSITIVE);
185 
186         LOOKBACK = new ParameterTypeLength("Look-back", "Look-back distance.", new Length(200, LengthUnit.SI), POSITIVE);
187 
188         LOOKBACKOLD = new ParameterTypeLength("Look-back old", "Look-back distance (old version for MOBIL code).", 
189             new Length(-200, LengthUnit.SI), NEGATIVE);
190         
191         FSPEED = new ParameterTypeDouble("fSpeed", "Speed limit adherence factor.", 1.0, POSITIVE);
192 
193         VCONG = new ParameterTypeSpeed("vCong", "Speed threshold below which traffic is considered congested.", 
194             new Speed(60, SpeedUnit.KM_PER_HOUR), POSITIVE);
195 
196         LCDUR = new ParameterTypeDuration("lcDur", "Regular lane change duration.", new Duration(3, DurationUnit.SI), POSITIVE);
197         
198         PERCEPTION = new ParameterTypeLength("mapLength", "Mental map length", new Length(2.0, LengthUnit.KILOMETER), POSITIVE);
199         
200         TR = new ParameterTypeDuration("Tr", "Reaction time.", Duration.createSI(0.5), POSITIVEZERO);
201         
202     }
203 
204 }