Planning with Global State Constraints for Urban Traffic Control Franc Ivankovic, Marco Roveri Department of Information Engineering and Computer Science - University of Trento Abstract Planning with global state constraints is an extension of classical planning in which some properties of each state are derived via a set of constraints. This approach allows us to apply planning techniques in domains involving interconnected physical systems. The crucial feature of such domains is that a single discrete action affects the state of the entire system in a way that is dependent on the global state. Urban Traffic Control refers to coordinating traffic signals over an area in order to reduce congestion and delays. Here we show how this domain can be modelled as a planning problem with global state constraints. Keywords Urban traffic control, Automated planning, Global state constraints 1. Introduction and related work Urban Traffic Control (UTC) is the problem of managing and coordinating traffic signals over an area in order to optimise traffic flows in a road network [1]. The UTC problem has been traditionally approached either with complex mathematical models or with simple model of traffic (see [1] for details). More recently, have been discussed approaches to solve UTC problems leveraging on state-of-the-art planning and scheduling techniques. The work [2] provides a detailed survey of the approaches of planning and scheduling for UTC. In [1, 3] it has been discussed an approach based on PDDL+ [4]: continuous processes are used to control flows of cars; and traffic light green phases are the control variables to be modified by actions to achieve the goal of reducing congestions in specific roads. [5] provides a pure PDDL [6] encoding where each road is associated a discrete density level. Actions operate on the traffic lights to enable flows and change density levels. Planning with Global State Constraints (GSC) [7, 8] is an extension of classical planning in which some properties of states are determined by a set of constraints common to all states. This formalism is well suited for applying classical planning methods on domains that involve a network of interconnected physical systems [9] controlled by discrete controllable variables (noticeable examples are power networks). The crucial feature of such domains is that a single discrete action (to change controllable variables), such as opening or closing a switch somewhere, affects the entire network in a way that is dependent on the global state of the system. OVERLAY 2021: 3rd Workshop on Artificial Intelligence and Formal Verification, Logic, Automata, and Synthesis, September 22, 2021, Padova, Italy " franc.ivankovic@unitn.it (F. Ivankovic); marco.roveri@unitn.it (M. Roveri)  0000-0001-9483-3940 (M. Roveri) ยฉ 2021 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). CEUR Workshop Proceedings http://ceur-ws.org ISSN 1613-0073 CEUR Workshop Proceedings (CEUR-WS.org) We make the following contributions. First, we observe several similarities between the power network re-configurations problems and the UTC problem: actions like closing/opening of a road, changing the duration of green light, or redirecting traffic, can potentially affect traffic flow rates throughout the city in a complex way similarly to corresponding operations in a power network. Second, we provide an encoding of the UTC problem into the framework of planning with GSC. Third, we witness the feasibility of the approach by a preliminary experimentation on a small UTC scenario. 2. Background Planning with global state constraints [7] allows us to model some properties of states as derived from so called constraints. These can take a variety of forms depending on the modeled system, e.g., logical axioms [10] or a system of equations and inequalities [7] This has been shown to be well suited for domains that involve interconnected physical systems, such as power grids. These domains are such that each discrete action can change the state of the whole network in a way that depends on the entire current configuration (e.g., opening/closing a switch may change power flow in all lines). Here we will briefly present a (somewhat simplified) formulation of planning with GSC. The framework distinguishes primary variables that the planner has direct control over (such as states of the switches) and secondary variables whose value is computed by so called switched constraints. The former behave like in classical planning โ€“ their domains are finite and discrete, their values are assigned in the initial state and they persist unless modified by action effects. Secondary variables can be of any type (in this instance, they are real numbers), and their values are recomputed in each state. Switched constraints have the form ๐œ‘ โ†’ ๐›พ where ๐œ‘ is assignment to a subset of the primary variables, and ๐›พ is an expression over secondary variables. The assignment to primary variables determines whether a switched constraint is active in a given state. For a state to be valid, an assignment to secondary variables must exist such that the set of all ๐›พ-parts of all active switched constraints is satisfiable. A plan can only pass through valid states. Consequently, to be able to apply an action in state ๐‘  i. its preconditions must be satisfiable in ๐‘  and ii. the resulting state must be valid. For a thorough discussion of the framework refer to [7, 9]. In [9] it has been shown how to combine GSCs constraints and state-dependent action costs (SDAC) and how to incorporate them into pattern database (PDB) heuristics. In this framework the cost of applying an action can be a function of all primary and secondary variables. For instance, in the the power network reconfiguration domain SDAC account for the fact that it is preferable to reduce the unsupplied load (consumers without power) over the total time span. 3. Traffic model and encoding in Planning with GSC We model the traffic network as a directed graph โŸจ๐‘, ๐‘…โŸฉ, such that ๐‘ = ๐‘‚ โˆช ๐ท โˆช ๐‘† and ๐‘‚, ๐ท, ๐‘† are pairwise disjoint set of nodes. Nodes ๐‘‚ (for origin) being sources; nodes ๐ท (for destinations) being sinks, and nodes ๐‘† (for switches) being intersections. Each edge ๐‘…๐‘– โˆˆ ๐‘… โІ ๐‘ ร— ๐‘ , denotes a road (a two way road is modeled with two different edges with opposite directions). For a node ๐‘๐‘– โˆˆ ๐‘ we denote with ๐‘–๐‘›(๐‘๐‘– ) (resp. ๐‘œ๐‘ข๐‘ก(๐‘๐‘– )) the set of incoming (resp. outgoing) roads. Each source generates some number of vehicles that move towards different sinks. We denote with ๐‘Ÿ๐‘–,๐ท๐‘— โ‰ฅ 0 the flow of vehicles on road ๐‘…๐‘– with destination ๐ท๐‘— . We denote with ๐‘œ๐‘–,๐ท๐‘˜ โ‰ฅ 0 the flow of vehicles generated by source ๐‘‚๐‘– with the destination ๐ท๐‘˜ . For instance, Fig. 1 shows a simple traffic network with three sources (๐‘‚1 , ๐‘‚2 , ๐‘‚3 ), one sink (๐ท1 ), three Figure 1: A simple traffic network. switches with traffic lights (๐ด, ๐ต, and ๐ถ), and 8 roads (๐‘…1 ,...,๐‘…5 and abusing notation ๐‘‚1 ,๐‘‚2 , ๐‘‚3 to refer to the edges between the sources and the switches). The values of traffic flows are determined by three types of constraints: i) capacity constraints associated with roads and intersections, ii) flow conservation constraints, and iii) constraints associated with different modes of operation of the intersections. 3.1. Capacity constraints Each road ๐‘…๐‘– has a capacity ๐‘๐‘…๐‘– โ‰ฅ 0, and โˆ‘๏ธ€ the sum ๐‘Ÿ๐‘– of all flows of vehicles through the road cannot exceed its capacity, i.e. ๐‘Ÿ๐‘– = ๐‘‘๐‘˜ โˆˆ๐ท ๐‘Ÿ๐‘–,๐‘‘๐‘˜ โ‰ค ๐‘๐‘…๐‘– . The total number ๐‘‘โˆ‘๏ธ€๐‘— of vehicles entering the destination ๐ท๐‘— must be equal the number generated at all sources ๐‘‘๐‘— = ๐‘‚๐‘– โˆˆ๐‘‚ ๐‘œ๐‘–,๐ท๐‘— . The total number ๐‘œ๐‘— of vehicles generated at source โˆ‘๏ธ€ ๐‘‚๐‘— must be equal the sum of the vehicles generated at ๐‘‚๐‘— for all the destinations, i.e. ๐‘œ๐‘— = ๐ท๐‘˜ โˆˆ๐ท ๐‘œ๐‘—,๐ท๐‘˜ . 3.2. Flow conservation constraints Every intersection has a set of flow conservation constraints โ€“ one for each incoming or one and for each destination. That is, for an outgoing road ๐‘…๐‘– at an intersection ๐‘†โ„Ž , we outgoing roadโˆ‘๏ธ€ have ๐‘Ÿ๐‘–,๐ท๐‘˜ = ๐‘…๐‘— โˆˆ๐‘–๐‘›(๐‘†โ„Ž ) ๐‘“๐‘…๐‘– ,๐‘…๐‘— ,๐ท๐‘˜ where ๐‘“๐‘…๐‘– ,๐‘…๐‘— ,๐ท๐‘˜ is the traffic flow moving from the road ๐‘…๐‘– to the road ๐‘…๐‘— towards sink ๐ท๐‘˜ . (The constraints for incoming roads have the same form except the sum is over ๐‘œ๐‘ข๐‘ก(๐‘†โ„Ž ).) 3.3. Intersection configurations flow ๐‘“๐‘…๐‘– ,๐‘…๐‘— between roads ๐‘…๐‘– and ๐‘…๐‘— is the sum of the flows to all destinations, The total โˆ‘๏ธ€ ๐‘“๐‘…๐‘– ,๐‘…๐‘— = ๐ท๐‘˜ โˆˆ๐ท ๐‘“๐‘…๐‘– ,๐‘…๐‘— ,๐ท๐‘˜ . This number is limited by the product of the total cycle length ๐‘‡ , the portion ๐‘ก๐‘…๐‘– ,๐‘…๐‘— ,๐‘˜ of the cycle during which the light between roads ๐‘…๐‘– and ๐‘…๐‘— is green under configuration ๐‘˜, and the capacity ๐‘๐‘…๐‘– ,๐‘…๐‘— of the switch. The value of ๐‘ก๐‘…๐‘– ,๐‘…๐‘— ,๐‘˜ depends on the configuration of the intersection ๐‘†โ„Ž which is modelled as a primary variable ๐ฟโ„Ž , with the domain ๐’Ÿ(๐ฟโ„Ž ) = [0 . . . ๐‘โ„Ž ] (with ๐‘โ„Ž โ‰ฅ 0). Denoting the primary variable ๐ฟโ„Ž and the value ๐‘˜ โˆˆ ๐’Ÿ(๐ฟโ„Ž ) the switched constraint is ๐ฟโ„Ž = ๐‘˜ โ†’ ๐‘“๐‘…๐‘– ,๐‘…๐‘— โ‰ค ๐‘๐‘…๐‘– ,๐‘…๐‘— ๐‘‡ ๐‘ก๐‘…๐‘– ,๐‘…๐‘— ,๐‘˜ . For each of the configurations, there is one such constraint associated with each pair of roads. (We remark that, that the values of ๐‘‡ and ๐‘๐‘…๐‘– ,๐‘…๐‘— are the same in all constraints.) When defining the configurations, we need to make sure that the resulting combination of green/red lights or open/closed roads is compatible (e.g. if traffic cannot flow between ๐‘…๐‘– and ๐‘…๐‘— at the same time as between ๐‘…๐‘š and ๐‘…๐‘› , then ๐‘ก๐‘…๐‘š ,๐‘…๐‘› โ‰ค ๐‘‡ โˆ’ ๐‘ก๐‘…๐‘– ,๐‘…๐‘— ). A complete assignment to the different secondary variables ๐‘Ÿ๐‘–,๐‘…๐‘— , ๐‘๐‘…๐‘˜ ,๐‘…๐‘™ and ๐‘ก๐‘…๐‘š ,๐‘…๐‘› , defined above satisfying the different respective constraints, represents one possible traffic situation of the traffic network at a given time instant. 3.4. Actions, initial condition, goal and the plan cost Actions change the configurations of intersections by assigning values to primary variables. For each intersections ๐‘†โ„Ž โˆˆ ๐‘† and for each ๐‘˜ โˆˆ ๐’Ÿ(๐ฟโ„Ž ) we have an action switch_Lh _to_k whose only effect is to enforce ๐ฟโ„Ž = ๐‘˜. Such actions therefore activate/de-activate a subset of the switched constraints. The initial state is an assignment to the primary variables only (that in turn activate respective switched constraints). The goal in this domain is typically to remove a congestion on a given road. As such it might have the form of ๐‘Ÿ๐‘– โ‰ค ๐‘ฃ, where ๐‘ฃ is some value of the vehicle flow that we want to achieve. If we employ state-dependent action costs, we can also โˆ‘๏ธ€ assign additional costs to having congested roads. The cost of every action becomes ๐‘๐‘Ž = ๐‘…๐‘– โˆˆ๐‘… max (๐‘Ÿ๐‘– โˆ’ ๐‘ฃ๐‘– , 0), where ๐‘ฃ๐‘– is some traffic congestion threshold for road ๐‘…๐‘– . (This is similar to previous work on applying planning to UTC [11] that adds penalties for road congestions.) 4. Experimental evaluation In order to show the feasibility of the proposed encoding we encoded the simple traffic network illustrated in Figure 1 in the specification language of the GSC Planner [7, 8] available from https://github.com/patrikhaslum/gscplanner, configured to leverage on the Gurobiยฎ (https://www. gurobi.com/) optimization solver to deal with the GSC constraints. We run the GSC Planner on a Linux Laptop equipped with an Intel i5 processor and 16Gb of RAM. The GSC Planner was able to solve this small instance in less than a second. 5. Conclusions and Future Work In this paper we have shown how to encode the UTC problem in the framework of planning with global constraints. The encoding has been experimented on a simple traffic network witnessing the feasibility of the approach. We envision several possible directions for future work. First, we intend to carry out a more thorough experimental evaluation considering large networks and possibly different encodings. The previous experience in solving power network domains (that have many similarities with the UTC problem) [9] suggest that the approach may scale up to larger instances. We want also investigate how to enrich this encoding to integrate additional constraints and state-dependent action costs [9, 11]. Finally, we also intend to carry out a more thorough comparison with the approaches based on PDDL+ [1, 3, 11]. Acknowledgments This work is partially funded by the grant MOSES, Bando interno 2020 Universitร  di Trento "Covid 19". References [1] L. Chrpa, D. Magazzeni, K. McCabe, T. L. McCluskey, M. Vallati, Automated planning for urban traffic control: Strategic vehicle routing to respect air quality limitations, Intelligenza Artificiale 10 (2016) 113โ€“128. [2] I. Cenamor, L. Chrpa, F. Jimoh, T. McCluskey, M. Vallati, Planning & scheduling applica- tions in urban traffic management, The UK Planning and Scheduling Special Interest Group (UK PlanSIG), 2014. http://eprints.hud.ac.uk/id/eprint/22801/. [3] T. L. McCluskey, M. Vallati, Embedding automated planning within urban traffic manage- ment operations, in: ICAPS 2017, AAAI Press, 2017, pp. 391โ€“399. [4] M. Fox, D. Long, Modelling mixed discrete-continuous domains for planning, J. Artif. Intell. Res. 27 (2006) 235โ€“297. [5] A. Pozanco, S. Fernรกndez, D. Borrajo, Urban traffic control assisted by AI planning and relational learning, in: A. L. C. Bazzan, F. Klรผgl, S. Ossowski, G. Vizzari (Eds.), Agents in Traffic and Transportation (ATT 2016), volume 1678 of CEUR Workshop Proceedings, CEUR-WS.org, 2016. [6] D. V. McDermott, The 1998 AI planning systems competition, AI Mag. 21 (2000) 35โ€“55. [7] F. Ivankovic, P. Haslum, S. Thiรฉbaux, V. Shivashankar, D. S. Nau, Optimal planning with global numerical state constraints, in: ICAPS 2014, 2014. [8] P. Haslum, F. Ivankovic, M. Ramรญrez, D. Gordon, S. Thiรฉbaux, V. Shivashankar, D. S. Nau, Extending classical planning with state constraints: Heuristics and search for optimal planning, J. Artif. Intell. Res. 62 (2018) 373โ€“431. [9] F. Ivankovic, D. Gordon, P. Haslum, Planning with global state constraints and state- dependent action costs, in: ICAPS 2018, AAAI Press, 2019, pp. 232โ€“236. [10] S. Thiรฉbaux, J. Hoffmann, B. Nebel, In defense of PDDL axioms, Artif. Intell. 168 (2005) 38โ€“69. [11] M. Vallati, E. Scala, L. Chrpa, A hybrid automated planning approach for urban real- time routing of connected vehicles, in: 24th IEEE International Conference on Intelligent Transportation - ITSC2021, IEEE, 2021. To appear.