This project simulates the spreading of information on a lattice using an agent-based model (ABM). It was originally developed as part of a bachelor internship in C and later transcribed into Python. The simulation aims to replicate the findings from the paper:
- "2007 - Agliari, Burioni, Cassi, Neri - Universal Features of Information Spreading Efficiency on d-Dimensional Lattices"
The current Python version focuses on visualizing and analyzing how information spreads among agents on a one-dimensional lattice.
The primary objective of this project is to simulate the dynamics of information spreading on a lattice where agents can be informed or uninformed. The simulation tracks how long it takes for all agents to become informed when they interact according to specified rules.
- Agent-Based Modeling: Agents move randomly and exchange information based on their neighbors' states.
- Visualization: The lattice and agent states are visualized using graphical plots.
- Configurable Simulation: The simulation parameters, such as lattice length and number of agents, can be defined through a configuration file.
- Incomplete Features: Several features from the original C implementation are still pending, including:
- Results analysis
- Extension to higher-dimensional lattices
- Simplified Visualization: Currently, visualization is limited to one-dimensional lattices.
Agent
: Represents a single agent with a position and state (informed or uninformed).Agents
: Manages a collection ofAgent
objects, including initialization, movement, and information exchange.Simulation
: Orchestrates the simulation process, including setting up the lattice, running the simulation, and collecting statistics.Visualization
: Provides methods for visualizing the lattice and agent states.
agent.py
: Contains theAgent
class definition.agents.py
: Contains theAgents
class definition and interactions with theAgent
class.visualization.py
: Contains theVisualization
class for plotting and printing lattice states.simulation.py
: Manages the overall simulation logic, including initializing the lattice and running the simulation.main.py
: Entry point for running simulations. Reads configuration from a JSON file, executes simulations, and saves results.
Contains tests for the Agent
class, including initialization and movement functionalities.
Contains tests for the Agents
class, including:
- Initialization with a lattice.
- Information exchange logic.
- Movement and positioning of agents.
Note: The tests in this file are currently incomplete and may require additional coverage and validation.
Contains tests for the Simulation
class, including:
- Initialization with different lattice sizes and agent counts.
- Running simulations and validating the number of steps required for all agents to be informed.
Contains tests for the Visualization
class, ensuring that the visualization methods work correctly.
-
Configuration: Define simulation parameters in
config.json
.{ "simulations": [ { "lattice_length": 20, "num_agents": 10 }, { "lattice_length": 30, "num_agents": 15 }, { "lattice_length": 40, "num_agents": 20 } ] }