1 package org.opentrafficsim.road.gtu.lane.perception.mental;
2
3 import org.djunits.value.vdouble.scalar.Duration;
4 import org.opentrafficsim.base.parameters.ParameterException;
5 import org.opentrafficsim.base.parameters.Parameters;
6 import org.opentrafficsim.core.dsol.OtsSimulatorInterface;
7 import org.opentrafficsim.core.gtu.GtuException;
8 import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
9 import org.opentrafficsim.road.gtu.lane.perception.LanePerception;
10
11
12
13
14 public class ExponentialTask extends AbstractTask
15 {
16
17 private final double initialTaskDemand;
18
19
20 private final double additionalTaskDemand;
21
22
23 private final Duration tau;
24
25
26 private final double start;
27
28
29
30
31
32
33
34
35
36 public ExponentialTask(final String id, final double initialTaskDemand, final double finalTaskDemand, final Duration tau,
37 final OtsSimulatorInterface simulator)
38 {
39 super(id);
40 this.initialTaskDemand = initialTaskDemand;
41 this.additionalTaskDemand = finalTaskDemand - initialTaskDemand;
42 this.tau = tau;
43 this.start = simulator.getSimulatorTime().si;
44 }
45
46
47 @Override
48 public double calculateTaskDemand(final LanePerception perception, final LaneBasedGtu gtu, final Parameters parameters)
49 throws ParameterException, GtuException
50 {
51 double t = gtu.getSimulator().getSimulatorTime().si - this.start;
52 return this.initialTaskDemand + this.additionalTaskDemand * (1.0 - Math.exp(-t / this.tau.si));
53 }
54
55 }