ParameterTypes.java

  1. package org.opentrafficsim.base.parameters;

  2. import org.djunits.unit.LengthUnit;
  3. import org.djunits.unit.SpeedUnit;
  4. import org.djunits.value.vdouble.scalar.Acceleration;
  5. import org.djunits.value.vdouble.scalar.Duration;
  6. import org.djunits.value.vdouble.scalar.Length;
  7. import org.djunits.value.vdouble.scalar.Speed;
  8. import org.djutils.exceptions.Throw;
  9. import org.opentrafficsim.base.parameters.constraint.ConstraintInterface;

  10. /**
  11.  * Predefined list of common parameter types.
  12.  * <p>
  13.  * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  14.  * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
  15.  * <p>
  16.  * @version $Revision$, $LastChangedDate$, by $Author$, initial version Apr 13, 2016 <br>
  17.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  18.  * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  19.  */
  20. @SuppressWarnings("checkstyle:finalclass")
  21. public class ParameterTypes implements ConstraintInterface
  22. {
  23.     /** Do not create instance. */
  24.     private ParameterTypes()
  25.     {
  26.         //
  27.     }

  28.     /** Fixed model time step. */
  29.     public static final ParameterTypeDuration DT;

  30.     /** Car-following stopping distance. */
  31.     public static final ParameterTypeLength S0;

  32.     /** Maximum (desired) car-following acceleration. */
  33.     public static final ParameterTypeAcceleration A;

  34.     /** Maximum comfortable car-following deceleration. */
  35.     public static final ParameterTypeAcceleration B;

  36.     /** Maximum critical deceleration, e.g. stop/go at traffic light. */
  37.     public static final ParameterTypeAcceleration BCRIT;

  38.     /** Maximum adjustment deceleration, e.g. when speed limit drops. */
  39.     public static final ParameterTypeAcceleration B0;

  40.     /** Current car-following headway. */
  41.     public static final ParameterTypeDuration T;

  42.     /** Minimum car-following headway. */
  43.     public static final ParameterTypeDuration TMIN;

  44.     /** Maximum car-following headway. */
  45.     public static final ParameterTypeDuration TMAX;

  46.     /** Headway relaxation time. */
  47.     public static final ParameterTypeDuration TAU;

  48.     /** Look-ahead time for mandatory lane changes. */
  49.     public static final ParameterTypeDuration T0;

  50.     /** Look-ahead distance. */
  51.     public static final ParameterTypeLength LOOKAHEAD;

  52.     /** Look-back distance. */
  53.     public static final ParameterTypeLength LOOKBACK;

  54.     // TODO remove LOOKBACKOLD
  55.     /** Look-back distance, for old MOBIL code only. */
  56.     public static final ParameterTypeLength LOOKBACKOLD;

  57.     /** Speed limit adherence factor. */
  58.     public static final ParameterTypeDouble FSPEED;

  59.     /** Speed threshold below which traffic is considered congested. */
  60.     public static final ParameterTypeSpeed VCONG;

  61.     /** Regular lane change duration. */
  62.     public static final ParameterTypeDuration LCDUR;

  63.     /** Length of mental map ahead. */
  64.     public static final ParameterTypeLength PERCEPTION;

  65.     /** Reaction time. */
  66.     public static final ParameterTypeDuration TR;

  67.     static
  68.     {

  69.         DT = new ParameterTypeDuration("dt", "Fixed model time step", Duration.instantiateSI(0.5), POSITIVE);

  70.         S0 = new ParameterTypeLength("s0", "Car-following stopping distance", Length.instantiateSI(3.0), POSITIVE);

  71.         A = new ParameterTypeAcceleration("a", "Maximum (desired) car-following acceleration", Acceleration.instantiateSI(
  72.             1.25), POSITIVE);

  73.         B = new ParameterTypeAcceleration("b", "Maximum comfortable car-following deceleration", Acceleration.instantiateSI(
  74.             2.09), POSITIVE)
  75.         {
  76.             /** */
  77.             private static final long serialVersionUID = 20170203L;

  78.             @Override
  79.             public void check(final Acceleration value, final Parameters params) throws ParameterException
  80.             {
  81.                 Acceleration b0 = params.getParameterOrNull(B0);
  82.                 Throw.when(b0 != null && value.si <= b0.si, ParameterException.class, "Value of b is below or equal to b0");
  83.                 Acceleration bCrit = params.getParameterOrNull(BCRIT);
  84.                 Throw.when(bCrit != null && value.si >= bCrit.si, ParameterException.class,
  85.                     "Value of b is above or equal to bCrit");
  86.             }
  87.         };

  88.         BCRIT = new ParameterTypeAcceleration("bCrit", "Maximum critical deceleration, e.g. stop/go at traffic light",
  89.             Acceleration.instantiateSI(3.5), POSITIVE)
  90.         {
  91.             /** */
  92.             private static final long serialVersionUID = 20170203L;

  93.             @Override
  94.             public void check(final Acceleration value, final Parameters params) throws ParameterException
  95.             {
  96.                 Acceleration b0 = params.getParameterOrNull(B0);
  97.                 Throw.when(b0 != null && value.si <= b0.si, ParameterException.class,
  98.                     "Value of bCrit is below or equal to b0");
  99.                 Acceleration b = params.getParameterOrNull(B);
  100.                 Throw.when(b != null && value.si <= b.si, ParameterException.class, "Value of bCrit is below or equal to b");
  101.             }
  102.         };

  103.         B0 = new ParameterTypeAcceleration("b0", "Maximum adjustment deceleration, e.g. when speed limit drops", Acceleration
  104.             .instantiateSI(0.5), POSITIVE)
  105.         {
  106.             /** */
  107.             private static final long serialVersionUID = 20170203L;

  108.             @Override
  109.             public void check(final Acceleration value, final Parameters params) throws ParameterException
  110.             {
  111.                 Acceleration b = params.getParameterOrNull(B);
  112.                 Throw.when(b != null && value.si >= b.si, ParameterException.class, "Value of b0 is above or equal to b");
  113.                 Acceleration bCrit = params.getParameterOrNull(BCRIT);
  114.                 Throw.when(bCrit != null && value.si >= bCrit.si, ParameterException.class,
  115.                     "Value of b0 is above or equal to bCrit");
  116.             }
  117.         };

  118.         T = new ParameterTypeDuration("T", "Current car-following headway", Duration.instantiateSI(1.2), POSITIVE);

  119.         TMIN = new ParameterTypeDuration("Tmin", "Minimum car-following headway", Duration.instantiateSI(0.56), POSITIVE)
  120.         {
  121.             /** */
  122.             private static final long serialVersionUID = 20160400L;

  123.             @Override
  124.             public void check(final Duration value, final Parameters params) throws ParameterException
  125.             {
  126.                 Duration tMax = params.getParameterOrNull(TMAX);
  127.                 Throw.when(tMax != null && value.si >= tMax.si, ParameterException.class,
  128.                     "Value of Tmin is above or equal to Tmax");
  129.             }
  130.         };

  131.         TMAX = new ParameterTypeDuration("Tmax", "Maximum car-following headway", Duration.instantiateSI(1.2), POSITIVE)
  132.         {
  133.             /** */
  134.             private static final long serialVersionUID = 20160400L;

  135.             @Override
  136.             public void check(final Duration value, final Parameters params) throws ParameterException
  137.             {
  138.                 Duration tMin = params.getParameterOrNull(TMIN);
  139.                 Throw.when(tMin != null && value.si <= tMin.si, ParameterException.class,
  140.                     "Value of Tmax is below or equal to Tmin");
  141.             }
  142.         };

  143.         TAU = new ParameterTypeDuration("tau", "Headway relaxation time", Duration.instantiateSI(25.0), POSITIVE);

  144.         T0 = new ParameterTypeDuration("t0", "Look-ahead time for mandatory lane changes", Duration.instantiateSI(43.0),
  145.             POSITIVE);

  146.         LOOKAHEAD = new ParameterTypeLength("Look-ahead", "Look-ahead distance", Length.instantiateSI(295.0), POSITIVE);

  147.         LOOKBACK = new ParameterTypeLength("Look-back", "Look-back distance", Length.instantiateSI(200.0), POSITIVE);

  148.         LOOKBACKOLD = new ParameterTypeLength("Look-back old", "Look-back distance (old version for MOBIL code)", Length
  149.             .instantiateSI(-200.0), NEGATIVE);

  150.         FSPEED = new ParameterTypeDouble("fSpeed", "Speed limit adherence factor", 1.0, POSITIVE);

  151.         VCONG = new ParameterTypeSpeed("vCong", "Speed threshold below which traffic is considered congested", new Speed(60,
  152.             SpeedUnit.KM_PER_HOUR), POSITIVE);

  153.         LCDUR = new ParameterTypeDuration("lcDur", "Regular lane change duration", Duration.instantiateSI(3.0), POSITIVE);

  154.         PERCEPTION = new ParameterTypeLength("perception", "Mental map length", new Length(2.0, LengthUnit.KILOMETER),
  155.             POSITIVE);

  156.         TR = new ParameterTypeDuration("Tr", "Reaction time", Duration.instantiateSI(0.5), POSITIVEZERO);

  157.     }

  158. }