AdaptationSpeed.java

  1. package org.opentrafficsim.road.gtu.lane.perception.mental;

  2. import static org.opentrafficsim.base.parameters.constraint.NumericConstraint.POSITIVEZERO;

  3. import org.opentrafficsim.base.parameters.ParameterException;
  4. import org.opentrafficsim.base.parameters.ParameterTypeDouble;
  5. import org.opentrafficsim.base.parameters.ParameterTypes;
  6. import org.opentrafficsim.base.parameters.Parameters;
  7. import org.opentrafficsim.road.gtu.lane.perception.mental.Fuller.BehavioralAdaptation;

  8. /**
  9.  * Behavioral adaptation which reduces the desired speed to reduce task-demand.
  10.  * <p>
  11.  * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  12.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  13.  * </p>
  14.  * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
  15.  * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
  16.  * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
  17.  */
  18. public class AdaptationSpeed implements BehavioralAdaptation
  19. {

  20.     /** Parameter for desired speed scaling. */
  21.     public static final ParameterTypeDouble BETA_V0 =
  22.             new ParameterTypeDouble("Beta_v0", "max desired speed scaling", 1.0, POSITIVEZERO);

  23.     /** Base value for the desired speed. */
  24.     private Double fSpeed0;

  25.     @Override
  26.     public void adapt(final Parameters parameters, final double taskSaturation) throws ParameterException
  27.     {
  28.         if (this.fSpeed0 == null)
  29.         {
  30.             this.fSpeed0 = parameters.getParameter(ParameterTypes.FSPEED);
  31.         }
  32.         double eps = parameters.getParameter(Fuller.TS) - parameters.getParameter(Fuller.TS_CRIT);
  33.         eps = eps < 0.0 ? 0.0 : (eps > 1.0 ? 1.0 : eps);
  34.         double factor = 1.0 - parameters.getParameter(BETA_V0) * eps;
  35.         parameters.setParameter(ParameterTypes.FSPEED, this.fSpeed0 * factor);
  36.     }

  37. }