1 package org.opentrafficsim.road.gtu.lane.tactical.lmrs;
2
3 import java.util.LinkedHashSet;
4
5 import org.djutils.immutablecollections.Immutable;
6 import org.djutils.immutablecollections.ImmutableLinkedHashSet;
7 import org.djutils.immutablecollections.ImmutableSet;
8 import org.opentrafficsim.base.parameters.ParameterTypeClassList;
9 import org.opentrafficsim.base.parameters.constraint.ClassCollectionConstraint;
10 import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
11 import org.opentrafficsim.road.gtu.lane.perception.LanePerception;
12 import org.opentrafficsim.road.gtu.lane.tactical.AbstractLaneBasedTacticalPlanner;
13 import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel;
14 import org.opentrafficsim.road.gtu.lane.tactical.util.lmrs.MandatoryIncentive;
15 import org.opentrafficsim.road.gtu.lane.tactical.util.lmrs.VoluntaryIncentive;
16
17
18
19
20
21
22
23
24
25
26
27 public abstract class AbstractIncentivesTacticalPlanner extends AbstractLaneBasedTacticalPlanner
28 {
29
30
31 private static final long serialVersionUID = 20190731L;
32
33
34
35
36
37
38
39 public AbstractIncentivesTacticalPlanner(final CarFollowingModel carFollowingModel, final LaneBasedGTU gtu,
40 final LanePerception lanePerception)
41 {
42 super(carFollowingModel, gtu, lanePerception);
43 }
44
45
46 public static final ParameterTypeClassList<MandatoryIncentive> MANDATORY = new ParameterTypeClassList<>("man.incent.",
47 "Mandatory lane-change incentives.", ParameterTypeClassList.getValueClass(MandatoryIncentive.class));
48
49
50 public static final ParameterTypeClassList<VoluntaryIncentive> VOLUNTARY = new ParameterTypeClassList<>("vol.incent.",
51 "Voluntary lane-change incentives.", ParameterTypeClassList.getValueClass(VoluntaryIncentive.class));
52
53
54 public static final ParameterTypeClassList<AccelerationIncentive> ACCELERATION = new ParameterTypeClassList<>("acc.incent.",
55 "Acceleration incentives.", ParameterTypeClassList.getValueClass(AccelerationIncentive.class),
56 ClassCollectionConstraint.newInstance(AccelerationBusStop.class));
57
58
59 private final LinkedHashSet<MandatoryIncentive> mandatoryIncentives = new LinkedHashSet<>();
60
61
62 private final LinkedHashSet<VoluntaryIncentive> voluntaryIncentives = new LinkedHashSet<>();
63
64
65 private final LinkedHashSet<AccelerationIncentive> accelerationIncentives = new LinkedHashSet<>();
66
67
68 private final ImmutableSet<MandatoryIncentive> immutableMandatoryIncentives =
69 new ImmutableLinkedHashSet<>(this.mandatoryIncentives, Immutable.WRAP);
70
71
72 private final ImmutableSet<VoluntaryIncentive> immutableVoluntaryIncentives =
73 new ImmutableLinkedHashSet<>(this.voluntaryIncentives, Immutable.WRAP);
74
75
76 private final ImmutableSet<AccelerationIncentive> immutableAccelerationIncentives =
77 new ImmutableLinkedHashSet<>(this.accelerationIncentives, Immutable.WRAP);
78
79
80
81
82
83 public final void addMandatoryIncentive(final MandatoryIncentive incentive)
84 {
85 if (incentive != null)
86 {
87 this.mandatoryIncentives.add(incentive);
88 }
89 }
90
91
92
93
94
95 public final void addVoluntaryIncentive(final VoluntaryIncentive incentive)
96 {
97 if (incentive != null)
98 {
99 this.voluntaryIncentives.add(incentive);
100 }
101 }
102
103
104
105
106
107 public final void addAccelerationIncentive(final AccelerationIncentive incentive)
108 {
109 if (incentive != null)
110 {
111 this.accelerationIncentives.add(incentive);
112 }
113 }
114
115
116
117
118 public final void setDefaultIncentives()
119 {
120 this.mandatoryIncentives.clear();
121 this.voluntaryIncentives.clear();
122 this.accelerationIncentives.clear();
123 this.mandatoryIncentives.add(new IncentiveRoute());
124
125 this.voluntaryIncentives.add(new IncentiveSpeedWithCourtesy());
126 this.voluntaryIncentives.add(new IncentiveKeep());
127 this.voluntaryIncentives.add(new IncentiveQueue());
128 this.accelerationIncentives.add(new AccelerationSpeedLimitTransition());
129 this.accelerationIncentives.add(new AccelerationTrafficLights());
130 this.accelerationIncentives.add(new AccelerationConflicts());
131 }
132
133
134
135
136
137 public final ImmutableSet<MandatoryIncentive> getMandatoryIncentives()
138 {
139 return this.immutableMandatoryIncentives;
140 }
141
142
143
144
145
146 public final ImmutableSet<VoluntaryIncentive> getVoluntaryIncentives()
147 {
148 return this.immutableVoluntaryIncentives;
149 }
150
151
152
153
154
155 public final ImmutableSet<AccelerationIncentive> getAccelerationIncentives()
156 {
157 return this.immutableAccelerationIncentives;
158 }
159
160 }