Professional Documents
Culture Documents
Barış Ekdi
6/22/2007
Barış EKDi STPS 514 –Final Project
by
BARIŞ EKDĐ
FINAL PROJECT
• Table of Outputs
2
Barış EKDi STPS 514 –Final Project
By Barış EKDĐ
1. THE MODEL
THE CRIME & PUNISHMENT MODEL shares some characteristics of the Schelling’s
Segregation Model and the J.M. Dalle’s Model in terms of local interactions and heterogeneity;
but also has different characteristics, such as learning/ individual memory, two-way interaction,
individuality and transition of agents. The aim of the model is to show the different outcomes of
the different policies in a given time period (i.e. in t turns.) and explore the possibilities of
reaching a criminal-free world.
Those four groups of agents, namely Policemen, Criminals, Warners and Ignorers, have some
common properties, such as recording/knowing with how many agents from each group they
interact through the simulation and thus behave accordingly. And, if the certain conditions are
met, some of the agents from one group (i.e. a Criminal) transform into another group, (i.e.
Ignorer. or vice versa). The Policemen do not transform into another type; unless the
Policemen/Criminals ratio is set to specific percentage as a policy option.
At initial step there are n number of agents from those four groups are placed onto the matrix
randomly. The user sets the number of the agents from each group (or default by the program).
There are four policy options provided for the user; and the user must choose one of them at
initial step. She cannot change those options after the simulation is started:
(a) Fix POL/CRM Rate – (STRATEGY 1) Normally Policemen (POL) do not transform into
other agents throughout the simulation process. However, if this option is chosen, the
program adjusts the number of policemen to the ratio set; first by converting required
number of Warners (WRN) into Policemen, and if there are no Warners left Ignorers
(IGN) are converted into Policemen before the next turn.
3
Barış EKDi STPS 514 –Final Project
jail, and as those numbers are increased the costs of the government increases…). This is
a kind of variable cost, and changes according to the number of Criminals punished. So,
it increases in line with the number of Criminals.
(c) Increase Public Awareness – (STRATEGY 3) : Increase public awareness – This option
aims at creating public awareness, and thus Ignorers are transformed into Warners
throughout the simulation. This is done by decreasing parameter IGNPOL (which will be
explained below in detail). In order to raise the public awareness, the executives must
also bear some costs, comparatively less then the costs of applying policies (a) and (b).
This cost occurs each turn, as long as there are criminals, but it is independent from the
number of agents of any type.
(d) Do Nothing – Which means the interactions will solely be conducted according to the
interaction table.
Heterogeneity: There are 4 groups of agents: Policemen, Criminals, Warners and Ignorers.
Learning: Each group has some common characteristics, such as memory / ability to learn.
Transition: An agent from one type can transform into another one.
Local Interaction: There are rule based and two way local interactions for each type of
agent.
Global Interaction: If POL/CRM ratio is fixed, the number of criminals affects the
transition of Policemen, and in addition costs are calculated globally.
Individuality: Individuality matters, since agents learn, interact and transform on individual
basis.
4
Barış EKDi STPS 514 –Final Project
(1) The parameters are set and initial costs are calculated.
(2) All agents are placed onto the matrix randomly. (The number of agents from each group is
set beforehand by the user).
(3) From the first cell to the last one, the agent occupying the cell interacts with its k neighbours.
(The neighbours are located on the surrounding cells and an agent has eight neighbours
typically).
(4) Each interaction with a neighbour occurs according to the Interaction Table given below.
The type and other characteristics of the neighbour is recorded mutually, and calculations for
the next move is based on them (–i.e. if the agent focused is a Criminal and the neighbour
being interacted with is a Policeman; the Criminal is punished. New properties of agents
(whether the type of the agent will change, the number of interactions according to the
groups etc.) are set for the next turn.
(5) Benefits provided (i.e. decrease in the number of Criminals, increase in the number of
Warners) and Costs occurred in that turn is calculated.
(6) Steps from (2) to (5) are run until the number of turns set by the user is reached; or there are
no criminals left.
Criminal Ignorer : A Criminal becomes Ignorer, after Correction. Correction occurs after
CRMPOL times of Punishment (Since Punishment is a result of an interaction
with a Policeman; a Criminal becomes an Ignorer after certain number of
interaction with a Policeman) or CRMWRN times of Warning (interaction
with a Warner).
Ignorer Criminal : An Ignorer becomes a Criminal after IGNCRM times of interaction with
a Criminal.
Warner Ignorer : Warners may become tired and lose their incentives after WRNCRM times
of interaction with Criminals.
5
Barış EKDi STPS 514 –Final Project
Ignorer Warner : Ignorers become Warners after IGNPOL times of interaction with
Policemen.
Warner Policeman: Warners become Policemen only if there is a POL/CRM ratio set and new
Policemen are required due to the increase in the number of Criminals.
Policemen Warner: Policemen become Warners only if there is a POL/CRM ratio set and there
is excess number of Policemen on the matrix.
If POL/CRM ratio is
If POL/CRM ratio
Police N/A NEVER (directly) fixed and there are no
is fixed.
Warners Left.
After CRMPOL
first it must
times with Police,
Criminal NEVER (directly) N/A become an
Ignorer or CRMWRN times
with Warners
6
Barış EKDi STPS 514 –Final Project
In this world, there are bi-directional local interactions with cumulative effects. Interactions are
bi-directional, because when two agents come across they affect each other in a different way.
For example, when a Criminal interacts with a Warner, it becomes a little bit closer to
correction, and thus being an Ignorer. Meanwhile, the Warner is affected, too; and it becomes
closer to transforming into an Ignorer.
The complete table of the effects of interactions among the agents is given below. At each
interaction two cells of the table is used. (i.e. when Police interacts with a Criminal, both
PoliceCriminal and CriminalPolice cells are used.)
Punish
Increase vCRM Increase VCRM
ed(Increase
Criminal N/A of the Warner of the Warner
vPol of the
(3) (4)
CRM) (2)
Increase
Warner Nothing vWRN of the N/A Nothing
Criminal(5)
Increase VPol
Ignorer of the ignorer. Nothing Nothing N/A
(6)
(1) Policemen are not affected from the interaction with other agents.
(2) Criminal is affected; and becomes one-step closer to being an Ignorer.
(3) Criminal is affected; and becomes one-step closer to being an Ignorer.
(4) Ignorer is affected; and becomes one-step closer to being a Criminal.
(5) Warner is affected; and becomes one-step closer to being an Ignorer.
(6) Ignorer is affected; and becomes one-step closer to being a Warner.
Each agent defined as an object, with certain properties listed below. Agent No does not change
through the simulation, but the AgentType (thus the Colour) changes at some points, provided
that the agent is not a Policeman, and transition for that agent occurs. Likewise, Position of the
Agent changes randomly at each turn, and the other four properties (i.e. memories of interaction)
changes each turn, according to the interactions took place. Lastly if the agent is due a transition
on the next turn, NextType defines the type of the agent to be placed onto the matrix.
7
Barış EKDi STPS 514 –Final Project
Table of Properties of
Police Criminal Warner Ignorer
the Agents
AgentNo n N n n
# of # of # of
# of
Interactions Interactions Interactions
Interactions
vPolice with with with
with
Policemen – Policemen – Policemen –
Policemen
No effects RCORT RPAW
# of # of # of # of
Interactions Interactions Interactions Interactions
vCrim with with with with
Criminals - Criminals – Criminals – Criminals -
RCORP No effects RGIVEUP No effects
# of
# of # of # of
Interactions
Interactions Interactions Interactions
vWarn with
with Warners with Warners with Warners
Warners
- No effects - RCORT No effects
No effects
# of # of # of # of
Interactions Interactions Interactions Interactions
vIgn
with Ignorers with Ignorers with Ignorers with Ignorers
No effects No effects No effects No effects
Type to be Type to be Type to be
transformed transformed transformed
NextType N/A into at next into at next into at next
turn; if turn; if turn; if
necessary necessary necessary
There are numerous parameters used in the model, however it is expected that only one of them
will be chosen to compare the outcomes of the simulations with different values. Those
parameters are:
Number of Agents is total number of agents subject to simulation. This is also equal to the
number of cell in the matrix. (i.e. a 30x30 world there will be 900 agents
available.). It is the sum of all four types of agents.
8
Barış EKDi STPS 514 –Final Project
Number of Policemen is a percentage of the whole population (number of agents) and do not
change during the simulation – unless a POL/CRM ratio is set.
Number of Criminals is a percentage of the whole population, and do change through the
interactions during the simulation:
Number of Warners is a percentage of the whole population, and change through the
interactions during the simulation:
Number of Ignorers is a percentage of the whole population, and change through the
interactions during the simulation:
CRMPOL the parameter defines the required number of interactions of a Criminal with
Policemen in order to convert the Criminal to Ignorer.
CRMWRN the parameter defines the required number of interactions of a Criminal with
Warners in order to convert the Criminal to Ignorer.
WRNCRM the parameter defines the required number of interactions of a Warner with
Criminals in order to convert the Warner to Ignorer.
IGNPOL the parameter defines the required number of interactions of an Ignorer with
Policemen in order to convert the Ignorer to a Warner.
IGNCRM the parameter defines the required number of interactions of an Ignorer with
Criminals in order to convert the Ignorer to a Criminal.
CostPolUnit the parameter defines the unit cost of increasing the number of Policemen.
This cost depends on the number of Policemen; and occurs at each turn of the
simulation.
CostPawUnit the parameter defines the unit cost of increasing Public Awareness. This cost
applies at each interaction of an Ignorer with a Policeman.
CostEffUnit the parameter defines the unit cost of punishing a Criminal. This cost
increases at each interaction of Criminal with a Policeman.
9
Barış EKDi STPS 514 –Final Project
2. THE PROGRAM
The Program is written using Microsoft Visual Basic 6.0. The startup screenshot of the program
is as follows:
Settings Frame: A graphical user interface (GUI) is used for getting the required parameters
from the user, in order to run the simulation. As the program starts, default parameter are loaded
and a matrix drawn according to those values, and re-drawn whenever the user changes the size
of the matrix.
World Size & Agents: Combo box used to get the size of the matrix and the number of the
agents; and percentages of the agents living in the population are set using the text boxes
available.
10
Barış EKDi STPS 514 –Final Project
CRM v POL -> IGN @: Sets CRMPOL parameter, which is used to define after how many
times of interaction with a policeman (POL) a criminal (CRM) will be
transformed into an ignorer (IGN).
CRM v WRN -> IGN @: Sets CRMWRN parameter, which is used to define after how many
times of interaction with a warner (WRN) a criminal (CRM) will be
transformed into an ignorer (IGN).
WRN v CRM -> IGN @: Sets WRNCRM parameter, which is used to define after how many
times of interaction with a criminal (CRM) a warner (WRN) will be
transformed into an ignorer (IGN).
IGN v POL -> WRN @: Sets IGNPOL parameter, which is used to define after how many times
of interaction with a policeman (POL) an ignorer (IGN) will be transformed
into an warner (WRN).
IGN v CRM -> CRM @: Sets IGNCRM parameter, which is used to define after how many
times of interaction with a criminal (CRM) an ignorer (IGN) will be
transformed into a criminal (CRM).
Fix POL/CRM Rat@ % : If the strategy (STRATEGY=1) to fix the number of POL in the matrix
in proportion to the number of CRMs, this option button and text box is used to
set the strategy and parameters.
Inc/Dec Pub. Awareness: If the strategy (STRATEGY=3) to increase the effectiveness through
decreasing IGNPOL parameter this option is used; and also the textbox is used
to set the cost (CPaw) associated with the policy option.
Do Nothing: If the strategy Do Nothing (STRATEGY=0) is chosen, POL/CRM ratio is not fixed;
and no public awareness is available.
Number of Turns to Run: Textbox is used to set the number of times the simulation will run.
Early Stop Available: Check box is used to make early termination available.
11
Barış EKDi STPS 514 –Final Project
Buttons:
RUN SIM : Gets the parameters, starts the simulation and draws the new matrix.
BACK to INIT : Draws the initial matrix –i.e. positioning of the agents.
GRAPH : Shows the transformation of the agents graphically for each turn.
SEE COSTS : Shows the detailed costs of the strategies occurred at each turn
SAVE FILES : Saves the output of the simulation to “C:\” in 4 files: A TXT file is used
for detailed process and output; and another one for the costs. The World
(Matrix) and the Agent Transition Graphs are saved as BMP files.
RESTART : Restarts the simulation after initializing all of the values and parameters.
Windows:
World Window: The agents placed onto the matrix are shown graphically.
Detailed Process and Output Window: This window is used in order to inform the user about
almost each step of the process the program is executing. Therefore the user
can check the calculations and save it for further use.
12
Barış EKDi STPS 514 –Final Project
A simple pseudo-algorithm is given below in order to explain how the program runs:
(1) At startup, default parameters and a random matrix are loaded. and user input is waited.
(2) After the user sets default parameters, starting from the first cell, for each cell on the matrix;
• the program gets the relevant data (previous interaction values i.e. “memory”) about the
agent “k” occupying the cell; and defines the neighbours ( three for the ones at the
corners, five for the edges and eight for the ones in the middle) ;
• agent “k” interacts with its neighbours according to the interaction table (See previous
sections for the table). For example, if the agent is criminal (CRM) and if it is third
encounter with a police (POL) (and if CRMPOL parameter =3) the agent will be
“corrected” before next turn and become an ignorer (IGN). [thus the information that it
will change its type (Agt().NextType property is registered as IGN ].
(3) After all cells are processed; the program sets the relevant values of agents (value of the
NextType variable of the Agent copied to its Type variable etc.) and the number of agents is
adjusted (if POL/CRM ratio is set). [Agents are differentiated in this stage, since each of them
has its own history of interaction and processed according to that].
(4) Agents are placed onto the matrix randomly for the next turn.
(5) Steps from (2) to (4) are run until the number of turns set by the user is reached; or there are
no criminals left (if EARLYSTOP option is checked).
13
Barış EKDi STPS 514 –Final Project
The simulation program is run for 70 times with different parameters and strategy options; in
order to compare the effects of differences in those parameters.(Before starting it must be
underlined that; there are 7 sizes of matrix, (so 7 different population options); 104 ways of
placing the agents initially with different percentages onto the matrix; 5 different parameters
(which can accept any positive integer as value) for interaction; 4 strategy options and 3 cost
options. Therefore, there are limitless numbers of compositions practically available for
assessment. )
So, the framework of the analysis is limited to one size of matrix; runtime is limited to 100 and
cost options are changed only in a few instances; in order to focus on the interaction process of
the agents.
As seen in Annex-I; first three runs are like test runs, and only the value of CRMPOL parameter
increased; runs numbered 4-18 show the different outcomes of CRMPOL and IGNCRM
parameters; while runs 19-27 deal with the interaction of CRMPOL, IGNCRM and CRMWRN.
In runs 1-27 the STRATEGY chosen is 2 (i.e. increase the efficiency; thus change interaction
effectiveness of CRMPOL).
On the other hand, in runs 28-33 STRATEGY 3 (i.e. increase public awareness by changing
IGNPOL) is employed; and parameters changed slightly.
Simulations 34-73 are occupied with STRATEGY 1; which fixes the number of POL to CRM in
a given ratio: The number of CRM increases, so does the number of POL; and while number of
CRM decreases the number of POL decreases as well…
The results and analysis of those simulations are explained in detail below:
14
Barış EKDi STPS 514 –Final Project
In order to see the interaction of CRMPOL with IGNCRM the simulation is run with different
values regarding those parameters. Therefore, it is anticipated that IGNCRM parameter will
have a counterbalancing effect on the CRMPOL value; as such while CRMPOL converts
CRMs to IGNs; IGNCRM parameter converts IGNs to CRMs.
This prediction came true, since none of the runs stopped before the programmed number of
turns (=100) due to the termination of CRMs; on the contrary number of CRMs increased as
IGNCRM increased: ıt is also thought that the speed of increase in the number of CRMs is as a
result of having more IGNs and CRMs in the system compared to POLs.
It is also observed that smaller the number of IGNCRM greater the number of CRMs in the
world; and the system reaches a kind of equilibrium by swapping the CRMs and IGNs
asymmetrically:
15
Barış EKDi STPS 514 –Final Project
In run 19, the value for all three parameters (CRMPOL, IGNCRM and CRMWRN) is set to 5;
and it is seen that the program terminates at 22nd run.
On the other hand, decrease in CRMWRN(3) supports CRMPOL(5); while providing the
program stop at 8th turn. However, when the parameters CRMPOL and CRMWRN set to 3, and
5 respectively the speed of terminating CRMs slows down, probably due to the small number
POLs compared to WRNs.
When parameter IGNCRM is less more than 5, CRMs loose their chance of surviving (Runs 24-
25) chance to survive; and introducing CRMWRN parameter (at Run 23) which increases the
number of IGNs is not enough for this termination. However, when four parameters at equal
values (which is 5) the system finds a balance among those agents at least up to 200 turns (Run
27).
16
Barış EKDi STPS 514 –Final Project
Run 19: CRMPOL= IGNCRM =CRMWRN=5 Run 22: CRMPOL=3; IGNCRM =5; CRMWRN=3
Run 24: CRMPOL=3; IGNCRM =9; CRMWRN=6 Run 27: CRMPOL=5; IGNCRM =5; CRMWRN=5; CRMIGN=5
Strategy 3 involves introducing IGNPOL parameter; which converts IGNs to WRNs; therefore
lessens the survival chance of CRMs. If all four parameters are equal at 5; then the program
stops at 9th turn with 1949 IGNs and 301 warns (Run – 28).
However, when CRMWRN parameter increases to 10 (which means %100 decrease in support
to POL); CRMs increase in number and WRNs exit the system – in other words; the menace
prevails… (Run – 29).
17
Barış EKDi STPS 514 –Final Project
Runs 34-73 employ completely different strategy (1) which allows the number of POL change in
proportion to the number of CRMs.
In runs 33-35 POL/CRM ratio is set to %50 and IGNCRM is set to 0 (which means IGNs are not
allowed to transform into CRMs). Unlike anticipated the simulation did not stop due to the
termination of the CRMS! However, the CRMs fade away slowly from 500 (initial number) to
11, 7 and 5 (so do the POLs from 250 to 5,3 and 2 ) at turns 0, 100, 200 and 300, respectively.
On the other hand, when the CRMs are given chance to convert IGNs, they increased their
numbers even though the IGNCRM is not so small (Runs 36-39).
Run 35 - Run 38
18
Barış EKDi STPS 514 –Final Project
In runs 41 and 42, where the CRMPOL, CRMWRN and IGNCRM parameters are increased to
6,12,6 the simulation terminated at 13th turn; however another increase in those parameters to
8,16,8 resulted in driving the WRNs away.
Run 41 Run 42
In Runs 45 to 70 the POL/CRM proportion is increased from %10 to %150 gradually while
keeping all other parameters equal to 4. At this stage it is observed that;
- while the POL/CRM ratio is less than %55 with the parameters above, the CRMs have
chance to survive although this chance decreases in line with the increase in the
proportion (Runs 45-54);
- while the POL/CRM ratio >=% 60, the CRMs exit at a speed parallel to the increase
(Runs 55-68).
19
Barış EKDi STPS 514 –Final Project
The relationship of costs with strategies is another aspect explored in this simulation: All of the
results are listed in detail in Annex – I; and further details are available at CP***_Costs.TXT
files.
At first sight it may be concluded that as the number of turns increased the costs are increased,
too. Therefore, options that result in Early Termination of the simulation by driving the criminals
out should be more profitable.
Although this hypothesis true to a certain extent, the results do not support the statement that
“earlier the program terminates lesser the costs”: For example, the least costly simulation was
Run 25 among those of 70; and it stopped at the 16th turn with a cost of 8.920 units. On the
contrary, Runs 3, 20 and 28 terminates at turns 9,8 and 9 with costs of 50.000, 54.323 and
70.112, respectively rank far beyond the Run 25.
However, it is also true that most of the runs that cost less are of those that terminate earlier than
set. On the other hand, it is also surprising to see that Run 35, which lasts at least 300 turns, costs
less than most of the runs with 100 turns. Another peculiarity with the Run 35 is that, only one
parameter CRMPOL is set to 5, while others are set to 0; and POL/CRM ratio is set to %50 the
CRMs managed to survive at least until the 300th turn.
20
Barış EKDi STPS 514 –Final Project
The least costly run (25) was with parameters CRMPOL=3, CRMWRN=9, WRNCRM=9,
IGNPOL=0, IGNCRM=6; STRATEGY=2; (CRM/POL is not set ); UPolCost=20, UEffCost=10
and UPawCost=0; and the simulation stopped at 16th turn with a cost of 8.920.
Another observation is that, as parameters come close to each other, the struggle among the
agents lasts longer and the cost increase; and yet another misconception may be related to the
POL/CRM ratio. It may be thought that as the POL/CRM ratio increases, it would be easier to
drive the criminals away, and thus less costly. This assumption holds true especially it is seen
that with POL/CRM ratio above %60 and all interaction parameters are set to 4 (See Runs 60 –
65). However, the runs with POL/CRM ratio below %60 yields most costly results; since CRMs
are not driven away effectively and having certain number of POLs in the system is costly (See.
Runs 47-51).
3.3.Conclusion
In this paper, a world with heterogeneous agents interacting with and transforming into each
other according to certain rules is explored. The rules and number of interaction times for
transformation determines the number of agents in the system; and increasing number of
policemen neither guarantees that the criminals will be driven out quickly nor (or so) it will be
the cheapest way to terminate the criminals. In certain cases, maintaining a sound public
awareness and using warners (as conscious citizens) can be accepted as more effective and less
costly solution. Albeit, it should also be noted that, all those assumptions are only valid within
the given world with pre-set parameters whose selection may seem arbitrary; so any change in
those parameters may likely give different outcomes.
21
Barış EKDi STPS 514 –Final Project
ANNEX – I
Initial Population and Number of Agents: Population : 2500; POL = 250 ; CRM = 500; WRN= 875; IGN= 875
Sign “>>>” refers to the process that may run further; otherwise it means the process is ended at nth turn due to the termination of CRMs.
Sim No
Pol/Crm %
SimStamp
# of WRN
# of CRM
# of IGN
# of POL
SimTurn
Strategy
WrnCrm
CrmWrn
CrmPol
IgnCrm
UPawC
IgnPol
UPolC
EStop
UEffC
TotCost
22
Barış EKDi STPS 514 –Final Project
23
Barış EKDi STPS 514 –Final Project
*
28 CP2206093929 5 5 5 5 5 0 20 10 3 3 100 9 250 0 1949 301 70112
24
Barış EKDi STPS 514 –Final Project
>>>
46 CP2206133912 4 4 4 4 4 15 20 10 3 1 100 174 1981 0 345 662978
>>>
47 CP2206133913 4 4 4 4 4 20 20 10 3 1 100 191 1982 0 327 1416707
>>>
48 CP2206133914 4 4 4 4 4 25 20 10 3 1 100 369 1477 18 636 1445408
>>>
49 CP2206133915 4 4 4 4 4 30 20 10 3 1 100 388 1295 56 761 1536824
>>>
51 CP2206133917 4 4 4 4 4 40 20 10 3 1 100 379 948 191 982 1383170
>>>
52 CP2206133918 4 4 4 4 4 45 20 10 3 1 100 231 514 478 1277 761378
>>>
53 CP2206133919 4 4 4 4 4 50 20 10 3 1 100 82 165 714 1539 282090
>>>
54 CP2206133920 4 4 4 4 4 55 20 10 3 1 100 17 32 809 1642 108030
25
Barış EKDi STPS 514 –Final Project
26