File size: 1,252 Bytes
f234112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
class DecisionInterface:

    def build_junction_decision(self, junction_state):

        return {
            "junction_id": junction_state["junction_id"],
            "vehicle_count": junction_state["vehicle_count"],
            "most_congested_approach": (
                junction_state["most_congested_approach"]
            ),
            "congestion_score": (
                junction_state["highest_congestion_score"]
            ),
            "traffic_lights": junction_state[
                "traffic_lights"
            ]
        }

    def build_corridor_decision(self, corridor_state):

        junctions = {}

        for junction_id, state in corridor_state[
            "junctions"
        ].items():

            junctions[junction_id] = (
                self.build_junction_decision(state)
            )

        return {
            "corridor_id": corridor_state["corridor_id"],
            "junction_count": corridor_state["junction_count"],
            "total_vehicles": corridor_state["total_vehicles"],
            "worst_junction": corridor_state["worst_junction"],
            "highest_congestion_score": (
                corridor_state["highest_congestion_score"]
            ),
            "junctions": junctions
        }