Slides from MABS talk: Combining Constraint-Based and Imperative Programming in MABS for More Reliable Modelling

Invited talk at MABS, London, May 2023. Slides at:


We argue for a combination of declarative/constraint and imperative programming approaches for MABS. In such approach there would be basically be two layers: a declarative layer of statements that specified the ontology, assumptions, types, internal and checks for a simulation and the specific imperative code that satisfied the statements of the declarative layer – instantiating the behaviours described more abstractly there. Such a system would be a generalisation of common elements of existing imperative simulations, such as: random choices, strong typing, unit/internal tests, ontologies, stubs, and APIs. The idea is that the two layers would be separately developed and communicated but work together. Using such a system one might start (a) with an ontology of entities that have been previously agreed within a field then (b) work with domain experts to implement declarative statements that reflect what is known about the system © develop the implementation starting with declarative internal checks (e.g. on incoming data) and the start of the outlines of the implementation (d) slowly becoming more and more imperative to fill in details, make the simulation run faster, maybe making some more arbitrary choices where the details of processes are not known (e) when the simulation has been completely verified, the declarative layer could be switched off to allow faster model result exploration.

Such a system would not only ensure for a higher-quality of simulation (fewer bugs) but also ensure its consistency with common ontologies/APIs etc. It would facilitate the following: joining models together with fewer mistakes, comparing models (one could check that the declarative layers were consistent before doing model runs), provide enhanced and flexible error checking, make modules more reusable (one could check the constraints/specification of the module with the rest of your simulation before use), allow for rapid prototyping (and hence facilitate the expert-programmer dialogue), support the automation of modelling tools/add-ons, and allow the selective exploration of all possible behaviours of a sub-model using constraint programming techniques.

Separating out the specification and implementation stages of model development might allow for faster, more reliable, more modular and more comparable simulations and thus be a step towards enabling MABS to become a more reliable engineering/scientific endeavour.

(full paper currently being written with Gary Polhill)