Skip to content

jonas4climate/honeybee-colony-abm

Repository files navigation

Honeybee colony ABM

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.

Repository structure

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 folder
  • figures folder contains plots and graphs used in our work and generated from the experimental data using the visualization.ipynb notebook
  • src folder contains all of the source code files of the ABM model and server functionality
    • model folder contains source code relating to our honey bee foraging ABM
      • agents folder contains .py files corresponding to three types of agents used in the model: BeeSwarm, Hive and Resource implementing Mesa's Agent class
      • config folder contains all the constants and default parameter values used in the simulations
        • BeeswarmConfig.py, HiveConfig.py and ResourceConfig.py define constants and default parameters for three types of agents, accordingly
        • ModelConfig.py defines additional, global model constants
        • VisualConfig.py contains constants used in JS server visualization
        • SensitivityAnalysisConfig.py contains parameter ranges for the OFAT sensitivity analysis scripts
      • util folder contains additional utility files for analytics, resource placement functionality and model enums
      • Model.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)

Environment setup

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.

JS server visualization

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.

Reproducing the experiments

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.

About

Agent-based modelling project and complexity analysis for Agent-based Models class (2024) @ UvA

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5