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
13
14
15
16
17
18
19
20
21 public class AdaptationSpeed implements BehavioralAdaptation
22 {
23
24
25 public static final ParameterTypeDouble BETA_V0 =
26 new ParameterTypeDouble("Beta_v0", "max desired speed scaling", 1.0, POSITIVEZERO);
27
28
29 private Double fSpeed0;
30
31
32 @Override
33 public void adapt(final Parameters parameters, final double taskSaturation) throws ParameterException
34 {
35 if (this.fSpeed0 == null)
36 {
37 this.fSpeed0 = parameters.getParameter(ParameterTypes.FSPEED);
38 }
39 double eps = parameters.getParameter(Fuller.TS) - parameters.getParameter(Fuller.TS_CRIT);
40 eps = eps < 0.0 ? 0.0 : (eps > 1.0 ? 1.0 : eps);
41 double factor = 1.0 - parameters.getParameter(BETA_V0) * eps;
42 parameters.setParameter(ParameterTypes.FSPEED, this.fSpeed0 * factor);
43 }
44
45 }