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