Simulating Cities: A Software Engineering Perspective

Despite all the reasons why complex simulations are desirable for decision and policy making, and despite advances in computing power, large distributed simulations are still rarely used.  The reality is that developing distributed simulations is much harder than developing non-distributed, specialized ones, and requires a much higher level of software engineering expertise.  Prof. Cristina Lopes and her students have been working on a software architecture, and a corresponding software framework, which have the goal of lowering the barriers for the simulation of large, complex systems, such as entire cities.

Prof. Cristina Videira LopesOne of the main challenges in doing complex systems simulations, including cities, is the fact that they embody many different subsystems, each of them relatively, but not completely, independent from the others.  For this reason, there are many similarities between the concept of aspect (as given by Aspect-Oriented Programming) and the general concept of aspect of a city that urban planning researchers routinely use.  All these aspects are conceptually distinct, but interact with each other over essentially the same objects (data) of the simulation.  Moreover, each of these subsystems tends to fall under different expertise, different groups of people who understand them.  Aggregating that knowledge under one large simulation is a daunting task.

One way to divide a complex simulation system into smaller parts is to distribute the data.  Simulators partition the workload by simulating different objects at each time frame.  While scalable in terms of number of objects, this approach is not scalable in terms of simulation complexity: many different subsystems need to access the same data, so each simulation node needs to simulate all subsystems.  Another approach is to divide the load by subsystem: functions such as physics simulation, scripts processing, and client management, are run in distributed simulators, and object attributes are synchronized when updated.  This a good solution for synchronizing updates, but has some performance penalties, because data needs to be shared among simulators.  

Aspects of Cities

Prof. Lopes and her team have been experimenting with partitioning the simulation load using AOP concepts.  This architecture is inspired by the High Level Architecture military standard, but provides concrete design choices and a powerful expression mechanism (inspired by relational queries, in general, and dependent types, in particular) to reduce the technical complexity of distributing an urban simulation. 

AOP urban simulation architecture, a concrete realization of the canonical HLA.The framework they are developing is called “The Spacetime Framework,” and consists of the framework itself, as well as a library (in fact, a domain-specific language, DSL) called “Predicate Collection Classes” (PCC) that lets developers declare their data models, as well as  to reappropriate portions of other developers’ data to fit their own sub-simulations.  A simple example is a Car object and an ActiveCar object: a Car represents a common vehicle driven in cities, and its data model could be defined by a certain group of people; an ActiveCar (i.e. a Car whose velocity property is more than 0) is a specific view of the Car that might be needed for some simulations but not for all, therefore would be part of someone else’s data model.  The ActiveCar class is declared as a predicate on the Car class – hence the name Predicate Collection Classes.  Whenever needed, a runtime classification collects all Car objects that are active, returning the collection of ActiveCar objects, statically marked as such, for a specific simulation to use.  The PCC runtime maintains a synchronization between an object and its derivatives based on a primary key.  This means that modifying the value of properties of ActiveCar implies the same modifications in the original Car object.  The PCC DSL/runtime support is being developed by Ph.D. student Rohan Achar.  A paper describing it, entitled “Predicate Collection Classes,” will soon appear in the Journal of Object Technology.

The Spacetime Framework is a time-stepped simulation framework that allows developers to declare which data to use, and how.  So, for example, a certain simulation component might create Car objects, while another component might get ActiveCar objects, and a third component might get and update InactiveCar objects.  All of this is done declaratively.  The objects themselves are reclassified at every time step for every simulation component.

View of the urban simulation platform prototype. The colored rectangles are vehicles, with each color  indicating a different type of vehicle.While the architecture and programming model of Spacetime are very simple, a simplistic implementation of the framework would lead to severe performance issues.  Recently graduated Dr. Arthur Valadares, who defended his thesis in November, has been working on the performance of Spacetime.  The simple relational model of PCC allows multiple optimizations that dramatically reduce the amount of data that needs to be sent from the shared data store to all the simulation components at each time step.  Benchmarks show that the Spacetime framework is comparable to hand-optimized code.  A paper describing the Spacetime framework entitled “CADIS: Aspect-oriented Architecture for Collaborative Modeling and Simulation” has been published and presented at the 2016 Winter Simulation Conference in December.

The Spacetime Framework is currently under experimental deployment at an urban planning company, and is also being used as the basis for projects in a course Prof. Lopes is teaching in the Winter quarter.

See in Github:


This work is currently supported by NSF grant #1526593.

For more information, contact Prof. Lopes or visit Lopes's Mondego website.

This article appeared in ISR Connector issue: