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