Skip to content

Common

Realizations shared by several engineering systems, by family.

The families are mechanics and electrical components, and the car and its optimal velocity of the traffic systems.

CarElement(label, visual=None, *, x=0.0, v=0.0)

Bases: Element

Car on a road whose position x advances at its speed v.

Source code in src/skcomplex/systems/engineering/common/_car.py
17
18
19
20
21
22
23
24
25
26
27
def __init__(
    self,
    label: str,
    visual: VisualSpec | None = None,
    *,
    x: Annotated[object, StateSpec(role='position')] = 0.0,
    v: Annotated[object, StateSpec(role='velocity')] = 0.0,
) -> None:
    super().__init__(label, visual=visual)
    self.x = x
    self.v = v

OptimalVelocityInteraction(label, *, target, a=1.0, V0=1.0, hc=2.0, road_length=40.0)

Bases: RelaxationInteraction

Relaxation of the speed v of every car of a ring road towards the optimal velocity of its headway.

The speed follows v' = a (V(h) - v) with the optimal velocity V(h) = V0 (tanh(h - hc) + tanh(hc)) of the headway h to the next car, a relaxation over the time 1 / a.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Annotated[str, RoleSpec()]

The path of the group of cars, in the order they drive.

required
a Annotated[object, ParameterSpec(domain=open(0, oo))]

The sensitivity, the inverse of the relaxation time.

1.0
V0 Annotated[object, ParameterSpec(domain=open(0, oo))]

The scale of the optimal velocity.

1.0
hc Annotated[object, ParameterSpec(domain=open(0, oo))]

The safe headway, where the optimal velocity turns.

2.0
road_length Annotated[object, ParameterSpec(domain=open(0, oo))]

The length of the ring road.

40.0
Source code in src/skcomplex/systems/engineering/common/_optimal_velocity.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def __init__(
    self,
    label: str,
    *,
    target: Annotated[str, RoleSpec()],
    a: Annotated[object, ParameterSpec(domain=RealSet.open(0, oo))] = 1.0,
    V0: Annotated[object, ParameterSpec(domain=RealSet.open(0, oo))] = 1.0,
    hc: Annotated[object, ParameterSpec(domain=RealSet.open(0, oo))] = 2.0,
    road_length: Annotated[object, ParameterSpec(domain=RealSet.open(0, oo))] = 40.0,
) -> None:
    super().__init__(label, target=target, state='v')
    self.a = a
    self.V0 = V0
    self.hc = hc
    self.road_length = road_length