projectmesa / mesa-examples

Seminal agent-based models developed using Mesa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 main development branch are available here on the main branch.
  • Mesa examples that work for Mesa 2.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/mesa-examples@mesa-2.x#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.

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.

Visualization Examples

Boltzmann Wealth model with the experimental Juptyer notebook visualization feature.

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

Schelling segregation model with the experimental Juptyer notebook visualization feature.

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

License:Other


Languages

Language:Python 73.8%Language:NetLogo 26.2%