This software is meant to support the research paper "Emergence of Specialised Third-Party Enforcement" by Erik Mohlin, Alexandros Rigos, and Simon Weidenholzer. It contains the tools that were used to produce the simulations and figures for the paper, as well as a demo script. All function definitions are found in ComEn-Definitions.jl
.
- System requirements
- Installagtion guide
- Demo
- Instructions for use
- Replication code for the paper's figures
The software only requires a standard computer.
The code is written in the Julia language (v1.7). Moreover, LaTeX should be installed on the system for the generation of some figures.
The software should be able to run on all major operating systems. It has been tested on the following systems:
- macOS: Catalina (10.15.7)
- Windows 10 (OS version 19044.1288)
- CSV (v0.10.4)
- ColorSchemes (v3.17.1)
- LaTeXStrings (v1.3.0)
- Measures (v0.3.1)
- PGFPlotsX (v1.4.1)
- Plots (v1.27.4)
- StatsBase (v0.33.16)
- Tables (v1.7.0)
- Distributed
- Random
- Download and install the Julia language from https://julialang.org/
- Download the software from github and move to the installation directory.
- If you use
git
and have access to a terminal, you can use the following commands to do that.$ git clone https://github.com/alex-rigos/Community-Enforcement $ cd Community-Enforcement
- If you do not have access to a terminal
- Navigate to https://github.com/alex-rigos/Community-Enforcement
- Click on the green
Code
button, and selectDownload ZIP
to download the ZIP file. - Unzip the file. This will create a folder called
Community-Enforcement-master
, where the files are found. - Open the Julia REPL and navigate it to the
Community-Enforcement-master
folder:for example.julia> cd("My\\Path\\Community-Enforcement-master") (On Windows) julia> cd("My/Path/Community-Enforcement-master") (On Mac/Linux)
- Install Julia dependencies:
- From the terminal
$ julia install.jl
- or from the Julia REPL
julia> include("install.jl")
After installing Julia, the installation of the required dependencies takes about 80 seconds.
Select the parameters to be used in the simulation by editing the file demo-params.jl
(and saving it). A short description of each parameter is included in this file. For more details, please see the paper.
The version of the demo-params.jl
file provided includes the parameter values for the baseline model and for a population of 50 agents with initial state generations
variable. Increasing this number will considerably affect execution times.
After setting the parameter values, you can run a simulation:
- From the terminal
$ julia demo-sims.jl
- or from the Julia REPL
julia> include("demo-sims.jl")
The script generates three output files, which are placed under the demo/
folder:
demo-data.csv
: simulation datademo-time-series.pdf
: population evolution period by perioddemo-time-avg.pdf
: strategy averages across all periods
The demo script takes approximately 65 seconds to execute the first time, as Julia needs to compile the source. After that, the script takes approximately 14 seconds to execute. These numbers are for 10,000 period-long simulations. Increasing the number of periods will significantly increase execution time.
To generate new data and figures like those in the paper, please follow the procedures laid out below. The scripts below use parallel processing to reduce execution time. To set the default parameter values for any of the data generation scripts below, edit the file ComEn-ParametersBaseline.jl
accordingly (and Save). All data-generation scripts below take considerable amounts of time to execute for the default parameter values (up to 30 minutes).
Run the script time-series-data-generation-multiple-IC.jl
. This creates a directory tree with root time-series-and-averages/time-series-data/
where the data are stored in files under the appropriate folders. The subfolder structure is as follows (in parent -> child order)
- Parameter list: Parameters and values that differ from the Baseline
- Reputation system (karma): karma 1 uses the CE reputation system; karma 2 uses the PE reputation system; karma 3 uses the following set of enforcer strategies:
${CE,PE,DE}$ . - Number of strategies: 4 strategies includes {CP,DP,CE,DE} under karma 1 and
${CP,DP,PE,DE}$ under karma 2. 18 strategies includes${CP,DP}$ as well as all the four-binary-digit combinations of enforcer strategies for each of karma 1 and karma 2. 5 strategies is only used under karma 3 and includes the strategies${CP,DP,CE,PE,DE}$ .
The files containing the data are named run-(number).csv
, where number
is used to differentiate between the 7 independent simulations that the code runs.
Run the script time-series-plots-multiple-IC.jl
. This will create the folder time-series-and-averages/time-series-plots/
, where the figures are stored under appropriately-named directories (see 4.1.1 above).
Run the script time-averages-plots-multiple-IC.jl
. This will create the folder time-series-and-averages/time-averages-plots/
, where the figures are stored under appropriately-named directories (see 4.1.1 above).
To generate the data, run the script comp-stat-data-generation.jl
. This will create data files in subfolders under the directory comp-stat/comp-stat-data/
. The subfolders are named with the variables for which the comparative statics computation is being conducted.
Parameter values are read from the ComEn-ParametersBaseline.jl
file. The parameters and parameter values for which the simulations are carried out can be edited in the comp-stat-data-generation.jl
file.
Run the script comp-stat-plots.jl
. This will create the folder comp-stat/comp-stat-plots/
, where the figures are stored for the data found in the comp-stat/comp-stat-data/
folder.
To generate the data, run the script fishtank-data-generation.jl
. This will create data files in the directory fishtanks/fishtank-data/
.
Parameter values are read from the ComEn-ParametersBaseline.jl
file. The population states for which the calculations are run can be edited in the fishtank-data-generation.jl
file.
Run the script fishtank-plots.jl
. This will create the folder fishtanks/fishtank-plots/
, where the figures are stored for the data found in the fishtanks/fishtank-data/
folder.
Replicate the paper's figures:
- From the terminal
$ julia paper-figures-replication.jl
- or from the Julia REPL
julia> include("paper-figures-replication.jl")
The scipt runs code that generates plots for the data that are found in subfolders under the paper-figures/
folder (and were used for the paper's figures). These subfolders are
time-series-and-averages/time-series-data/
comp-stat/comp-stat-data/
The script creates the following subfolders (under the paper-figures/
folder) where the generated figures are placed:
time-series-and-averages/time-series-plots/
time-series-and-averages/time-averages-plots/
comp-stat/comp-stat-plots/
The termsbaseline
andworse
in the filenames refer to the baseline and the alternative parameter combinations mentioned in the paper, respectively.