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.djunits.value.vdouble.scalar.Duration;
6   import org.opentrafficsim.base.parameters.ParameterException;
7   import org.opentrafficsim.base.parameters.ParameterTypeDouble;
8   import org.opentrafficsim.base.parameters.ParameterTypes;
9   import org.opentrafficsim.base.parameters.Parameters;
10  import org.opentrafficsim.road.gtu.lane.perception.mental.Fuller.BehavioralAdaptation;
11  
12  /**
13   * Behavioral adaptation which increases the desired headway to reduce task-demand.
14   * <p>
15   * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
16   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
17   * <p>
18   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 3 apr. 2018 <br>
19   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
20   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
21   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
22   */
23  public class AdaptationHeadway implements BehavioralAdaptation
24  {
25  
26      /** Parameter for desired headway scaling. */
27      public static final ParameterTypeDouble BETA_T =
28              new ParameterTypeDouble("Beta_T", "max headway scaling", 1.0, POSITIVEZERO);
29  
30      /** Base value for the minimum desired headway. */
31      private Duration t0Min;
32  
33      /** Base value for the maximum desired headway. */
34      private Duration t0Max;
35  
36      /** {@inheritDoc} */
37      @Override
38      public void adapt(final Parameters parameters, final double taskSaturation) throws ParameterException
39      {
40          if (this.t0Min == null)
41          {
42              this.t0Min = parameters.getParameterOrNull(ParameterTypes.TMIN);
43              this.t0Max = parameters.getParameterOrNull(ParameterTypes.TMAX);
44          }
45          double eps = parameters.getParameter(Fuller.TS) - parameters.getParameter(Fuller.TS_CRIT);
46          eps = eps < 0.0 ? 0.0 : (eps > 1.0 ? 1.0 : eps);
47          double factor = 1.0 + parameters.getParameter(BETA_T) * eps;
48          parameters.setParameter(ParameterTypes.TMIN, this.t0Min.multiplyBy(factor));
49          parameters.setParameter(ParameterTypes.TMAX, this.t0Max.multiplyBy(factor));
50      }
51  
52  }