1 package org.opentrafficsim.road.network.lane.changing;
2
3 import java.io.Serializable;
4 import java.util.Collection;
5
6 import org.djunits.value.vdouble.scalar.Speed;
7 import org.opentrafficsim.core.gtu.GtuType;
8
9 /**
10 * This class implements the overtaking conditions. Examples are:
11 * <ul>
12 * <li>Overtaking on the left is allowed for all GTU types (not likely when there are e.g., both cars and bicycles in the
13 * model).</li>
14 * <li>A GTU type CAR can overtake a GTU type TRACTOR on the left on this road, but no other types of GTUs.</li>
15 * <li>When the speed of the GTU you try to overtake is lower than 50 km/h, you can overtake on the left.</li>
16 * <li>When the speed of the GTU you try to overtake is 25 km/h less than the maximum speed of the lane on which you and the
17 * other GTU are driving, you can overtake on the left or right.</li>
18 * <li>only overtake vehicles that have a maximum speed of under 25 km/h.</li>
19 * <li>Overtaking on the left is allowed for all GTU types, but overtaking on the right is also allowed when traffic density is
20 * below a certain number</li>
21 * <li>Overtaking on the left is allowed for all GTU types, but overtaking on the right is also allowed when the distance to a
22 * traffic light is less than 200 m</li>
23 * <li>Overtaking on the left and the right is allowed for all GTUs. This can e.g. be used on an American highway where all GTUs
24 * that are allowed on the highway can indeed overtake on the right or the left.</li>
25 * </ul>
26 * <b>Note:</b> The class does not check whether it is <b>allowed</b> to overtake another GTU on this road, neither whether it
27 * is possible or safe to do so. That has to be checked by the GTU itself based on e.g., gap acceptance and other behavioral
28 * rules.
29 * <p>
30 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
31 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
32 * </p>
33 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
34 */
35 public interface OvertakingConditions
36 {
37 /********************************************************************************************************************/
38 /********************** IMPLEMENTATION CLASSES OF MOST COMMON OVERTAKING CONDITIONS *****************************/
39 /********************************************************************************************************************/
40
41 /**
42 * Overtaking on the left allowed for all GTUs. Note: overtaking on the right not allowed, so vehicles will stall on a
43 * multilane road near a traffic light. Also, bicycles will overtake cars on the "wrong" side of the road in this simple
44 * condition!
45 * <p>
46 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
47 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
48 * </p>
49 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
50 */
51 class LeftOnly implements OvertakingConditions
52 {
53 @Override
54 public final String toString()
55 {
56 return "LeftOnly []";
57 }
58 }
59
60 /**
61 * Overtaking on the right allowed for all GTUs. Note: overtaking on the left not allowed, so vehicles will stall on a
62 * multilane road near a traffic light. Also, bicycles will overtake cars on the "wrong" side of the road in this simple
63 * condition!
64 * <p>
65 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
66 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
67 * </p>
68 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
69 */
70 class RightOnly implements OvertakingConditions
71 {
72 @Override
73 public final String toString()
74 {
75 return "RightOnly []";
76 }
77 }
78
79 /**
80 * No overtaking allowed. Note if there are multiple lanes, vehicles will stall near a traffic light.
81 * <p>
82 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
83 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
84 * </p>
85 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
86 */
87 class None implements OvertakingConditions
88 {
89 @Override
90 public final String toString()
91 {
92 return "None []";
93 }
94 }
95
96 /**
97 * Overtaking on both sides allowed. This is, e.g., the situation for an American highway.
98 * <p>
99 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
100 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
101 * </p>
102 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
103 */
104 class LeftAndRight implements OvertakingConditions
105 {
106 @Override
107 public final String toString()
108 {
109 return "LeftAndRight []";
110 }
111 }
112
113 /**
114 * Overtaking on the left allowed for all GTUs; they stay on the same lane (e.g., bicycles).
115 * <p>
116 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
117 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
118 * </p>
119 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
120 */
121 class SameLaneLeft implements OvertakingConditions
122 {
123 @Override
124 public final String toString()
125 {
126 return "SameLaneLeft []";
127 }
128 }
129
130 /**
131 * Overtaking on the right allowed for all GTUs; they stay on the same lane (e.g., bicycles).
132 * <p>
133 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
134 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
135 * </p>
136 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
137 */
138 class SameLaneRight implements OvertakingConditions
139 {
140 @Override
141 public final String toString()
142 {
143 return "SameLaneRight []";
144 }
145 }
146
147 /**
148 * Overtaking on both sides allowed for all GTUs; they stay on the same lane (e.g., pedestrians).
149 * <p>
150 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
151 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
152 * </p>
153 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
154 */
155 class SameLaneBoth implements OvertakingConditions
156 {
157 @Override
158 public final String toString()
159 {
160 return "SameLaneBoth []";
161 }
162 }
163
164 /**
165 * Overtaking on the left allowed for all GTUs, and overtaking on the right allowed under a given speed.
166 * <p>
167 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
168 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
169 * </p>
170 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
171 */
172 class LeftAlwaysRightSpeed implements OvertakingConditions, Serializable
173 {
174 /** */
175 private static final long serialVersionUID = 20150913L;
176
177 /** The speed under which overtaking on the "wrong" side is allowed. */
178 private final Speed rightOvertakingSpeedMax;
179
180 /**
181 * @param rightOvertakingSpeedMax the speed under which overtaking on the "wrong" side is allowed
182 */
183 public LeftAlwaysRightSpeed(final Speed rightOvertakingSpeedMax)
184 {
185 this.rightOvertakingSpeedMax = rightOvertakingSpeedMax;
186 }
187
188 @Override
189 public final String toString()
190 {
191 return "LeftAlwaysRightSpeed [rightOvertakingSpeedMax=" + this.rightOvertakingSpeedMax + "]";
192 }
193 }
194
195 /**
196 * Overtaking on the left allowed for all GTUs, and overtaking on the right allowed when there is a traffic jam.
197 * <p>
198 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
199 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
200 * </p>
201 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
202 */
203 class LeftAlwaysRightJam implements OvertakingConditions, Serializable
204 {
205 /** */
206 private static final long serialVersionUID = 20150913L;
207
208 @Override
209 public final String toString()
210 {
211 return "LeftAlwaysRightJam []";
212 }
213 }
214
215 /**
216 * Overtaking on the right allowed for all GTUs, and overtaking on the left allowed under a given speed.
217 * <p>
218 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
219 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
220 * </p>
221 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
222 */
223 class RightAlwaysLeftSpeed implements OvertakingConditions, Serializable
224 {
225 /** */
226 private static final long serialVersionUID = 20150913L;
227
228 /** The speed under which overtaking on the "wrong" side is allowed. */
229 private final Speed leftOvertakingSpeedMax;
230
231 /**
232 * @param leftOvertakingSpeedMax the speed under which overtaking on the "wrong" side is allowed
233 */
234 public RightAlwaysLeftSpeed(final Speed leftOvertakingSpeedMax)
235 {
236 this.leftOvertakingSpeedMax = leftOvertakingSpeedMax;
237 }
238
239 @Override
240 public final String toString()
241 {
242 return "RightAlwaysLeftSpeed [leftOvertakingSpeedMax=" + this.leftOvertakingSpeedMax + "]";
243 }
244 }
245
246 /**
247 * Overtaking on the right allowed for all GTUs, and overtaking on the left allowed when there is a traffic jam.
248 * <p>
249 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
250 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
251 * </p>
252 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
253 */
254 class RightAlwaysLeftJam implements OvertakingConditions, Serializable
255 {
256 /** */
257 private static final long serialVersionUID = 20150913L;
258
259 @Override
260 public final String toString()
261 {
262 return "RightAlwaysLeftJam []";
263 }
264 }
265
266 /**
267 * Provide a collection of GTUs that can overtake another collection of GTUs on the left side, but not vice versa. Example:
268 * {CAR, TRUCK, BUS} can overtake {BICYCLE, SCOOTER}, or {CAR, TRUCK, BUS} can overtake {CAR, TRUCK, BUS, BICYCLE, SCOOTER}.
269 * In the latter case, cars, trucks and busses can overtake all other GTUs, but bicycles and scooters cannot overtake cars,
270 * trucks or busses. Another example is a lane where cars and motors can overtake all other road users, but trucks are not
271 * allowed to overtake. In that case, we would allow {CAR, MOTOR} to overtake {ALL} or {CAR, MOTOR} to overtake {CAR, MOTOR,
272 * TRUCK} in that lane.<br>
273 * TODO: All these "Right/LeftSet" classes should probably use Compatibility instead of full sets.
274 * <p>
275 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
276 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
277 * </p>
278 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
279 */
280 class LeftSet implements OvertakingConditions, Serializable
281 {
282 /** */
283 private static final long serialVersionUID = 20150913L;
284
285 /** A collection of GTUs that can overtake another collection of GTUs. */
286 private final Collection<GtuType> overtakingGtuTypes;
287
288 /** A collection of GTUs that can be overtaken by another collection of GTUs. */
289 private final Collection<GtuType> overtakenGtuTypes;
290
291 /**
292 * Provide a collection of GTUs that can overtake another collection of GTUs on the left, but not vice versa. Example:
293 * {CAR, TRUCK, BUS} can overtake {BICYCLE, SCOOTER}, or {CAR, TRUCK, BUS} can overtake {CAR, TRUCK, BUS, BICYCLE,
294 * SCOOTER}, or {CAR, TRUCK, BUS} can overtake {TRACTOR}.
295 * @param overtakingGtuTypes the GTUs that can overtake a set of other GTUs, e.g., CAR, TRUCK.
296 * @param overtakenGTUTYpes the GTUs that can be overtaken, e.g., BICYCLE, SCOOTER.
297 */
298 public LeftSet(final Collection<GtuType> overtakingGtuTypes, final Collection<GtuType> overtakenGTUTYpes)
299 {
300 this.overtakingGtuTypes = overtakingGtuTypes;
301 this.overtakenGtuTypes = overtakenGTUTYpes;
302 }
303
304 @Override
305 public final String toString()
306 {
307 return "LeftSet [overtakingGtuTypes=" + this.overtakingGtuTypes + ", overtakenGtuTypes=" + this.overtakenGtuTypes
308 + "]";
309 }
310 }
311
312 /**
313 * Provide a collection of GTUs that can overtake another collection of GTUs on the right side, but not vice versa. Example:
314 * {CAR, TRUCK, BUS} can overtake {BICYCLE, SCOOTER}, or {CAR, TRUCK, BUS} can overtake {CAR, TRUCK, BUS, BICYCLE, SCOOTER}.
315 * In the latter case, cars, trucks and busses can overtake all other GTUs, but bicycles and scooters cannot overtake cars,
316 * trucks or busses. Another example is a lane where cars and motors can overtake all other road users, but trucks are not
317 * allowed to overtake. In that case, we would allow {CAR, MOTOR} to overtake {ALL} or {CAR, MOTOR} to overtake {CAR, MOTOR,
318 * TRUCK} in that lane.
319 * <p>
320 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
321 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
322 * </p>
323 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
324 */
325 class RightSet implements OvertakingConditions, Serializable
326 {
327 /** */
328 private static final long serialVersionUID = 20150913L;
329
330 /** A collection of GTUs that can overtake another collection of GTUs. */
331 private final Collection<GtuType> overtakingGtuTypes;
332
333 /** A collection of GTUs that can be overtaken by another collection of GTUs. */
334 private final Collection<GtuType> overtakenGtuTypes;
335
336 /**
337 * Provide a collection of GTUs that can overtake another collection of GTUs on the right, but not vice versa. Example:
338 * {CAR, TRUCK, BUS} can overtake {BICYCLE, SCOOTER}, or {CAR, TRUCK, BUS} can overtake {CAR, TRUCK, BUS, BICYCLE,
339 * SCOOTER}, or {CAR, TRUCK, BUS} can overtake {TRACTOR}.
340 * @param overtakingGTUs the GTUs that can overtake a set of other GTUs, e.g., CAR, TRUCK.
341 * @param overtakenGTUs the GTUs that can be overtaken, e.g., BICYCLE, SCOOTER.
342 */
343 public RightSet(final Collection<GtuType> overtakingGTUs, final Collection<GtuType> overtakenGTUs)
344 {
345 this.overtakingGtuTypes = overtakingGTUs;
346 this.overtakenGtuTypes = overtakenGTUs;
347 }
348
349 @Override
350 public final String toString()
351 {
352 return "RightSet [overtakingGtuTypes=" + this.overtakingGtuTypes + ", overtakenGtuTypes=" + this.overtakenGtuTypes
353 + "]";
354 }
355 }
356
357 /**
358 * Provide a collection of GTUs that can overtake another collection of GTUs on the left side, but not vice versa. Example:
359 * {CAR, TRUCK, BUS} can overtake {BICYCLE, SCOOTER}, or {CAR, TRUCK, BUS} can overtake {CAR, TRUCK, BUS, BICYCLE, SCOOTER}.
360 * In the latter case, cars, trucks and busses can overtake all other GTUs, but bicycles and scooters cannot overtake cars,
361 * trucks or busses. Another example is a lane where cars and motors can overtake all other road users, but trucks are not
362 * allowed to overtake. In that case, we would allow {CAR, MOTOR} to overtake {ALL} or {CAR, MOTOR} to overtake {CAR, MOTOR,
363 * TRUCK} in that lane. In addition, overtaking on the other side is allowed under a given driving speed.
364 * <p>
365 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
366 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
367 * </p>
368 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
369 */
370 class LeftSetRightSpeed implements OvertakingConditions, Serializable
371 {
372 /** */
373 private static final long serialVersionUID = 20150913L;
374
375 /** A collection of GTUs that can overtake another collection of GTUs. */
376 private final Collection<GtuType> overtakingGtuTypes;
377
378 /** A collection of GTUs that can be overtaken by another collection of GTUs. */
379 private final Collection<GtuType> overtakenGtuTypes;
380
381 /** The speed under which overtaking on the "wrong" side is allowed. */
382 private final Speed rightOvertakingSpeedMax;
383
384 /**
385 * Provide a collection of GTUs that can overtake another collection of GTUs on the left, but not vice versa. Example:
386 * {CAR, TRUCK, BUS} can overtake {BICYCLE, SCOOTER}, or {CAR, TRUCK, BUS} can overtake {CAR, TRUCK, BUS, BICYCLE,
387 * SCOOTER}, or {CAR, TRUCK, BUS} can overtake {TRACTOR}. In addition, overtaking on the other side is allowed under a
388 * given driving speed.
389 * @param overtakingGTUs the GTUs that can overtake a set of other GTUs, e.g., CAR, TRUCK.
390 * @param overtakenGTUs the GTUs that can be overtaken, e.g., BICYCLE, SCOOTER.
391 * @param rightOvertakingSpeedMax the speed under which overtaking on the "wrong" side is allowed
392 */
393 public LeftSetRightSpeed(final Collection<GtuType> overtakingGTUs, final Collection<GtuType> overtakenGTUs,
394 final Speed rightOvertakingSpeedMax)
395 {
396 this.overtakingGtuTypes = overtakingGTUs;
397 this.overtakenGtuTypes = overtakenGTUs;
398 this.rightOvertakingSpeedMax = rightOvertakingSpeedMax;
399 }
400
401 @Override
402 public final String toString()
403 {
404 return "LeftSetRightSpeed [overtakingGtuTypes=" + this.overtakingGtuTypes + ", overtakenGtuTypes="
405 + this.overtakenGtuTypes + ", rightOvertakingSpeedMax=" + this.rightOvertakingSpeedMax + "]";
406 }
407 }
408
409 /**
410 * Provide a collection of GTUs that can overtake another collection of GTUs on the left side, but not vice versa. Example:
411 * {CAR, TRUCK, BUS} can overtake {BICYCLE, SCOOTER}, or {CAR, TRUCK, BUS} can overtake {CAR, TRUCK, BUS, BICYCLE, SCOOTER}.
412 * In the latter case, cars, trucks and busses can overtake all other GTUs, but bicycles and scooters cannot overtake cars,
413 * trucks or busses. Another example is a lane where cars and motors can overtake all other road users, but trucks are not
414 * allowed to overtake. In that case, we would allow {CAR, MOTOR} to overtake {ALL} or {CAR, MOTOR} to overtake {CAR, MOTOR,
415 * TRUCK} in that lane. In addition, overtaking on the other side is allowed when there is a traffic jam.
416 * <p>
417 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
418 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
419 * </p>
420 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
421 */
422 class LeftSetRightJam implements OvertakingConditions, Serializable
423 {
424 /** */
425 private static final long serialVersionUID = 20150913L;
426
427 /** A collection of GTUs that can overtake another collection of GTUs. */
428 private final Collection<GtuType> overtakingGtuTypes;
429
430 /** A collection of GTUs that can be overtaken by another collection of GTUs. */
431 private final Collection<GtuType> overtakenGtuTypes;
432
433 /**
434 * Provide a collection of GTUs that can overtake another collection of GTUs on the left, but not vice versa. Example:
435 * {CAR, TRUCK, BUS} can overtake {BICYCLE, SCOOTER}, or {CAR, TRUCK, BUS} can overtake {CAR, TRUCK, BUS, BICYCLE,
436 * SCOOTER}, or {CAR, TRUCK, BUS} can overtake {TRACTOR}. In addition, overtaking on the other side is allowed when
437 * there is a traffic jam.
438 * @param overtakingGTUs the GTUs that can overtake a set of other GTUs, e.g., CAR, TRUCK.
439 * @param overtakenGTUs the GTUs that can be overtaken, e.g., BICYCLE, SCOOTER.
440 */
441 public LeftSetRightJam(final Collection<GtuType> overtakingGTUs, final Collection<GtuType> overtakenGTUs)
442 {
443 this.overtakingGtuTypes = overtakingGTUs;
444 this.overtakenGtuTypes = overtakenGTUs;
445 }
446
447 @Override
448 public final String toString()
449 {
450 return "LeftSetRightSpeed [overtakingGtuTypes=" + this.overtakingGtuTypes + ", overtakenGtuTypes="
451 + this.overtakenGtuTypes + "]";
452 }
453 }
454
455 /**
456 * Provide a collection of GTUs that can overtake another collection of GTUs on the right side, but not vice versa. Example:
457 * {CAR, TRUCK, BUS} can overtake {BICYCLE, SCOOTER}, or {CAR, TRUCK, BUS} can overtake {CAR, TRUCK, BUS, BICYCLE, SCOOTER}.
458 * In the latter case, cars, trucks and busses can overtake all other GTUs, but bicycles and scooters cannot overtake cars,
459 * trucks or busses. Another example is a lane where cars and motors can overtake all other road users, but trucks are not
460 * allowed to overtake. In that case, we would allow {CAR, MOTOR} to overtake {ALL} or {CAR, MOTOR} to overtake {CAR, MOTOR,
461 * TRUCK} in that lane. In addition, overtaking on the other side is allowed under a given driving speed.
462 * <p>
463 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
464 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
465 * </p>
466 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
467 */
468 class RightSetLeftSpeed implements OvertakingConditions, Serializable
469 {
470 /** */
471 private static final long serialVersionUID = 20150913L;
472
473 /** A collection of GTUs that can overtake another collection of GTUs. */
474 private final Collection<GtuType> overtakingGtuTypes;
475
476 /** A collection of GTUs that can be overtaken by another collection of GTUs. */
477 private final Collection<GtuType> overtakenGtuTypes;
478
479 /** The speed under which overtaking on the "wrong" side is allowed. */
480 private final Speed leftOvertakingSpeedMax;
481
482 /**
483 * Provide a collection of GTUs that can overtake another collection of GTUs on the left, but not vice versa. Example:
484 * {CAR, TRUCK, BUS} can overtake {BICYCLE, SCOOTER}, or {CAR, TRUCK, BUS} can overtake {CAR, TRUCK, BUS, BICYCLE,
485 * SCOOTER}, or {CAR, TRUCK, BUS} can overtake {TRACTOR}. In addition, overtaking on the other side is allowed under a
486 * given driving speed.
487 * @param overtakingGTUs the GTUs that can overtake a set of other GTUs, e.g., CAR, TRUCK.
488 * @param overtakenGTUs the GTUs that can be overtaken, e.g., BICYCLE, SCOOTER.
489 * @param leftOvertakingSpeedMax the speed under which overtaking on the "wrong" side is allowed
490 */
491 public RightSetLeftSpeed(final Collection<GtuType> overtakingGTUs, final Collection<GtuType> overtakenGTUs,
492 final Speed leftOvertakingSpeedMax)
493 {
494 this.overtakingGtuTypes = overtakingGTUs;
495 this.overtakenGtuTypes = overtakenGTUs;
496 this.leftOvertakingSpeedMax = leftOvertakingSpeedMax;
497 }
498
499 @Override
500 public final String toString()
501 {
502 return "RightSetLeftSpeed [overtakingGtuTypes=" + this.overtakingGtuTypes + ", overtakenGtuTypes="
503 + this.overtakenGtuTypes + ", leftOvertakingSpeedMax=" + this.leftOvertakingSpeedMax + "]";
504 }
505 }
506
507 /**
508 * Provide a collection of GTUs that can overtake another collection of GTUs on the right side, but not vice versa. Example:
509 * {CAR, TRUCK, BUS} can overtake {BICYCLE, SCOOTER}, or {CAR, TRUCK, BUS} can overtake {CAR, TRUCK, BUS, BICYCLE, SCOOTER}.
510 * In the latter case, cars, trucks and busses can overtake all other GTUs, but bicycles and scooters cannot overtake cars,
511 * trucks or busses. Another example is a lane where cars and motors can overtake all other road users, but trucks are not
512 * allowed to overtake. In that case, we would allow {CAR, MOTOR} to overtake {ALL} or {CAR, MOTOR} to overtake {CAR, MOTOR,
513 * TRUCK} in that lane. In addition, overtaking on the other side is allowed when there is a traffic jam.
514 * <p>
515 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
516 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
517 * </p>
518 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
519 */
520 class RightSetLeftJam implements OvertakingConditions, Serializable
521 {
522 /** */
523 private static final long serialVersionUID = 20150913L;
524
525 /** A collection of GTUs that can overtake another collection of GTUs. */
526 private final Collection<GtuType> overtakingGtuTypes;
527
528 /** A collection of GTUs that can be overtaken by another collection of GTUs. */
529 private final Collection<GtuType> overtakenGtuTypes;
530
531 /**
532 * Provide a collection of GTUs that can overtake another collection of GTUs on the left, but not vice versa. Example:
533 * {CAR, TRUCK, BUS} can overtake {BICYCLE, SCOOTER}, or {CAR, TRUCK, BUS} can overtake {CAR, TRUCK, BUS, BICYCLE,
534 * SCOOTER}, or {CAR, TRUCK, BUS} can overtake {TRACTOR}. In addition, overtaking on the other side is allowed when
535 * there is a traffic jam.
536 * @param overtakingGTUs the GTUs that can overtake a set of other GTUs, e.g., CAR, TRUCK.
537 * @param overtakenGTUs the GTUs that can be overtaken, e.g., BICYCLE, SCOOTER.
538 */
539 public RightSetLeftJam(final Collection<GtuType> overtakingGTUs, final Collection<GtuType> overtakenGTUs)
540 {
541 this.overtakingGtuTypes = overtakingGTUs;
542 this.overtakenGtuTypes = overtakenGTUs;
543 }
544
545 @Override
546 public final String toString()
547 {
548 return "RightSetLeftJam [overtakingGtuTypes=" + this.overtakingGtuTypes + ", overtakenGtuTypes="
549 + this.overtakenGtuTypes + "]";
550 }
551 }
552
553 }