Investigating the use of pure functional programming for agent-based simulation

This 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...

Full description

Bibliographic Details
Main Author: Thaler, Jonathan
Format: Thesis (University of Nottingham only)
Language:English
Published: 2020
Subjects:
Online Access:https://eprints.nottingham.ac.uk/60350/
_version_ 1848799753130737664
author Thaler, Jonathan
author_facet Thaler, Jonathan
author_sort Thaler, Jonathan
building Nottingham Research Data Repository
collection Online Access
description This 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.
first_indexed 2025-11-14T20:40:40Z
format Thesis (University of Nottingham only)
id nottingham-60350
institution University of Nottingham Malaysia Campus
institution_category Local University
language English
last_indexed 2025-11-14T20:40:40Z
publishDate 2020
recordtype eprints
repository_type Digital Repository
spelling nottingham-603502025-02-28T14:52:40Z https://eprints.nottingham.ac.uk/60350/ Investigating the use of pure functional programming for agent-based simulation Thaler, Jonathan This 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. 2020-07-24 Thesis (University of Nottingham only) NonPeerReviewed application/pdf en arr https://eprints.nottingham.ac.uk/60350/1/thaler_thesis_minorcorrections.pdf Thaler, Jonathan (2020) Investigating the use of pure functional programming for agent-based simulation. PhD thesis, University of Nottingham. Agent-based simulation Functional programming Haskell Parallel programming Software transactional memory Property-based testing
spellingShingle Agent-based simulation
Functional programming
Haskell
Parallel programming
Software transactional memory
Property-based testing
Thaler, Jonathan
Investigating the use of pure functional programming for agent-based simulation
title Investigating the use of pure functional programming for agent-based simulation
title_full Investigating the use of pure functional programming for agent-based simulation
title_fullStr Investigating the use of pure functional programming for agent-based simulation
title_full_unstemmed Investigating the use of pure functional programming for agent-based simulation
title_short Investigating the use of pure functional programming for agent-based simulation
title_sort investigating the use of pure functional programming for agent-based simulation
topic Agent-based simulation
Functional programming
Haskell
Parallel programming
Software transactional memory
Property-based testing
url https://eprints.nottingham.ac.uk/60350/