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