Skip to content

Commit e47abd1

Browse files
committed
Performance upgrade for sharing procedure
* A new procedure `share-fast` has been introduced. In case of de-facto complete networks and convergence, it allows computation of the sharing between scientists in a much more efficient way. * A new reporter `converged-light` has been introduced. It reports whether all scientists are on the same theory. * The `integrate-own-pull-info` procedure has been removed, and it's task is now taken over by the sharing procedures. * One new global variable `g-fast-sharing-enabled` has been added and documented. * One new turtle-owned variable `share-group` has been added and documented.
1 parent 22917df commit e47abd1

File tree

3 files changed

+106
-48
lines changed

3 files changed

+106
-48
lines changed

README.md

+33-19
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# UNDER CONSTRUCTION
1+
# UNDER CONSTRUCTION
22

33
# SocNetABM
4-
NetLogo iteration of Zollman's (2010) ABM with critical interaction.
4+
NetLogo iteration of Zollman's (2010) ABM with critical interaction.
55

66

77

88
## HOW IT WORKS
99

10-
Beliefs of the researchers are modeled via a beta distribution: The mean of the beta distribution is their current belief.
10+
Beliefs of the researchers are modeled via a beta distribution: The mean of the beta distribution is their current belief.
1111

1212

1313

1414
## NETLOGO FEATURES
1515

1616
The binomial distribution is approximated by the normal distribution with the same mean and variance. This approximation is highly accurate for all parameter values from the interface.
17-
B/c the normal distribution is a continuous distribution the outcome is rounded and there is a safety check which constrains the distribution to the interval [0, pulls] to prevent negative- or higher than pulls numbers of successes.
17+
B/c the normal distribution is a continuous distribution the outcome is rounded and there is a safety check which constrains the distribution to the interval [0, pulls] to prevent negative- or higher than pulls numbers of successes.
1818

1919
## Variables
2020

@@ -28,14 +28,14 @@ Default-values have been set to mirror Zollman's (2010) model. The slider ranges
2828
#### th-i-signal
2929

3030
* type: float-list
31-
* example: [0.5 0.499]
31+
* example: [0.5 0.499]
3232

3333
The average objective probability of success (ops)for [theory-1 theory-2].
3434

3535
#### indiff-count
3636

3737
* type: integer
38-
* example: 1003
38+
* example: 1003
3939

4040
The sum of number of rounds each scientist was indifferent between the two theories.
4141

@@ -49,7 +49,7 @@ The sum of critical interactions scientists on theory 1(2) encountered.
4949
#### confidence-cutoff
5050

5151
* type: integer
52-
* example: 0.9999
52+
* example: 0.9999
5353

5454
The global-confidence `g-confidence` must be higher than this value for the run to be terminated.
5555

@@ -78,44 +78,51 @@ The maximal number of rounds before a run is terminated by the exit condition.
7878
#### converge-reporters
7979

8080
* type: anonymous reporters list
81-
* example: [(anonymous reporter: [ average-belief 0 true ]) (anonymous reporter: [ average-cum-successes 0 true ]) (anonymous reporter: [ average-confidence true ])]
81+
* example: [(anonymous reporter: [ average-belief 0 true ]) (anonymous reporter: [ average-cum-successes 0 true ]) (anonymous reporter: [ average-confidence true ]) (anonymous reporter: [ average-signal 0 true ])]
8282

83-
Reporters which have to be collected in the round when researchers converge. The values for those reporters is then stored in the global `converge-reporters-values` and retrieved by BehaviourSpace at the end of the run.
83+
Reporters which have to be collected in the round when researchers converge. The values for those reporters is then stored in the global `converge-reporters-values` and retrieved by BehaviourSpace at the end of the run.
8484

8585
#### converge-reporters-values
8686

8787
* type: list
88-
* example: [["avgbelief" 0.4998 0.4980] ["avgsuc" 757100.9795 383442.9715] ["avgconfidence" 60234.0298]]
88+
* example: [["avgbelief" 0.4997690253321044 0.49127250748536755] ["avgsuc" 110667.02991226684 21169.651936606337] ["avgconfidence" 0.7645093577413972] ["avgsignal" 0.5 0.499]]
8989

90-
The values from the anonymous reporters in `converge-reporters`, recorded at the last time researchers converged.
90+
The values from the anonymous reporters in `converge-reporters`, recorded at the last time researchers converged.
9191

9292
#### run-start-scientists-save
9393

9494
* type: integer-list
9595
* example: [5 5]
9696

97-
The number of scientists on [th1 th2] at the beginning of the run.
97+
The number of scientists on [th1 th2] at the beginning of the run.
9898

9999
#### rndseed
100100

101101
* format: integer
102102
* example: -2147452934
103103

104-
Stores the random-seed of the current run.
104+
Stores the random-seed of the current run.
105105

106106
#### g-confidence
107107

108108
* format: float
109-
* example: 0.9993
109+
* example: 0.9993
110110

111-
Global-confidence: the probability that not a single researcher will switch theories i.e. the probability that this convergence is final. Range: [0,1]
111+
Global-confidence: the probability that not a single researcher will switch theories i.e. the probability that this convergence is final. Range: [0,1]
112112

113113
#### g-depressed-confidence
114114

115115
* format: boolean
116-
* example: false
116+
* example: false
117+
118+
If there is a researcher for whom, if given sufficient time for her belief to converge to the average signal of her and her link-neighbors, this would this be enough to abandon her current theory, her confidence will always be zero and therefore `g-confidence` will also be zero. In this case `g-depressed-confidence` will be set to true in order to avoid redundant confidence calculations.
119+
120+
#### g-fast-sharing-enabled
121+
122+
* format: boolean
123+
* example: true
117124

118-
If there is a researcher for whom, if given sufficient time for her belief to converge to the average signal of her and her link-neighbors, this would this be enough to abandon her current theory, her confidence will always be zero and therefore `g-confidence` will also be zero. In this case `g-depressed-confidence` will be set to true in order to avoid redundant confidence calculations.
125+
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.
119126

120127

121128
### Turtles-own
@@ -131,7 +138,7 @@ The theories the researcher currently considers best: 0 = theory 1, 1 = theory 2
131138
* type: float-list
132139
* example: [0.44945 0.594994]
133140

134-
Contains the researchers current evaluation of the two theories. Entry 1 is the evaluation for the first theory and entry 2 for second.
141+
Contains the researchers current evaluation of the two theories. Entry 1 is the evaluation for the first theory and entry 2 for second.
135142

136143
#### mytheory
137144

@@ -199,10 +206,17 @@ How confident the researcher is in the fact that her current best theory is actu
199206
#### avg-neighbor-signal
200207

201208
* type: float
202-
* example: 0.499
209+
* example: 0.499
203210

204211
Only set once all researchers converged. This is the average signal the researcher and her link-neighbors currently observe for the theory they converged on.
205212

213+
#### share-group
214+
215+
* type: turtle-set
216+
* example: (agentset, 3 turtles)
217+
218+
Contains all the scientists this scientist will share information with, including herself. This exists for performance reasons and will be set during `setup`.
219+
206220

207221
## CREDITS AND REFERENCES
208222

SocNetABM.nlogo

+60-29
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
turtles-own [a b theory-jump times-jumped cur-best-th current-theory-info
22
mytheory successes subj-th-i-signal crit-interact-lock confidence
3-
avg-neighbor-signal]
3+
avg-neighbor-signal share-group]
44

55
globals [th-i-signal indiff-count crit-interactions-th1 crit-interactions-th2
66
confidence-cutoff converged-ticks last-converged-th
77
converge-reporters converge-reporters-values
8-
run-start-scientists-save rndseed g-confidence g-depressed-confidence]
8+
run-start-scientists-save rndseed g-confidence g-depressed-confidence
9+
g-fast-sharing-enabled]
910

1011
__includes ["protocol.nls"]
1112

@@ -41,6 +42,12 @@ to setup [rs]
4142
set subj-th-i-signal th-i-signal
4243
]
4344
create-network
45+
ask turtles [
46+
set share-group (turtle-set link-neighbors self)
47+
]
48+
set g-fast-sharing-enabled (network-structure = "complete"
49+
or (network-structure = "wheel" and scientists <= 4)
50+
or (network-structure = "cycle" and scientists <= 3) )
4451
let th-1-scientist count turtles with [mytheory = 0]
4552
let th-2-scientist count turtles with [mytheory = 1]
4653
set run-start-scientists-save (list th-1-scientist th-2-scientist)
@@ -55,10 +62,15 @@ end
5562
to go
5663
ask turtles [
5764
pull
58-
integrate-own-pull-info
65+
]
66+
let fast-sharing (g-fast-sharing-enabled and converged-light)
67+
if fast-sharing [
68+
share-fast
5969
]
6070
ask turtles [
61-
share
71+
if not fast-sharing [
72+
share
73+
]
6274
calc-posterior
6375
compute-strategies
6476
if crit-interact-lock > 0 [
@@ -232,11 +244,16 @@ end
232244

233245

234246

235-
; The information the scientist has obtained via her own pulls is integrated
236-
; into her memory
237-
to integrate-own-pull-info
238-
set a (map + a successes)
239-
set b replace-item mytheory b (item mytheory b + pulls)
247+
; the sharing of information between researchers in case that they are all on
248+
; the same theory and the structure of the network is equivalent to "complete".
249+
to share-fast
250+
let cur-theory [mytheory] of one-of turtles
251+
let cum-successes sum [item cur-theory successes] of turtles
252+
let cum-pulls pulls * scientists
253+
ask turtles [
254+
set a replace-item cur-theory a (item cur-theory a + cum-successes)
255+
set b replace-item cur-theory b (item cur-theory b + cum-pulls)
256+
]
240257
end
241258

242259

@@ -251,7 +268,7 @@ to share
251268
; first list entry is th1 2nd is th2
252269
let successvec [0 0]
253270
let pullcounter [0 0]
254-
ask link-neighbors [
271+
ask share-group [
255272
ifelse mytheory = cur-turtle-th or not critical-interaction [
256273
set successvec (map + successvec successes)
257274
set pullcounter replace-item mytheory pullcounter
@@ -654,23 +671,23 @@ NIL
654671
HORIZONTAL
655672

656673
@#$#@#$#@
657-
# UNDER CONSTRUCTION
674+
# UNDER CONSTRUCTION
658675

659676
# SocNetABM
660-
NetLogo iteration of Zollman's (2010) ABM with critical interaction.
677+
NetLogo iteration of Zollman's (2010) ABM with critical interaction.
661678

662679

663680

664681
## HOW IT WORKS
665682

666-
Beliefs of the researchers are modeled via a beta distribution: The mean of the beta distribution is their current belief.
683+
Beliefs of the researchers are modeled via a beta distribution: The mean of the beta distribution is their current belief.
667684

668685

669686

670687
## NETLOGO FEATURES
671688

672689
The binomial distribution is approximated by the normal distribution with the same mean and variance. This approximation is highly accurate for all parameter values from the interface.
673-
B/c the normal distribution is a continuous distribution the outcome is rounded and there is a safety check which constrains the distribution to the interval [0, pulls] to prevent negative- or higher than pulls numbers of successes.
690+
B/c the normal distribution is a continuous distribution the outcome is rounded and there is a safety check which constrains the distribution to the interval [0, pulls] to prevent negative- or higher than pulls numbers of successes.
674691

675692
## Variables
676693

@@ -684,14 +701,14 @@ Default-values have been set to mirror Zollman's (2010) model. The slider ranges
684701
#### th-i-signal
685702

686703
* type: float-list
687-
* example: [0.5 0.499]
704+
* example: [0.5 0.499]
688705

689706
The average objective probability of success (ops)for [theory-1 theory-2].
690707

691708
#### indiff-count
692709

693710
* type: integer
694-
* example: 1003
711+
* example: 1003
695712

696713
The sum of number of rounds each scientist was indifferent between the two theories.
697714

@@ -705,7 +722,7 @@ The sum of critical interactions scientists on theory 1(2) encountered.
705722
#### confidence-cutoff
706723

707724
* type: integer
708-
* example: 0.9999
725+
* example: 0.9999
709726

710727
The global-confidence `g-confidence` must be higher than this value for the run to be terminated.
711728

@@ -734,44 +751,51 @@ The maximal number of rounds before a run is terminated by the exit condition.
734751
#### converge-reporters
735752

736753
* type: anonymous reporters list
737-
* example: [(anonymous reporter: [ average-belief 0 true ]) (anonymous reporter: [ average-cum-successes 0 true ]) (anonymous reporter: [ average-confidence true ])]
754+
* example: [(anonymous reporter: [ average-belief 0 true ]) (anonymous reporter: [ average-cum-successes 0 true ]) (anonymous reporter: [ average-confidence true ]) (anonymous reporter: [ average-signal 0 true ])]
738755

739-
Reporters which have to be collected in the round when researchers converge. The values for those reporters is then stored in the global `converge-reporters-values` and retrieved by BehaviourSpace at the end of the run.
756+
Reporters which have to be collected in the round when researchers converge. The values for those reporters is then stored in the global `converge-reporters-values` and retrieved by BehaviourSpace at the end of the run.
740757

741758
#### converge-reporters-values
742759

743760
* type: list
744-
* example: [["avgbelief" 0.4998 0.4980] ["avgsuc" 757100.9795 383442.9715] ["avgconfidence" 60234.0298]]
761+
* example: [["avgbelief" 0.4997690253321044 0.49127250748536755] ["avgsuc" 110667.02991226684 21169.651936606337] ["avgconfidence" 0.7645093577413972] ["avgsignal" 0.5 0.499]]
745762

746-
The values from the anonymous reporters in `converge-reporters`, recorded at the last time researchers converged.
763+
The values from the anonymous reporters in `converge-reporters`, recorded at the last time researchers converged.
747764

748765
#### run-start-scientists-save
749766

750767
* type: integer-list
751768
* example: [5 5]
752769

753-
The number of scientists on [th1 th2] at the beginning of the run.
770+
The number of scientists on [th1 th2] at the beginning of the run.
754771

755772
#### rndseed
756773

757774
* format: integer
758775
* example: -2147452934
759776

760-
Stores the random-seed of the current run.
777+
Stores the random-seed of the current run.
761778

762779
#### g-confidence
763780

764781
* format: float
765-
* example: 0.9993
782+
* example: 0.9993
766783

767-
Global-confidence: the probability that not a single researcher will switch theories i.e. the probability that this convergence is final. Range: [0,1]
784+
Global-confidence: the probability that not a single researcher will switch theories i.e. the probability that this convergence is final. Range: [0,1]
768785

769786
#### g-depressed-confidence
770787

771788
* format: boolean
772-
* example: false
789+
* example: false
773790

774-
If there is a researcher for whom, if given sufficient time for her belief to converge to the average signal of her and her link-neighbors, this would this be enough to abandon her current theory, her confidence will always be zero and therefore `g-confidence` will also be zero. In this case `g-depressed-confidence` will be set to true in order to avoid redundant confidence calculations.
791+
If there is a researcher for whom, if given sufficient time for her belief to converge to the average signal of her and her link-neighbors, this would this be enough to abandon her current theory, her confidence will always be zero and therefore `g-confidence` will also be zero. In this case `g-depressed-confidence` will be set to true in order to avoid redundant confidence calculations.
792+
793+
#### g-fast-sharing-enabled
794+
795+
* format: boolean
796+
* example: true
797+
798+
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.
775799

776800

777801
### Turtles-own
@@ -787,7 +811,7 @@ The theories the researcher currently considers best: 0 = theory 1, 1 = theory 2
787811
* type: float-list
788812
* example: [0.44945 0.594994]
789813

790-
Contains the researchers current evaluation of the two theories. Entry 1 is the evaluation for the first theory and entry 2 for second.
814+
Contains the researchers current evaluation of the two theories. Entry 1 is the evaluation for the first theory and entry 2 for second.
791815

792816
#### mytheory
793817

@@ -855,10 +879,17 @@ How confident the researcher is in the fact that her current best theory is actu
855879
#### avg-neighbor-signal
856880

857881
* type: float
858-
* example: 0.499
882+
* example: 0.499
859883

860884
Only set once all researchers converged. This is the average signal the researcher and her link-neighbors currently observe for the theory they converged on.
861885

886+
#### share-group
887+
888+
* type: turtle-set
889+
* example: (agentset, 3 turtles)
890+
891+
Contains all the scientists this scientist will share information with, including herself. This exists for performance reasons and will be set during `setup`.
892+
862893

863894
## CREDITS AND REFERENCES
864895

protocol.nls

+13
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ end
6262

6363

6464

65+
; reports whether all scientists are on the same theory
66+
to-report converged-light
67+
if any? turtles with [mytheory = 0] and any? turtles with [mytheory = 1] [
68+
report false
69+
]
70+
report true
71+
end
72+
73+
74+
75+
76+
77+
6578
; Calculates how confident the researcher is in the fact that her current best
6679
; theory is actually the best theory (i.e. how unlikely it is that she will
6780
; change her mind). This calculation only makes sense in case researchers have

0 commit comments

Comments
 (0)