Skip to content

Commit

Permalink
New find-facilitator routine
Browse files Browse the repository at this point in the history
six times faster:

bserver> reset-timer repeat 1000 [ set people-jailed n-of 5 persons set co-offender-group-histo find-facilitator people-jailed] show timer
observer: 2.512
observer> reset-timer repeat 1000 [ set people-jailed n-of 5 persons set co-offender-group-histo find-facilitator-1 people-jailed] show timer
observer: 13.886
  • Loading branch information
mariopaolucci committed Aug 9, 2019
1 parent 6646a60 commit b46d4cd
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions PROTON-OC.nlogo
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ to make-people-die
ask all-persons [
if random-float 1 < p-mortality or age > 119 [
if facilitator? [
let new-facilitator one-of other persons with [ not facilitator? and age > 18 ]
let new-facilitator one-of other persons with [ not facilitator? and not oc-member? and age > 18 ]
ask new-facilitator [ set facilitator? true ]
]
set number-deceased number-deceased + 1
Expand Down Expand Up @@ -1157,24 +1157,19 @@ to-report p-fertility
end

to-report find-facilitator [ co-offending-group ]
let the-facilitator nobody
let the-facilitator no-turtles

This comment has been minimized.

Copy link
@digitaldust

digitaldust Aug 10, 2019

Contributor

I don't get this, why putting there an empty agentset? after this you put set the-facilitator one-of… so you revert it to a single turtle

This comment has been minimized.

Copy link
@digitaldust

digitaldust Aug 10, 2019

Contributor

all this to say it should be nobody… :-D

This comment has been minimized.

Copy link
@mariopaolucci

mariopaolucci Aug 10, 2019

Author Contributor

and so shall be :-D

; first, test if there is a facilitator into co-offender-groups
let available-facilitators co-offending-group with [ facilitator? ]
ifelse any? available-facilitators [
set the-facilitator one-of (available-facilitators with [ facilitator? ])
set the-facilitator one-of available-facilitators
] [
; second, search a facilitator into my networks
while [ the-facilitator = nobody and any? co-offending-group ] [
let pool nobody
ask one-of co-offending-group [
nw:with-context persons person-links [
set pool (turtle-set nw:turtles-in-radius max-accomplice-radius nw:turtles-in-reverse-radius max-accomplice-radius)
set pool other pool with [ facilitator? ]
]
if any? pool [ set the-facilitator one-of pool ]
set co-offending-group other co-offending-group
set available-facilitators turtle-set [
(turtle-set nw:turtles-in-radius max-accomplice-radius nw:turtles-in-reverse-radius max-accomplice-radius) with [
facilitator?
]
]
] of co-offending-group
if any? available-facilitators [ set the-facilitator one-of available-facilitators ]
]
report the-facilitator
end
Expand Down Expand Up @@ -1220,6 +1215,8 @@ to commit-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

; here we should change it. The facilitator must be one of them, not an added member: see https://github.com/LABSS/PROTON-OC/issues/60#issuecomment-472075050

This comment has been minimized.

Copy link
@digitaldust

digitaldust Aug 10, 2019

Contributor

so the problem we have here is that, if the facilitator is not already in the group of accomplices, we cannot put it into the co-offender-group because we have not yet found him using facilitator-test, am I right?

This comment has been minimized.

Copy link
@mariopaolucci

mariopaolucci Aug 10, 2019

Author Contributor

yes, it should be completely rewritten..

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
Expand Down

0 comments on commit b46d4cd

Please sign in to comment.