Skip to content

Seminal agent-based models developed using Mesa

License

Notifications You must be signed in to change notification settings

EwoutH/mesa-examples

 
 

Repository files navigation

Mesa Examples

This repository contains examples that work with Mesa and illustrate different features of Mesa. For more information on each model, see its own Readme and documentation.

  • Mesa examples that work on the Mesa and Mesa-Geo main development branches are available here on the main branch.
  • Mesa examples that work with Mesa 2.x releases and Mesa-Geo 0.8.x releases are available here on the mesa-2.x branch.

To contribute to this repository, see CONTRIBUTING.rst.

This repo also contains a package that readily lets you import and run some of the examples:

$ # This will install the "mesa_models" package
$ pip install -U -e git+https://github.com/projectmesa/mesa-examples#egg=mesa-models

For Mesa 2.x examples, install:

$ # This will install the "mesa_models" package
$ pip install -U -e git+https://github.com/projectmesa/[email protected]#egg=mesa-models
from mesa_models.boltzmann_wealth_model.model import BoltzmannWealthModel

You can see the available models at setup.cfg.

Table of Contents

Grid Space Examples

A highly abstracted, simplified model of an economy, with only one type of agent and a single bank representing all banks in an economy.

Completed code to go along with the tutorial on making a simple model of how a highly-skewed wealth distribution can emerge from simple rules.

A cellular automaton model where agents opinions are influenced by that of their neighbors. As the model evolves, color patches representing the prevailing opinion in a given area expand, contract, and sometimes disappear.

Implementation of Conway's Game of Life, a cellular automata where simple rules can give rise to complex patterns.

A very fast performance optimized version of Conway's Game of Life using the Mesa PropertyLayer. About 100x as fast as the regular versions, but limited visualisation (for now).

Conway's game of life on a hexagonal grid.

Grid-based demographic prisoner's dilemma model, demonstrating how simple rules can lead to the emergence of widespread cooperation -- and how a model activation regime can change its outcome.

Joshua Epstein's model of how a decentralized uprising can be suppressed or reach a critical mass of support.

Simple cellular automata of a fire spreading through a forest of cells on a grid, based on the NetLogo Fire model.

This project is an agent-based model implemented using the Mesa framework in Python. It simulates market dynamics based on Hotelling's Law, exploring the behavior of stores in a competitive market environment. Stores adjust their prices and locations if it's increases market share to maximize revenue, providing insights into the effects of competition and customer behavior on market outcomes.

Mesa implementation of the classic Schelling segregation model.

This is Epstein & Axtell's Sugarscape Constant Growback model, with a detailed description in the Chapter Two of Growing Artificial Societies: Social Science from the Bottom Up. It is based on the Netlogo Sugarscape 2 Constant Growback model.

This is Epstein & Axtell's Sugarscape model with Traders, a detailed description is in Chapter four of Growing Artificial Societies: Social Science from the Bottom Up (1996). The model shows an emergent price equilibrium can happen via a decentralized dynamics.

Implementation of an ecological model of predation and reproduction, based on the NetLogo Wolf Sheep Predation model.

Continuous Space Examples

Boids-style flocking model, demonstrating the use of agents moving through a continuous space following direction vectors.

Network Examples

This is the same Boltzmann Wealth Model, but with a network grid implementation.

This model is based on the NetLogo Virus on a Network model.

This is based on Dorigo's Ant System "Swarm Intelligence" algorithm for generating solutions for the Traveling Salesman Problem.

Visualization Examples

Boltzmann Wealth model with an optional visualization using Streamlit.

A modified version of the Bank Reserves example made to provide examples of Mesa's charting tools.

Example of grid display and direction showing agents in the form of arrow-head shape.

GIS Examples

Vector Data

Raster Data

Raster and Vector Data Overlay

Other Examples

This folder contains an implementation of El Farol restaurant model. Agents (restaurant customers) decide whether to go to the restaurant or not based on their memory and reward from previous trials. Implications from the model have been used to explain how individual decision-making affects overall performance and fluctuation.

This example applies caching on the Mesa Schelling example. It enables a simulation run to be "cached" or in other words recorded. The recorded simulation run is persisted on the local file system and can be replayed at any later point.

About

Seminal agent-based models developed using Mesa

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 78.6%
  • NetLogo 17.4%
  • Jupyter Notebook 4.0%