1 package org.opentrafficsim.road.gtu.lane.tactical.lmrs;
2
3 import org.opentrafficsim.base.parameters.ParameterException;
4 import org.opentrafficsim.base.parameters.ParameterTypeDouble;
5 import org.opentrafficsim.base.parameters.Parameters;
6 import org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException;
7 import org.opentrafficsim.road.gtu.lane.perception.LanePerception;
8 import org.opentrafficsim.road.gtu.lane.perception.RelativeLane;
9 import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel;
10 import org.opentrafficsim.road.gtu.lane.tactical.util.lmrs.Desire;
11 import org.opentrafficsim.road.gtu.lane.tactical.util.lmrs.LmrsParameters;
12 import org.opentrafficsim.road.gtu.lane.tactical.util.lmrs.VoluntaryIncentive;
13
14
15
16
17
18
19
20
21
22
23
24 public class IncentiveKeep implements VoluntaryIncentive
25 {
26
27
28 protected static final ParameterTypeDouble DFREE = LmrsParameters.DFREE;
29
30
31 @Override
32 public final Desire determineDesire(final Parameters parameters, final LanePerception perception,
33 final CarFollowingModel carFollowingModel, final Desire mandatoryDesire, final Desire voluntaryDesire)
34 throws ParameterException, OperationalPlanException
35 {
36 if (mandatoryDesire.right() < 0 || voluntaryDesire.right() < 0
37 || !perception.getLaneStructure().exists(RelativeLane.RIGHT))
38 {
39
40 return new Desire(0, 0);
41 }
42
43 return new Desire(0, parameters.getParameter(DFREE));
44 }
45
46
47 @Override
48 public final String toString()
49 {
50 return "IncentiveKeep";
51 }
52
53 }