Agent-based modelling project and complexity analysis for Agent-based Models class (2024) @ UvA. This is the corresponding code repository for a research report investigating honey bee colony survival outcomes and emergent adaptation on the colony level in response to weather effects and resource scarcity and distribution. The presentation can be found here.
This repository has the following file structure:
data
folder is where generated data from experiments is stored. By default, most scripts will load data from this folderfigures
folder contains plots and graphs used in our work and generated from the experimental data using thevisualization.ipynb
notebooksrc
folder contains all of the source code files of the ABM model and server functionalitymodel
folder contains source code relating to our honey bee foraging ABMagents
folder contains.py
files corresponding to three types of agents used in the model:BeeSwarm
,Hive
andResource
implementing Mesa's Agent classconfig
folder contains all the constants and default parameter values used in the simulationsBeeswarmConfig.py
,HiveConfig.py
andResourceConfig.py
define constants and default parameters for three types of agents, accordinglyModelConfig.py
defines additional, global model constantsVisualConfig.py
contains constants used in JS server visualizationSensitivityAnalysisConfig.py
contains parameter ranges for the OFAT sensitivity analysis scripts
util
folder contains additional utility files for analytics, resource placement functionality and model enumsModel.py
contains the baseline logic of the model itself implementing Mesa's Model class
server
folder contains files related to JS server visualization (see below for usage)
To set up the environment, we recommend the use of conda (install conda or install miniconda). The environment can then be set up by running conda env create -f environment.yml
. Then run conda activate abm-bees
before running any python scripts. Alternatively, the environment.yml
file can be converted for use with pip
if preferred.
Mesa's visualization module provides functionality for animated simulation of the model. To run the simulation, open the terminal in the root directory of this repo and run mesa runserver
. This starts the run.py
file, which opens the server. This uses simple_continuous_canvas.js
and SimpleContinuousModule.py
under the hood which are used to visualize Mesa's ContinuousSpace grid. By default, the settings of the server refers to the clustering experimentation setup. Other sliders and parameters to vary can be adjusted in the server folder.
The following experimental scripts are contained in this repository:
experiment_baseline_dynamics.py
experiment_resource_clustering.py
experiment_resource_scarcity.py
experiment_weather_effects.py
Additionally, sensitivity analysis scripts are the following:
ofat_sensitivity_analysis_bee_parameters.py
ofat_sensitivity_analysis_initial_conditions.py
All of these experimental scripts described in our work are located in the root folder of the project. Simply run the experiment with the corresponding name to recreate the experiment of interest. Keep in mind, that running all experiments may take a couple of hours / days depending on your machine hardware. To ensure that new data is generated, the load data flag in experiment scripts has to be set to False
. Visualizations of the data generated by experiments is done in the visualization.ipynb
notebook. For replication of results of the project, it is sufficient to simply run the visualization.ipynb
notebook line by line. The pre-computed data will be loaded in this case.