View Javadoc
1   package org.opentrafficsim.road.gtu.perception.mental;
2   
3   import static org.opentrafficsim.base.parameters.constraint.NumericConstraint.POSITIVEZERO;
4   
5   import org.opentrafficsim.base.parameters.ParameterException;
6   import org.opentrafficsim.base.parameters.ParameterTypeDouble;
7   import org.opentrafficsim.base.parameters.ParameterTypes;
8   import org.opentrafficsim.base.parameters.Parameters;
9   import org.opentrafficsim.road.gtu.perception.mental.channel.AdaptationSpeedChannel;
10  
11  /**
12   * Behavioral adaptation which reduces the desired speed to reduce task-demand. This implementation applies a linear reduction
13   * based on task saturation. To use multiplicative adaptation by a standard factor see {@link AdaptationSpeedChannel}.
14   * <p>
15   * Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
16   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
17   * </p>
18   * @author Alexander Verbraeck
19   * @author Peter Knoppers
20   * @author Wouter Schakel
21   */
22  public class AdaptationSpeed implements BehavioralAdaptation
23  {
24  
25      /** Parameter for desired speed scaling. */
26      public static final ParameterTypeDouble BETA_V0 =
27              new ParameterTypeDouble("beta_v0", "Maximum adaptation desired speed scaling", 1.0, POSITIVEZERO);
28  
29      /** Base value for the desired speed. */
30      private Double fSpeed0;
31  
32      /** Base value for the desired speed relative to GTU type speed limit. */
33      private Double fSpeedGtu0;
34  
35      /**
36       * Constructor.
37       */
38      public AdaptationSpeed()
39      {
40          //
41      }
42  
43      @Override
44      public void adapt(final Parameters parameters) throws ParameterException
45      {
46          if (this.fSpeed0 == null)
47          {
48              this.fSpeed0 = parameters.getParameter(ParameterTypes.FSPEED);
49              this.fSpeedGtu0 = parameters.getParameter(ParameterTypes.FSPEED_GTU);
50          }
51          double tsCrit = parameters.getOptionalParameter(SumFuller.TS_CRIT).orElse(1.0);
52          double eps = parameters.getParameter(Fuller.TS) - tsCrit;
53          eps = eps < 0.0 ? 0.0 : (eps >= 0.999 ? 0.999 : eps);
54          double factor = 1.0 - parameters.getParameter(BETA_V0) * eps;
55          parameters.setClaimedParameter(ParameterTypes.FSPEED, this.fSpeed0 * factor, this);
56          parameters.setClaimedParameter(ParameterTypes.FSPEED_GTU, this.fSpeedGtu0 * factor, this);
57      }
58  
59  }