Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip research time tracking #16

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,27 @@ If there is a researcher for whom, if given sufficient time for her belief to co

When the network is a de facto complete network, scientists might be able to utilize a more performant sharing procedure (the second condition is that they have to be converged): `share-fast`. This variable signals whether or not such a de-facto complete network is present in the current run.

#### g-exit-condition?

* format: boolean
* example: false

If the `exit-condition` reporter is evaluated the variable will be set to `true` in case the the exit-condition is met, `false` otherwise. Positive evaluation of the exit-condition marks the end of a run.

#### g-myscientists

* format: list
* example: [3 7]

Reflects how many scientist are currently researching each theory: the first entry in the list is for theory one the 2nd entry for theory two.

#### g-research-time

* format: list
* example: [350 129]

Records how much each theory has been researched over the course of the run: each round each researcher who pulls from the slot machine for a given theory increases the counter for this theory by one. The first entry in the list is for theory one the 2nd entry for theory two.


### Turtles-own

Expand Down
92 changes: 64 additions & 28 deletions SocNetABM.nlogo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ globals [th-i-signal indiff-count crit-interactions-th1 crit-interactions-th2
converge-reporters converge-reporters-values
run-start-scientists-save rndseed g-confidence g-depressed-confidence
g-fast-sharing-enabled g-last-convlight-th g-conv-dur-th1 g-conv-dur-th2
g-conv-start-th1 g-conv-start-th2]
g-conv-start-th1 g-conv-start-th2 g-exit-condition? g-myscientists
g-research-time]

__includes ["protocol.nls"]

Expand Down Expand Up @@ -53,30 +54,54 @@ to setup [rs]
let th-1-scientist count turtles with [mytheory = 0]
let th-2-scientist count turtles with [mytheory = 1]
set run-start-scientists-save (list th-1-scientist th-2-scientist)
set g-myscientists run-start-scientists-save
set g-depressed-confidence false
set g-last-convlight-th -1
set g-conv-dur-th1 []
set g-conv-dur-th2 []
set g-conv-start-th1 []
set g-conv-start-th2 []
set g-exit-condition? false
set g-research-time [0 0]
reset-ticks
end





; advances the model one round with- or without evaluating the exit-condition
; depending on the argument:
; exit? = exit-condition evaluated?, type: boolean
to go [exit?]
let fast-sharing? 0
with-local-randomness [
set fast-sharing? (g-fast-sharing-enabled and converged-light)
if exit? and not g-exit-condition? [
set g-exit-condition? exit-condition
]
]
ifelse g-exit-condition? and exit? [
stop
][
go-core fast-sharing?
]
end





; one go = one round
to go
to go-core [fast-sharing?]
ask turtles [
pull
]
let fast-sharing (g-fast-sharing-enabled and converged-light)
if fast-sharing [
if fast-sharing? [
share-fast
]
ask turtles [
if not fast-sharing [
if not fast-sharing? [
share
]
calc-posterior
Expand All @@ -96,21 +121,10 @@ to go
and not member? mytheory cur-best-th] [
act-on-strategies
]
tick
end





; runs until the exit-condition is met
to go-stop
let stop? 0
with-local-randomness [set stop? exit-condition]
while [not stop?][
go
with-local-randomness [set stop? exit-condition]
with-local-randomness [
compute-popularity
]
tick
end


Expand Down Expand Up @@ -148,7 +162,7 @@ end
to init-converge-reporters
set converge-reporters (list [ -> average-belief 0 true]
[ -> average-cum-successes 0 true] [ -> average-confidence true]
[ -> average-signal 0 true])
[ -> average-signal 0 true] [ -> research-time 0 true])
end


Expand Down Expand Up @@ -573,8 +587,8 @@ BUTTON
15
164
48
NIL
go
go false
T
1
T
Expand Down Expand Up @@ -611,8 +625,8 @@ true
false
"" ""
PENS
"best theory" 1.0 0 -2674135 true "" "plot count turtles with [mytheory = 0]"
"not-best-theory" 1.0 0 -14835848 true "" "plot count turtles with [mytheory = 1]"
"best theory" 1.0 0 -2674135 true "" "plot item 0 g-myscientists"
"not-best-theory" 1.0 0 -14835848 true "" "plot item 1 g-myscientists"

SWITCH
16
Expand Down Expand Up @@ -660,9 +674,9 @@ BUTTON
64
124
97
NIL
go-stop
NIL
go true
T
1
T
OBSERVER
Expand Down Expand Up @@ -870,6 +884,27 @@ If there is a researcher for whom, if given sufficient time for her belief to co

When the network is a de facto complete network, scientists might be able to utilize a more performant sharing procedure (the second condition is that they have to be converged): `share-fast`. This variable signals whether or not such a de-facto complete network is present in the current run.

#### g-exit-condition?

* format: boolean
* example: false

If the `exit-condition` reporter is evaluated the variable will be set to `true` in case the the exit-condition is met, `false` otherwise. Positive evaluation of the exit-condition marks the end of a run.

#### g-myscientists

* format: list
* example: [3 7]

Reflects how many scientist are currently researching each theory: the first entry in the list is for theory one the 2nd entry for theory two.

#### g-research-time

* format: list
* example: [350 129]

Records how much each theory has been researched over the course of the run: each round each researcher who pulls from the slot machine for a given theory increases the counter for this theory by one. The first entry in the list is for theory one the 2nd entry for theory two.


### Turtles-own

Expand Down Expand Up @@ -1278,15 +1313,14 @@ false
Polygon -7500403 true true 270 75 225 30 30 225 75 270
Polygon -7500403 true true 30 75 75 30 270 225 225 270
@#$#@#$#@
NetLogo 6.0.2
NetLogo 6.0.4
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
<experiments>
<experiment name="zm-base-run" repetitions="10000" runMetricsEveryStep="false">
<setup>setup new-seed</setup>
<go>go</go>
<exitCondition>exit-condition</exitCondition>
<go>go true</go>
<metric>successful-run</metric>
<metric>average-jumps</metric>
<metric>avg-indiff-time</metric>
Expand Down Expand Up @@ -1316,6 +1350,8 @@ NetLogo 6.0.2
<metric>frequency-converged "th2"</metric>
<metric>center-of-convergence "th1"</metric>
<metric>center-of-convergence "th2"</metric>
<metric>research-time "th1" false</metric>
<metric>research-time "th2" false</metric>
<steppedValueSet variable="scientists" first="3" step="1" last="11"/>
<enumeratedValueSet variable="th1-signal">
<value value="0.5"/>
Expand Down
36 changes: 34 additions & 2 deletions protocol.nls
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ end
; reports the average signal for th# at the time of final convergence
; arguments:
; - th# = theory, type: string
; - rec = recording?, type: boolean
; - rec? = recording?, type: boolean
to-report average-signal [th# rec?]
let identifier "avgsignal"
ifelse rec? [
Expand Down Expand Up @@ -362,7 +362,7 @@ end
; reports the average beliefs among the researchers
; arguments:
; - th# = theory, type: string
; - rec = recording?, type: boolean
; - rec? = recording?, type: boolean
to-report average-belief [th# rec?]
let identifier "avgbelief"
ifelse rec? [
Expand Down Expand Up @@ -529,3 +529,35 @@ to-report center-of-convergence [th#]
2 * curstart * curlength + curlength ^ 2] convergence-starts conv-durations)
report weighted-convergences / (2 * cur-cum-conv-dur)
end





to compute-popularity
set g-research-time (map + g-research-time g-myscientists)
let th-1-scientist count turtles with [mytheory = 0]
let th-2-scientist scientists - th-1-scientist
set g-myscientists (list th-1-scientist th-2-scientist)
end





; reports the time scientists spent researching each theory before they finally
; converged
; arguments:
; - th# = theory, type: string
; - rec? = recording?, type: boolean
to-report research-time [th# rec?]
let identifier "restime"
ifelse rec? [
report (fput identifier g-research-time)
][
set th# translate-from-string th#
let res-time but-first first filter [curitem ->
first curitem = identifier] converge-reporters-values
report item th# res-time
]
end