Skip to content

projectmesa/mesa-examples

Repository files navigation

Mesa Examples

Core Mesa examples

The core Mesa examples are available at the main Mesa repository: https://github.com/projectmesa/mesa/tree/main/mesa/examples

Those core examples are fully tested, updated and guaranteed to work with the Mesa release that they are included with. They are also included in the Mesa package, so you can access them directly from your Python environment.

Mesa user examples

This repository contains user examples and showcases that 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.

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.

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.

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.

Continuous Space Examples

No user examples available yet.

Network Examples

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

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

Visualization Examples

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.