LmrsParameters.java

  1. package org.opentrafficsim.road.gtu.lane.tactical.util.lmrs;

  2. import org.djunits.unit.SpeedUnit;
  3. import org.djunits.value.vdouble.scalar.Speed;
  4. import org.djutils.exceptions.Throw;
  5. import org.opentrafficsim.base.parameters.ParameterException;
  6. import org.opentrafficsim.base.parameters.ParameterTypeDouble;
  7. import org.opentrafficsim.base.parameters.ParameterTypeSpeed;
  8. import org.opentrafficsim.base.parameters.Parameters;
  9. import org.opentrafficsim.base.parameters.constraint.ConstraintInterface;

  10. /**
  11.  * Interface with LMRS parameters.
  12.  * <p>
  13.  * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  14.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  15.  * </p>
  16.  * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
  17.  * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
  18.  * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
  19.  */
  20. @SuppressWarnings("checkstyle:interfaceistype")
  21. public interface LmrsParameters
  22. {

  23.     /** Free lane change desire threshold. */
  24.     // @docs/06-behavior/parameters.md
  25.     ParameterTypeDouble DFREE =
  26.             new ParameterTypeDouble("dFree", "Free lane change desire threshold", 0.365, ConstraintInterface.UNITINTERVAL)
  27.             {
  28.                 /** */
  29.                 private static final long serialVersionUID = 20160413L;

  30.                 /** {@inheritDoc} */
  31.                 @Override
  32.                 public void check(final Double value, final Parameters params) throws ParameterException
  33.                 {
  34.                     // @docs/06-behavior/parameters.md
  35.                     Double dSync = params.getParameterOrNull(DSYNC);
  36.                     Throw.when(dSync != null && value >= dSync, ParameterException.class,
  37.                             "Value of dFree is above or equal to dSync.");
  38.                     // @end
  39.                     Double dCoop = params.getParameterOrNull(DCOOP);
  40.                     Throw.when(dCoop != null && value >= dCoop, ParameterException.class,
  41.                             "Value of dFree is above or equal to dCoop.");
  42.                 }
  43.             };

  44.     /** Synchronized lane change desire threshold. */
  45.     // @docs/06-behavior/parameters.md
  46.     ParameterTypeDouble DSYNC = new ParameterTypeDouble("dSync", "Synchronized lane change desire threshold", 0.577,
  47.             ConstraintInterface.UNITINTERVAL)
  48.     {
  49.         /** */
  50.         private static final long serialVersionUID = 20160413L;

  51.         /** {@inheritDoc} */
  52.         @Override
  53.         public void check(final Double value, final Parameters params) throws ParameterException
  54.         {
  55.             // @docs/06-behavior/parameters.md
  56.             Double dFree = params.getParameterOrNull(DFREE);
  57.             Throw.when(dFree != null && value <= dFree, ParameterException.class, "Value of dSync is below or equal to dFree.");
  58.             // @end
  59.             Double dCoop = params.getParameterOrNull(DCOOP);
  60.             Throw.when(dCoop != null && value >= dCoop, ParameterException.class, "Value of dSync is above or equal to dCoop.");
  61.         }
  62.     };

  63.     /** Cooperative lane change desire threshold. */
  64.     ParameterTypeDouble DCOOP = new ParameterTypeDouble("dCoop", "Cooperative lane change desire threshold", 0.788,
  65.             ConstraintInterface.UNITINTERVAL)
  66.     {
  67.         /** */
  68.         private static final long serialVersionUID = 20160413L;

  69.         /** {@inheritDoc} */
  70.         @Override
  71.         public void check(final Double value, final Parameters params) throws ParameterException
  72.         {
  73.             Double dFree = params.getParameterOrNull(DFREE);
  74.             Throw.when(dFree != null && value <= dFree, ParameterException.class, "Value of dCoop is below or equal to dFree.");
  75.             Double dSync = params.getParameterOrNull(DSYNC);
  76.             Throw.when(dSync != null && value <= dSync, ParameterException.class, "Value of dCoop is below or equal to dSync.");
  77.         }
  78.     };

  79.     /** Current left lane change desire. */
  80.     ParameterTypeDouble DLEFT = new ParameterTypeDouble("dLeft", "Left lane change desire", 0.0);

  81.     /** Current right lane change desire. */
  82.     ParameterTypeDouble DRIGHT = new ParameterTypeDouble("dRight", "Right lane change desire", 0.0);

  83.     /** Lane change desire of current lane change. */
  84.     ParameterTypeDouble DLC = new ParameterTypeDouble("dLaneChange", "Desire of current lane change", 0.0);

  85.     /** Anticipation speed difference at full lane change desired. */
  86.     ParameterTypeSpeed VGAIN = new ParameterTypeSpeed("vGain", "Anticipation speed difference at full lane change desire",
  87.             new Speed(69.6, SpeedUnit.KM_PER_HOUR), ConstraintInterface.POSITIVE);

  88.     /** Socio-speed sensitivity parameter. */
  89.     ParameterTypeDouble SOCIO =
  90.             new ParameterTypeDouble("socio", "Sensitivity level for speed of others", 1.0, ConstraintInterface.UNITINTERVAL);

  91. }