View Javadoc
1   package org.opentrafficsim.road.gtu.lane.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.lane.perception.mental.Fuller.BehavioralAdaptation;
10  
11  /**
12   * Behavioral adaptation which reduces the desired speed to reduce task-demand.
13   * <p>
14   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
16   * <p>
17   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 5 apr. 2018 <br>
18   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
19   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
20   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
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", "max desired speed scaling", 1.0, POSITIVEZERO);
28  
29      /** Base value for the desired speed. */
30      private Double fSpeed0;
31  
32      /** {@inheritDoc} */
33      @Override
34      public void adapt(final Parameters parameters, final double taskSaturation) throws ParameterException
35      {
36          if (this.fSpeed0 == null)
37          {
38              this.fSpeed0 = parameters.getParameter(ParameterTypes.FSPEED);
39          }
40          double eps = parameters.getParameter(Fuller.TS) - parameters.getParameter(Fuller.TS_CRIT);
41          eps = eps < 0.0 ? 0.0 : (eps > 1.0 ? 1.0 : eps);
42          double factor = 1.0 - parameters.getParameter(BETA_V0) * eps;
43          parameters.setParameter(ParameterTypes.FSPEED, this.fSpeed0 * factor);
44      }
45  
46  }