Home

Awesome

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.

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

Bank Reserves Model

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

Color Patches Model

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.

Conway's Game Of "Life" Model (Fast)

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" Model on a Hexagonal Grid

Conway's game of life on a hexagonal grid.

Forest Fire Model

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

Hotelling's Law 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

Boltzmann Wealth Model with Network

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

Ant System for Traveling Salesman Problem

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

Visualization Examples

Charts Example

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

Shape Example

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

El Farol Model

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.

Schelling Model with Caching and Replay

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.