Skip to content

Commit

Permalink
Fix & update for calc-confidence
Browse files Browse the repository at this point in the history
* The local `stop?` variable in the calc-confidence procedure caused unintended consequences in conjunction with `g-depressed-confidence`. It sometimes lead to researchers not properly updating their `avg-neighbor-signal`. Therefore the `stop?` variable has been removed.
* In case of de-facto complete networks the calculation of `avg-neighbor-signal` can be simplified. This has been implemented.
* The condition for when an update from nature is happening has been fixed inside the `calc-confidence` procedure.
  • Loading branch information
daimpi committed Jul 4, 2017
1 parent e47abd1 commit 1826929
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions protocol.nls
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ end



; reports true if all scientists converged to one theory and consider this theory
; to be among their best theories
; reports true if all scientists converged to one theory and consider this
; theory to be among their best theories
to-report converged
let count-th1-scientists count turtles with [
mytheory = 0 and member? 0 cur-best-th]
Expand Down Expand Up @@ -80,35 +80,48 @@ end
; change her mind). This calculation only makes sense in case researchers have
; converged.
to calc-confidence
if converged-ticks = 0 [
;force-update is a boolean. It is true if scientists just converged this round
let force-update? (converged-ticks = 0)
if force-update? [
set g-depressed-confidence false
]
if g-depressed-confidence [stop]
let stop? false
let force-nature-update? 0
if not force-update? [
; the -1 correction in ticks compensates for the fact that this procedure
; will be called after the go procedure and therefore the tick-counter has
; already advanced one step further
set force-nature-update? (nature-evidence-frequency > 0
and ticks > 1
and (ticks - 1) mod (1 / nature-evidence-frequency) = 0)
]
let cur-theory [mytheory] of one-of turtles
let other-theory ((cur-theory + 1) mod 2)
let avg-neighbor-signal-complete 0
if g-fast-sharing-enabled and (force-update? or force-nature-update?) [
set avg-neighbor-signal-complete mean [item cur-theory subj-th-i-signal] of
turtles
]
ask turtles [
if stop? and nature-evidence-frequency = 0 [stop]
let belief-to-beat item ((mytheory + 1) mod 2) current-theory-info
let belief-to-beat item other-theory current-theory-info
- strategy-threshold
; not entirerly sure whether this cutoff at 0 is needed, but I've added it
; for cautionarly reasons
set belief-to-beat max (list 0 belief-to-beat)
let cur-theory mytheory
; the -1 correction in ticks compensates for the fact that this procedure
; will be called after the go procedure and therefore the tick-counter has
; already advanced one step further
if converged-ticks = 0 or (nature-evidence-frequency > 0
and (ticks - 1) != 0
and (ticks - 1) mod (1 / nature-evidence-frequency) = 0) [
set avg-neighbor-signal mean [item cur-theory subj-th-i-signal] of
(turtle-set link-neighbors self)
set belief-to-beat max (list 0 belief-to-beat)
if force-update? or force-nature-update? [
ifelse g-fast-sharing-enabled [
set avg-neighbor-signal avg-neighbor-signal-complete
][
set avg-neighbor-signal mean [item cur-theory subj-th-i-signal] of
share-group
]
]
; if the scientist would be given sufficient time for her belief to
; converge to the average signal of her and her link-neighbors, would
; this be enough for her to abandon her current theory? If so, she's not
; confident enough.
if avg-neighbor-signal <= belief-to-beat [
set confidence 0
set stop? true
set g-depressed-confidence true
stop
]
Expand All @@ -119,7 +132,6 @@ to calc-confidence
let delta item mytheory current-theory-info - belief-to-beat
if (2 * alpha - 1) * delta <= belief-to-beat [
set confidence 0
set stop? true
stop
]
let exit-probability 0.5 + 0.5 * erf (
Expand All @@ -134,11 +146,7 @@ to calc-confidence
set confidence 1
]
]
ifelse stop? [
set g-confidence 0
][
set g-confidence reduce * [confidence] of turtles
]
set g-confidence reduce * [confidence] of turtles
end


Expand Down

0 comments on commit 1826929

Please sign in to comment.