File size: 1,235 Bytes
5893134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from __future__ import annotations

from dataclasses import dataclass

DISTRICT_TYPES: tuple[str, ...] = (
    "residential",
    "commercial",
    "industrial",
    "mixed",
)
DISTRICT_TYPE_TO_INDEX: dict[str, int] = {
    district_type: index for index, district_type in enumerate(DISTRICT_TYPES)
}
DEFAULT_DISTRICT_TYPE = "mixed"


@dataclass(frozen=True)
class PhaseConfig:
    engine_phase_index: int
    available_road_links: tuple[int, ...]
    incoming_lanes_served: tuple[str, ...]
    outgoing_lanes_served: tuple[str, ...]


@dataclass(frozen=True)
class IntersectionConfig:
    intersection_id: str
    district_id: str
    district_type: str
    district_type_index: int
    incoming_lanes: tuple[str, ...]
    outgoing_lanes: tuple[str, ...]
    is_boundary: bool
    green_phases: tuple[PhaseConfig, ...]
    all_phase_indices: tuple[int, ...]
    initial_engine_phase_index: int

    @property
    def num_green_phases(self) -> int:
        return len(self.green_phases)


@dataclass(frozen=True)
class DistrictConfig:
    district_id: str
    district_type: str
    district_type_index: int
    intersection_ids: tuple[str, ...]
    neighbor_districts: tuple[str, ...]