Investigating the use of pure functional programming for agent-based simulationTools Thaler, Jonathan (2020) Investigating the use of pure functional programming for agent-based simulation. PhD thesis, University of Nottingham.
AbstractThis thesis investigates the use of pure functional programming in Agent-Based Simulation (ABS) with the language Haskell. The central theme of this thesis is to do with purity, which identifies the lack of unrestricted side effects and referential transparency. Thematically, the research presented in this thesis is split into two parts. The first part deals with the approach to a pure functional ABS implementation and the second part with exploring benefits enabled through pure functional programming. First, the thesis explores how to implement ABS in a pure functional way, discussing both a time and event-driven approach. In each case Arrowized Functional Reactive Programming is used to derive fundamental abstractions and concepts. As use cases the well known agent-based SIR and the Sugarscape models are used. Additionally, the thesis focuses on why it is beneficial to implement ABS in a pure functional way. For this research topic, we explore both robust parallel and concurrent programming, where the main focus is on how to speed up the simulation while keeping it as pure as possible. In the parallel part, we rely on built-in language features and are able to speed the simulation up while retaining purity. In the concurrency part, Software Transactional Memory is used, sacrificing purity but still retaining certain guarantees about reproducibility. Finally, the thesis explores automated code testing of ABS implementations using property-based testing to show how to encode agent specifications and model invariants and perform model verification and hypothesis testing. The contribution of this thesis is threefold: 1. Development of pure functional implementation techniques for ABS through the use of Arrowized Functional Reactive Programming. 2. Development of techniques using Software Transactional Memory to implement robust concurrent ABS. 3. Development of a new testing approach to ABS using randomised propertybased testing for declarative and stochastic code testing. The results of the respective contributions support the view that pure functional programming indeed has its place in ABS. First, a pure functional approach leads to implementations which are more likely to be valid due to the focus on purity by avoiding computations with unrestricted side effects. Secondly, pure parallel computation and Software Transactional Memory (lockfree) based concurrency make it possible to gain substantial speedup, with the latter one dramatically outperforming traditional lock-based approaches. While pure parallel computation fully retains static guarantees, Software Transactional Memory is not pure, but is still able to retain certain guarantees regarding reproducibility. Finally, property-based testing is shown to be extremely useful, as it naturally maps to the stochastic nature of ABS and is therefore suitable to be integrated into the development process as an additional tool for testing specifications and hypotheses.
Actions (Archive Staff Only)
|