MASTIO (Multi-Agent Simulator for Territorial Input Output) is a simulation platform designed to model agent-based interactions in a market environment. It simulates buyers and sellers exchanging products, with agents learning and adapting their strategies over time. The platform includes features for visualizing market dynamics and analyzing agent behavior.
- Python 3.x
- pip (Python package installer)
- Clone the repository:
git clone https://github.com/matthieu-mastio/MASTIO.git cd MASTIO - Create a virtual environment (recommended):
python3 -m venv .venv
- Activate the virtual environment:
- On macOS/Linux:
source .venv/bin/activate - On Windows:
.venv\Scripts\activate
- On macOS/Linux:
- Install dependencies:
pip install -r requirements.txt
Simulations are configured using YAML files. An example configuration file (conf_example.yaml) is provided.
To run a simulation:
python MASTIO/run.py conf_example.yamlYou need to provide a product file that lists all available products and their characteristics. An example is provided in data/products_example.csv.
- name: Name of the product
- sellers_rate: The rate of agents discarding this product
- buyers_rate: The rate of agents needing this product
- market_price: The price at which this product can be bought on the main market
- km_cost: The transportation cost per km for this product
- scarcity: The availability of the product. A scarcity of 2 means demand is twice as high as supply
- price_to_dispose: The price a seller must pay if they cannot sell the product
Simulation results, including plots and regret analysis data, are saved in the directory specified by processed_path in the configuration file.
The core simulation logic resides in the MASTIO/ directory:
agent.py: Defines theAgentclass, representing market participants (buyers and sellers) and their learning mechanisms.area.py: Defines theSquareAreaclass, used for defining the geographical space of the simulation.auction.py: Implements theAuctionmechanism for matching buyers and sellers for a specific product.model.py: The main simulation model, orchestrating agent creation, simulation steps, and data collection.regret_analysis.py: Provides tools for analyzing agent regret, including counterfactual simulations.run.py: The entry point for running the simulation from the command line.utils.py: Utility functions, including distance calculations and normalization.visualization.py: Functions for generating various plots and animations of simulation results.
Contributions are welcome! Please refer to the project's contribution guidelines (if available) for more details.
This project is licensed under the MIT License. See the LICENSE file for details.
