A model of corruption

View the Project on GitHub javirk/Corruption

Corruption Model


This program developed entirely under Python reproduces a simple stochastic agent-based model of corruption using Monte Carlo method. It also contains code for the implementation of a non-stationary Markov model designed specifically for the model.


It basically has 3 main files that run independently:


The first two programs refer to the non-stationary Markov model. The main.py uses the class puebloClase in the folder Clases to create a village where the Monte Carlo algorithm will be used.

More information

The code itself also has functions to create scale-free and Erdös-Renyi networks that the program uses for the simulations. The networks are to be saved in the Input folder for the program to use them properly. Also, the classes that generate them is in the Clases/RedClase.py. There you'll find two different classes depending on which type of network you want to generate.

In case you want to generate networks and use them separately from the main program a folder named Output with the same structure as the Input folder must be created. Also, examples of networks with N=1000 and k=6 have been saved in zip files in the Input folder.

To run the program you must create a folder named Resultados with the following folders in it:


Depending on the program you want to run (two folders for Markov [Estacionario] and one for Monte Carlo). After that, the folders are created automatically by the program.


Monte Carlo

Everything should be self explanatory just looking at the files. However I will explain it here too: to run the main program, the route for the settings file is Settings/settings.ini. Due to the high times of compuyting, I strongly recommend not to change the parameters for the networks (N=1000 and k=6) other than tipoRed. If archivoRed = True, the program will try to find networks in the Input folder.

In the [Ejecucion] part, the parameter metodo can't be changed or the program will stop working.

In [Version], 2 is used for the 4p model and the parameters delta1 and delta2 in [Sistema] won't be considered.

If everything is set correctly, a folder inside Montecarlo or MontecarloPar will be created.


The file Settings/SettingsES.py should be edited for this. It's just roughly the same as before.

Phase portrait

The code in the folder Scripts generates a file Slider.html whose result can be seen here. It is a dynamic phase portrait, the parameters and model can be changed live.

Authors and Contributors

This is an academic study and the code uploaded here is only written by Javier Gamazo.