1 package org.opentrafficsim.road.gtu.lane.perception.mental;
2
3 import org.opentrafficsim.base.parameters.ParameterException;
4 import org.opentrafficsim.base.parameters.ParameterTypeDouble;
5 import org.opentrafficsim.base.parameters.Parameters;
6
7 /**
8 * Super class for behavioral adaptations using a factor based task saturation. The factor is defined as max(1, 1 + beta * (ts -
9 * tsCrit)), where beta is the behavioral adaptation scaling, ts is task saturation, and tsCrit is the critical task saturation.
10 * The latter does not need to be specified, in which case a value of 1 is used.
11 * <p>
12 * Copyright (c) 2024-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
14 * </p>
15 * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
16 */
17 public abstract class FactorAdaptation implements BehavioralAdaptation
18 {
19
20 /**
21 * Returns factor for behavioral adaptation. This is given by factor = max(1, 1 + beta * (ts - tsCrit)), where ts is the
22 * task saturation and tsCrit is the critical task saturation (assumed 1.0 if not given in the parameters). For behavioral
23 * adaptations that reduce something the effective factor can be used as 1.0 / factor.
24 * @param parameters parameters
25 * @param beta behavioral adaptation scaling parameter, assumed non-negative
26 * @return factor for behavioral adaptation
27 * @throws ParameterException if a used parameter (other than tsCrit) is not given
28 */
29 protected double getFactor(final Parameters parameters, final ParameterTypeDouble beta) throws ParameterException
30 {
31 double ts = parameters.getParameter(Fuller.TS);
32 double tsCrit = parameters.contains(SumFuller.TS_CRIT) ? parameters.getParameter(SumFuller.TS_CRIT) : 1.0;
33 return ts < tsCrit ? 1.0 : 1.0 + parameters.getParameter(beta) * (ts - tsCrit);
34 }
35
36 }