Skip to content

Commit

Permalink
Merge pull request #149 from LABSS/new-crime-mult
Browse files Browse the repository at this point in the history
New crime mult
  • Loading branch information
mariopaolucci authored Aug 6, 2019
2 parents a1afabf + 4426c4a commit 628fe57
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 241 deletions.
46 changes: 39 additions & 7 deletions PROTON-OC.nlogo
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ globals [
co-offender-group-histo
people-jailed
number-crimes
crime-multiplier
]

to profile-setup
Expand Down Expand Up @@ -223,6 +224,7 @@ to setup
setup-employers-jobs
ask persons with [ my-job = nobody and my-school = nobody and age >= 16 and age < retirement-age and job-level > 1 ] [ find-job ]
init-professional-links
calculate-crime-multiplier
calculate-criminal-tendency
calculate-arrest-rate
setup-oc-groups
Expand Down Expand Up @@ -448,7 +450,7 @@ end

to calculate-arrest-rate
; this gives the base probability of arrest, propotionally to the number of expected crimes in the first year
set arrest-rate number-arrests-per-year / ticks-per-year / 842
set arrest-rate number-arrests-per-year / ticks-per-year / number-crimes-yearly-per10k
end

to dump-networks
Expand Down Expand Up @@ -886,13 +888,14 @@ to let-migrants-in
; we do not care about education level and wealth of migrants, as those variables
; exist only in order to generate the job position.
hatch-persons 1 [
init-person-empty
set my-job myself
ask my-job [ set my-worker myself ]
let employees turtle-set [ current-employees ] of [ my-employer ] of my-job
let conn decide-conn-number employees 20
create-professional-links-with n-of conn other employees
set birth-tick ticks - (random 20 + 18) * ticks-per-year
init-person-empty
set age calculate-age
set wealth-level [ job-level ] of myself
set migrant? true
]
Expand Down Expand Up @@ -1080,7 +1083,7 @@ end
to graduate
let levels education-levels
let primary-age item 0 table:get levels 0
ask persons with [ education-level = -1 and age = primary-age ] [
ask persons with [ education-level = -1 and age = primary-age and my-school = nobody ] [
enroll-to-school 0
]
ask schools [
Expand Down Expand Up @@ -1110,15 +1113,16 @@ end

to make-people-die
ask all-persons [
if random-float 1 < p-mortality [
if random-float 1 < p-mortality or age > 119 [
if facilitator? [
let new-facilitator one-of other persons with [ not facilitator? and age > 18 ]
ask new-facilitator [ set facilitator? true ]
]
set number-deceased number-deceased + 1
if my-job != nobody [ ask my-job [ set my-worker nobody ] ]
if my-school != nobody [ ask my-school [ set my-students other my-students ] ]
die
]
ask all-persons with [ age > 119 ] [ die ]
]
end

Expand Down Expand Up @@ -1178,15 +1182,28 @@ to-report facilitator-test [ co-offending-group ]
]
end

to calculate-crime-multiplier
let total-crimes 0
foreach table:keys c-range-by-age-and-sex [ cell ->
let value last table:get c-range-by-age-and-sex cell
let people-in-cell persons with [
age > last cell and age <= first value and male? = first cell
]
let n-of-crimes last value * count people-in-cell * criminal-rate
set total-crimes total-crimes + n-of-crimes
]
set crime-multiplier number-crimes-yearly-per10k / 10000 * count all-persons / total-crimes
end

to commit-crimes
let co-offender-groups []
foreach table:keys c-range-by-age-and-sex [ cell ->
let value last table:get c-range-by-age-and-sex cell
let people-in-cell persons with [
age > last cell and age <= first value and male? = first cell
]
let n-of-crimes last value * count people-in-cell * criminal-rate / ticks-per-year
repeat round n-of-crimes [
let target-n-of-crimes last value * count people-in-cell * criminal-rate / ticks-per-year * crime-multiplier
repeat round target-n-of-crimes [
set number-crimes number-crimes + 1
ask rnd:weighted-one-of people-in-cell [ criminal-tendency + criminal-tendency-addme-for-weighted-extraction ] [
let accomplices find-accomplices number-of-accomplices
Expand Down Expand Up @@ -2525,6 +2542,21 @@ number-crimes
1
11

SLIDER
1095
655
1347
688
number-crimes-yearly-per10k
number-crimes-yearly-per10k
0
3000
2000.0
100
1
NIL
HORIZONTAL

@#$#@#$#@
## WHAT IS IT?

Expand Down
3 changes: 3 additions & 0 deletions experiments-xml/OC-profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
<metric>sum [ count my-students ] of schools</metric>
<metric>count jobs</metric>
<metric>count all-persons with [ num-crimes-committed = 0 ]</metric>
<metric>count all-persons with [ my-job = nobody and my-school = nobody and age &gt; 16 and age &lt; 65 ] / count all-persons with [my-job = nobody and my-school = nobody and age &gt; 16 and age &lt; 65 ]</metric>
<metric>people-jailed</metric>
<metric>initial-random-seed</metric>
<!-- PARAMETERS -->
<enumeratedValueSet variable="intervention">
<value value="&quot;baseline&quot;"/>
Expand Down
116 changes: 116 additions & 0 deletions experiments-xml/rp0.2/rp0.2-OC-noreport.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE experiments SYSTEM "behaviorspace.dtd">
<experiments>
<experiment name="rp0.2" repetitions="1" runMetricsEveryStep="true">
<setup></setup>
<go>setup</go>
<final>show (word "Time elapsed:" timer)
dump-networks
</final>
<!-- assuming 40 years -->
<timeLimit steps="1"/>
<!-- 1. Number of OC members per time unit (tentatively month) -->
<metric>o1</metric>
<metric>initial-random-seed</metric>
<!-- PARAMETERS -->
<enumeratedValueSet variable="intervention">
<value value="&quot;baseline&quot;"/>
</enumeratedValueSet>
<!-- 1. Number of OC members -->
<enumeratedValueSet variable="num-oc-persons">
<value value="30"/>
</enumeratedValueSet>
<!-- PALERMO SETUP -->
<enumeratedValueSet variable="data-folder">
<value value="&quot;inputs/palermo/data/&quot;"/>
</enumeratedValueSet>
<!-- 3a. Employment rate and education rate must vary together -->
<enumeratedValueSet variable="unemployment-target">
<value value="30"/>
</enumeratedValueSet>
<!-- 3b. Education rate -->
<enumeratedValueSet variable="education-rate">
<value value="1"/>
</enumeratedValueSet>
<!-- 4. Law enforcement intervention rate -->
<enumeratedValueSet variable="number-arrests-per-year">
<value value="30"/>
</enumeratedValueSet>
<!-- 5. Punishment length -->
<enumeratedValueSet variable="punishment-length">
<value value="1.0"/>
</enumeratedValueSet>
<!-- 2. Criminal rate -->
<enumeratedValueSet variable="number-crimes-yearly-per10k">
<value value="2000"/>
</enumeratedValueSet>
<!-- FIXED parameters -->
<enumeratedValueSet variable="num-oc-families">
<value value="8"/>
</enumeratedValueSet>
<enumeratedValueSet variable="num-persons">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="welfare-support">
<value value="&quot;none&quot;"/> <!-- overriden by intervention -->
</enumeratedValueSet>
<enumeratedValueSet variable="output?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="intervention-start">
<value value="13"/> <!-- overriden by intervention -->
</enumeratedValueSet>
<enumeratedValueSet variable="social-support">
<value value="&quot;none&quot;"/> <!-- overriden by intervention -->
</enumeratedValueSet>
<enumeratedValueSet variable="intervention-end">
<value value="36"/> <!-- overriden by intervention -->
</enumeratedValueSet>
<enumeratedValueSet variable="nat-propensity-threshold">
<value value="1"/>
</enumeratedValueSet>
<enumeratedValueSet variable="oc-embeddedness-radius">
<value value="2"/>
</enumeratedValueSet>
<enumeratedValueSet variable="threshold-use-facilitators">
<value value="4"/>
</enumeratedValueSet>
<enumeratedValueSet variable="ticks-per-year">
<value value="12"/>
</enumeratedValueSet>
<enumeratedValueSet variable="percentage-of-facilitators">
<value value="0.005"/>
</enumeratedValueSet>
<enumeratedValueSet variable="nat-propensity-sigma">
<value value="0.25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="targets-addressed-percent">
<value value="10"/> <!-- overriden by intervention -->
</enumeratedValueSet>
<enumeratedValueSet variable="nat-propensity-m">
<value value="1"/>
</enumeratedValueSet>
<enumeratedValueSet variable="OC-members-scrutinize?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="family-intervention">
<value value="&quot;none&quot;"/> <!-- overriden by intervention -->
</enumeratedValueSet>
<enumeratedValueSet variable="max-accomplice-radius">
<value value="2"/>
</enumeratedValueSet>
<enumeratedValueSet variable="ticks-between-intervention">
<value value="1"/> <!-- overriden by intervention -->
</enumeratedValueSet>
<enumeratedValueSet variable="retirement-age">
<value value="65"/>
</enumeratedValueSet>
<enumeratedValueSet variable="OC-boss-repression?">
<value value="false"/> <!-- overriden by intervention -->
</enumeratedValueSet>
<enumeratedValueSet variable="criminal-rate">
<value value="1.0"/>
</enumeratedValueSet>
</experiment>
</experiments>

Loading

0 comments on commit 628fe57

Please sign in to comment.