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
14
15
16
17
18
19
20
21
22
23 public class AdaptationHeadway implements BehavioralAdaptation
24 {
25
26
27 public static final ParameterTypeDouble BETA_T =
28 new ParameterTypeDouble("Beta_T", "max headway scaling", 1.0, POSITIVEZERO);
29
30
31 private Duration t0Min;
32
33
34 private Duration t0Max;
35
36
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 }