This repository contains the source code for an agent-based model simulation using the Mesa framework. The simulation includes various aspects such as economic and cop agent interactions, crime dynamics through sentence length (punishment severity) and level of policing (likelihood of getting caught).
- Clone the repository
- Install the required Python packages:
pip install -r requirements.txt
To visualize the agent-based model via a web interface, run the following command from the root of the repository:
mesa runserver src
From the project directory run
python src/experiment.py
it will run the experiment with the default parameter settings as specified in the configuration file (config.toml) in parallel.
If you want to run the experiment while varying 1 parameter at a time (e.g. vary trading skill but keep other params constant), run
python src/experiment.py --vary 'trading_skill_std'
To generate figures in our report, run all analysis.ipynb
and global_sensitivity_analysis.ipynb
├── LICENSE
├── README.md
├── config.toml
├── notebooks
│ ├── analysis.ipynb
│ └── global_sensitivity_analysis.ipynb
├── requirements.txt
├── results
├── src
│ ├── agent.py
│ ├── experiment.py
│ ├── extra_analysis.py
│ ├── model.py
│ ├── parallel_run_global.py
│ ├── plot.py
│ └── run.py
└── static
├── extra_graphs
├── icons
└── plot
- config.toml: Configuration file to run the experiment
- /notebooks: Contains Jupyter notebooks for analysis and to generate plots in our report
- /results: Stores simulation output results, currently ignored from being committed due to large file size
- agent.py: Defines the
EconomicAgent
andCopAgent
classes. - model.py: Contains the
EconomicModel
class which setups the simulation environment and agents. - run.py: Utilizes Mesa's server to visualize simulation runs. It is the entry point for running the visualization interface.
- experiment.py: Script for executing local sensitivity analysis and experiments of the model parameters.
- parallel_run_global.py: Script for executing global sensitivity analysis.
- plot.py: Provides functions used for plotting within the notebooks.
- extra_analysis.py: Additional scripts for experiments and analysis of model data.
- /static: Contains static resources used in the project, such as icons used in the simulation's GUI and plots generated from analysis notebooks.
Adrian Ruesink, Kenia Lopez, Milo Vollmuller, Nabila Siregar, Tad Price