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