Computational Model Library

The effect of homophily on co-offending outcomes (1.0.0)

This Agent-Based Model is designed to simulate how similarity-based partner selection (homophily) shapes the formation of co-offending networks and the diffusion of skills within those networks. Its purpose is to isolate and test the effects of offenders’ preference for similar partners on network structure and information flow, under controlled conditions.

In the model, offenders are represented as agents with an individual attribute and a set of skills. At each time step, agents attempt to select partners based on similarity preference. When two agents mutually select each other, they commit a co-offense, forming a tie and exchanging a skill. The model tracks the evolution of network properties (e.g., density, clustering, and tie strength) as well as the spread of skills over time.

This simple and theoretical model does not aim to produce precise empirical predictions but rather to generate insights and test hypotheses about the trade-off between network stability and information diffusion. It provides a flexible framework for exploring how changes in partner selection preferences may lead to differences in criminal network dynamics. Although the model was developed to simulate offenders’ interactions, in principle, it could be applied to other social processes involving social learning and skills exchange.

More information about the model can be found in the associated publication.

Pasted image (2).png

Release Notes

Code Structure

├── src/ # Source files for the model
│ ├── agent.py # Agents’ behavior setup
│ ├── description.txt # Description file for interactive mode
│ ├── model.py # Environment setup and model logic
│ └── server.py # Server view for interactive mode
├── requirements.txt # List of required Python packages
├── run.py # Launches the model in interactive mode
└── simulation_run.py # Runs the model in batch mode with parameter sweeps


Instructions to Set Up and Run the Model

  1. Create a new Python environment

    python -m venv homophily_abm

  2. Activate the environment

    • Unix/macOS
      source homophily_abm/bin/activate
    • Windows
      homophily_abm\Scripts\activate
  3. Install required packages

    pip install -r requirements.txt

  4. Run the model in interactive mode

    python run.py

  5. Run the model in batch mode

    First, adjust the input parameters in simulation_run.py (lines 9–15), then run:

    python simulation_run.py


Interactive Mode

  1. Set the desired parameters in the left panel.
  2. Click “Start” to run the model continuously, or “Step” to advance it one step at a time.
  3. Click “Reset” to reinitialize the model with the selected parameters.

Note: Interactive mode is not intended to produce output files. It is mainly used to observe how the network evolves over time and to track the cumulative number of co-offenses. Additional metrics can be added by modifying src/server.py.


Batch Mode

  1. Set input parameters in simulation_run.py (lines 9–15).
  2. To explore a single value:
    n_agents = 50 # or n_agents = [50]
  3. To explore multiple values:
    n_agents = [2, 50, 100]
  4. The model will run for each combination of input parameters.

Please refer to the official documentation for more details about the Mesa package: https://mesa.readthedocs.io/stable/.

Associated Publications

Ruslan Klymentiev, Luis E. C. Rocha, Christophe Vandeviver (2025). Homophily promotes stable connections in co-offending networks but limits information diffusion: insights from a simulation study. Crime Science, 14(1). https://doi.org/10.1186/s40163-025-00254-w

Consortium, C. (2025). Crimversations: “Homophily promotes stable connections in co-offending networks but limits information diffusion: insights from a simulation study.” CrimRxiv. https://doi.org/10.21428/cb6ab371.e073c85a

The effect of homophily on co-offending outcomes 1.0.0

This Agent-Based Model is designed to simulate how similarity-based partner selection (homophily) shapes the formation of co-offending networks and the diffusion of skills within those networks. Its purpose is to isolate and test the effects of offenders’ preference for similar partners on network structure and information flow, under controlled conditions.

In the model, offenders are represented as agents with an individual attribute and a set of skills. At each time step, agents attempt to select partners based on similarity preference. When two agents mutually select each other, they commit a co-offense, forming a tie and exchanging a skill. The model tracks the evolution of network properties (e.g., density, clustering, and tie strength) as well as the spread of skills over time.

This simple and theoretical model does not aim to produce precise empirical predictions but rather to generate insights and test hypotheses about the trade-off between network stability and information diffusion. It provides a flexible framework for exploring how changes in partner selection preferences may lead to differences in criminal network dynamics. Although the model was developed to simulate offenders’ interactions, in principle, it could be applied to other social processes involving social learning and skills exchange.

More information about the model can be found in the associated publication.

Release Notes

Code Structure

├── src/ # Source files for the model
│ ├── agent.py # Agents’ behavior setup
│ ├── description.txt # Description file for interactive mode
│ ├── model.py # Environment setup and model logic
│ └── server.py # Server view for interactive mode
├── requirements.txt # List of required Python packages
├── run.py # Launches the model in interactive mode
└── simulation_run.py # Runs the model in batch mode with parameter sweeps


Instructions to Set Up and Run the Model

  1. Create a new Python environment

    python -m venv homophily_abm

  2. Activate the environment

    • Unix/macOS
      source homophily_abm/bin/activate
    • Windows
      homophily_abm\Scripts\activate
  3. Install required packages

    pip install -r requirements.txt

  4. Run the model in interactive mode

    python run.py

  5. Run the model in batch mode

    First, adjust the input parameters in simulation_run.py (lines 9–15), then run:

    python simulation_run.py


Interactive Mode

  1. Set the desired parameters in the left panel.
  2. Click “Start” to run the model continuously, or “Step” to advance it one step at a time.
  3. Click “Reset” to reinitialize the model with the selected parameters.

Note: Interactive mode is not intended to produce output files. It is mainly used to observe how the network evolves over time and to track the cumulative number of co-offenses. Additional metrics can be added by modifying src/server.py.


Batch Mode

  1. Set input parameters in simulation_run.py (lines 9–15).
  2. To explore a single value:
    n_agents = 50 # or n_agents = [50]
  3. To explore multiple values:
    n_agents = [2, 50, 100]
  4. The model will run for each combination of input parameters.

Please refer to the official documentation for more details about the Mesa package: https://mesa.readthedocs.io/stable/.

Version Submitter First published Last modified Status
1.0.0 Ruslan Klymentiev Fri Sep 26 19:22:46 2025 Mon Sep 29 07:42:42 2025 Published Peer Reviewed DOI: 10.25937/3vah-2a07

Discussion

This website uses cookies and Google Analytics to help us track user engagement and improve our site. If you'd like to know more information about what data we collect and why, please see our data privacy policy. If you continue to use this site, you consent to our use of cookies.
Accept