Skip to content

Commit

Permalink
Merge pull request #155 from LABSS/fix-c
Browse files Browse the repository at this point in the history
Fix c
  • Loading branch information
mariopaolucci authored Aug 9, 2019
2 parents 1cf1f92 + fda6ead commit 6646a60
Show file tree
Hide file tree
Showing 4 changed files with 393 additions and 19 deletions.
23 changes: 13 additions & 10 deletions PROTON-OC.nlogo
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,8 @@ end

to setup-oc-groups
; OC members are scaled down if we don't have 10K agents
let scaled-num-oc-families ceiling num-oc-families * num-persons / 10000
let scaled-num-oc-persons ceiling num-oc-persons * num-persons / 10000
let scaled-num-oc-families ceiling (num-oc-families * num-persons / 10000 * num-oc-persons / 30)
let scaled-num-oc-persons ceiling (num-oc-persons * num-persons / 10000)
ask rnd:weighted-n-of scaled-num-oc-families persons [
criminal-tendency + criminal-tendency-addme-for-weighted-extraction
] [
Expand Down Expand Up @@ -1209,6 +1209,7 @@ end

to commit-crimes
let co-offender-groups []
let co-offenders-started-by-OC []
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 [
Expand All @@ -1220,6 +1221,7 @@ to commit-crimes
ask rnd:weighted-one-of people-in-cell [ criminal-tendency + criminal-tendency-addme-for-weighted-extraction ] [
let accomplices find-accomplices number-of-accomplices
set co-offender-groups lput (turtle-set self accomplices) co-offender-groups
if oc-member? [ set co-offenders-started-by-OC lput (turtle-set self accomplices) co-offenders-started-by-OC ]
; check for big crimes started from a normal guy
if length accomplices + 1 > this-is-a-big-crime and criminal-tendency < good-guy-threshold [
set big-crime-from-small-fish big-crime-from-small-fish + 1
Expand All @@ -1234,10 +1236,7 @@ to commit-crimes
if not empty? co-offender-groups [
set co-offender-group-histo make-co-offending-histo co-offender-groups
]
let oc-co-offender-groups filter [ co-offenders ->
any? co-offenders with [ oc-member? ]
] co-offender-groups
foreach oc-co-offender-groups [ co-offenders ->
foreach co-offenders-started-by-OC [ co-offenders ->
ask co-offenders with [ not oc-member? ] [
set new-recruit ticks
set oc-member? true
Expand Down Expand Up @@ -1287,6 +1286,7 @@ to retire-persons
end

to-report find-accomplices [ n ] ; person reporter
if n = 0 [ report [ ] ]
let d 1 ; start with a network distance of 1
let accomplices []
nw:with-context persons person-links [
Expand Down Expand Up @@ -1343,8 +1343,11 @@ end
; this is what in the paper is called r - this is r
;R is then operationalised as the proportion of OC members among the social relations of each individual (comprising family, friendship, school, working and co-offending relations)
to-report candidate-weight ; person reporter
let r ifelse-value [ oc-member? ] of myself [ oc-embeddedness ] [ 0 ]
report -1 * (social-proximity-with myself + r)
report -1 * ifelse-value [ oc-member? ] of myself [
(social-proximity-with myself * oc-embeddedness * criminal-tendency)
] [
(social-proximity-with myself * criminal-tendency)
]
end

to calculate-criminal-tendency
Expand Down Expand Up @@ -2142,7 +2145,7 @@ num-oc-persons
num-oc-persons
2
200
20.0
30.0
1
1
NIL
Expand Down Expand Up @@ -2193,7 +2196,7 @@ CHOOSER
family-intervention
family-intervention
"none" "remove-if-caught" "remove-if-OC-member" "remove-if-caught-and-OC-member"
3
0

CHOOSER
15
Expand Down
189 changes: 189 additions & 0 deletions experiments-xml/xml-launch/xml-launch-OC.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE experiments SYSTEM "behaviorspace.dtd">
<experiments>
<experiment name="xml_launch" repetitions="1" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<final>show (word "Time elapsed:" timer)
dump-networks
</final>
<!-- 30 years -->
<timeLimit steps="360"/>
<!-- 1. Number of OC members per time unit (tentatively month) -->
<metric>o1</metric>
<!-- 2. Number of recruited individuals into OC per time unit -->
<metric>o2</metric>
<!-- 3. Number of crimes per time unit -->
<metric>o3</metric>
<!-- 4. Number of crimes committed by OC members per time unit -->
<metric>o4</metric>
<!-- 5. Distribution and mean of C (which is the individual propensity towards crime commission) -->
<metric>o5</metric>
<metric>o5a</metric>
<!-- 6. Distribution and mean of R (which is the individual embededdness into OC-prone local networks) -->
<metric>o6</metric>
<metric>o6a</metric>
<!-- 7. Distribution of socio-demographic variables on new recruited individuals -->
<metric>o7a</metric>
<metric>o7b</metric>
<metric>o7c</metric>
<!-- 8. Distribution of socio-demographic variables of OC members -->
<metric>o8a</metric>
<metric>o8b</metric>
<metric>o8c</metric>
<!-- 9. Distribution of socio-demographic variables of “ordinary criminals” (people that commit crime but are not part of an OC) -->
<metric>o9a</metric>
<metric>o9b</metric>
<metric>o9c</metric>
<!-- 10. Distribution of socio-demographic variables of the general population -->
<metric>o10a</metric>
<metric>o10b</metric>
<metric>o10c</metric>
<!-- 11. Number of crimes committed by facilitator agents per time unit -->
<metric>o11</metric>
<!-- 12. Number of law enforcement interventions per time unit -->
<metric>o12</metric>
<!-- 13. age structure of offenses -->
<metric>o13</metric>
<!-- 14. co-offenses per turn. A vector of co-offenses the side of the index, starting with zero. -->
<metric>o14</metric>
<!-- 15. number of persons addressed by a preventive interventions recruited this tick-->
<metric>o15</metric>
<!-- 16. number of OC person offsprings recruited this tick -->
<metric>o16</metric>
<metric>count persons</metric>
<metric>count links</metric>
<metric>count prisoners</metric>
<metric>count persons with [ migrant? ]</metric>
<metric>number-deceased</metric>
<metric>sum [ num-crimes-committed ] of persons</metric>
<metric>count persons with [ my-job != nobody ]</metric>
<metric>count jobs with [ my-worker != nobody ]</metric>
<metric>crime-size-fails</metric>
<metric>count persons with [facilitator?]</metric>
<metric>facilitator-fails</metric>
<metric>facilitator-crimes</metric>
<metric>count household-links </metric>
<metric>count partner-links</metric>
<metric>count sibling-links</metric>
<metric>count offspring-links</metric>
<metric>count friendship-links</metric>
<metric>count criminal-links</metric>
<metric>count professional-links</metric>
<metric>count school-links</metric>
<metric>count meta-links</metric>
<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>
<!-- PARAMETERS -->
<enumeratedValueSet variable="intervention">
<value value="&quot;baseline&quot;"/>
<value value="&quot;preventive&quot;"/>
<value value="&quot;disruptive&quot;"/>
</enumeratedValueSet>
<!-- 1. Number of OC members -->
<enumeratedValueSet variable="num-oc-persons">
<value value="15"/>
<value value="30"/>
<value value="45"/>
</enumeratedValueSet>
<!-- PALERMO SETUP -->
<enumeratedValueSet variable="data-folder">
<value value="&quot;inputs/palermo/data/&quot;"/>
</enumeratedValueSet>
<!-- 2. Criminal rate -->
<enumeratedValueSet variable="criminal-rate">
<value value="0.5"/>
<value value="1.0"/>
<value value="1.5"/>
</enumeratedValueSet>
<!-- 3a. Employment rate -->
<enumeratedValueSet variable="unemployment-multiplier">
<value value="&quot;base&quot;"/>
<value value="0.5"/>
</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="15"/>
<value value="30"/>
<value value="45"/>
</enumeratedValueSet>
<!-- 5. Punishment length -->
<enumeratedValueSet variable="punishment-length">
<value value="0.5"/>
<value value="1.0"/>
<value value="1.5"/>
</enumeratedValueSet>
<!-- FIXED parameters -->
<enumeratedValueSet variable="num-oc-families">
<value value="8"/>
</enumeratedValueSet>
<enumeratedValueSet variable="num-persons">
<value value="10000"/>
</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>
</experiment>
</experiments>

Loading

0 comments on commit 6646a60

Please sign in to comment.