
ECOWHEATALY Repast4Py Model Documentation
Agent-based model of the wheat production system implemented in Repast4Py.
The model simulates interactions between farms, policy makers, and international market actors in order to analyse the effects of agricultural policies, environmental constraints, and market dynamics on wheat production and sustainability outcomes.
The model is part of the ECOWHEATALY research project.
Visit the github repository for browsing the source code.
Overview
ECOWHEATALY is an agent-based simulation model (ABM) designed to study:
- the behaviour of heterogeneous wheat farms
- policy interventions in agricultural systems
- international wheat market dynamics
- environmental impacts of agricultural production
The model integrates:
- farm decision-making
- policy incentives and constraints
- international buyers and producers
- sustainability indicators based on Life Cycle Assessment (LCA).
The model is implemented using Repast4Py, allowing scalable simulations with MPI parallel computing.
Model Architecture
The simulation includes several interacting agents:
| Agent | Description |
|---|---|
| Farm | Represents agricultural producers deciding production and input use |
| Policy Maker | Implements agricultural policy instruments |
| International Buyers | Demand wheat on the global market |
| International Producers | Compete with domestic production |
The main simulation engine coordinates:
- market sessions
- farm production decisions
- policy interactions
- environmental indicator computation.
Repository Structure
ecowheataly_repast4py_model
│
├── ecowheataly_repast_model.py # Main simulation model
├── params.py # Model parameters
│
├── agents/
│ ├── farm.py
│ ├── policy_maker.py
│ ├── international_buyer.py
│ └── international_producer.py
│
└── utils/
└── utils.py
Installation
The model requires Python and several scientific and simulation libraries.
Main dependencies include:
repast4pympi4pynumpypandasbrightway2(for environmental impact calculations)
A working MPI implementation must be installed in your computational setting. This is required by repast4py.
Follow the instructions in the Repast4py web site if you have not an MPI environment installed.
Then, proceed to the installation through the following commands:
git clone https://github.com/gfgprojects/ecowheataly_repast4py_model.git
cd ecowheataly_repast4py_model
python3 -m venv repast4py_venv #optional: create an environment
source repast4py_venv/bin/activate #optional: activate the environment
pip install mpi4py
env CC=mpicxx CXX=mpicxx pip install repast4py
At this point, in case you get an error about missed python.h file, install python development package. For example, in case of python 3.8 on Ubuntu Linux type
sudo apt install python3.8-dev
Then, continue the installation with the following commands
pip install -r requirements.txt
cd brightway
python setup01_brightway2_database_and_methods.py
python setup02_recipe_2016_ecowheataly_customization.py
python setup03_create_custom_databases_for_tractors_N_and_ecowheataly.py
python compute_inputs_and_lca.py #check if brightway works
cd ../ecowheataly
./run 5 #run the ecowheataly model using 5 ranks (a different number of ranks can be used)
In case of troubles
Install additional dependencies if needed:
pip install -r requirements1.txt
all dependencies are listed in requirements_all.txt
in case of troubles you can reinstall openmpi and mpi4py
sudo apt install libopenmpi-dev openmpi-bin
pip uninstall mpi4py
pip install mpi4py --no-cache-dir