-
Notifications
You must be signed in to change notification settings - Fork 0
/
MC2R-RandomTies.nlogo
1484 lines (1247 loc) · 37 KB
/
MC2R-RandomTies.nlogo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;By m6f, any comment please write me at hellypoch@gmail.com
;Global Variables
globals[contadorAct contadorActNull i j tduni1 tduni2 tduni3 tduni4 blacks
N propini propfin propiniab propt0 personas Caux sum-color1 sum-color2
sum-color3 sum-color4 npixel z pc nlist nlist1 acolor
t0party_1 t0party_2 t0party_3 t0party_4 t0party_5
contempate-mr contempate-ab menorav mayorav colorempate2rm
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12
]
;PATCH VARIABLES
patches-own [partido influencia]
;---------------
;SETUP PROCEDURE. System initializatioin, by distributing opinions A,B,C,0
;Opinions A, B, C, 0 are drawed with black respectively.
;------------------------------------------------------------------------
to setup
;Resize the work according to netorder value
resize-world 0 netorder 0 netorder
;tparty_1 is the variable associated with entry buttom, also variables tparty_2, tparty_3, tparty_4, tparty_5 has an entry buttom
;this variables serves to initialize the world, at the beginning must be 0, and at final inizialitation must be equal to persons_party's variables.
set tparty_1 0
set tparty_2 0
set tparty_3 0
set tparty_4 0
set tparty_5 0
;porcentA, porcentB and porcentC sets percents for party, i.e., numbers in [0,1] s.t. porcentA + porcentB = 1 - pocentC and porcentC <= 1
ifelse (porcentC <= 1)
[
;Setting porcentC to 0.5 party C has the half of nodes and AB has the other half
set porcentB (precision (1 - porcentC - porcentA) 3) ;precision predicate sets the number of decimal digits to use.
]
[ stop ]
;Setting number of nodes in totaladistribuir variable
;Fixing totaladistribuir, in general it could be variable
;set totaladistribuir (netorder + 1) * (netorder + 1)
set nnodos (netorder + 1) * (netorder + 1)
;First erase our world
clear-all
;To each patche we set its party to null party, influencia to 0, color to black
ask patches [set partido 4 set influencia 0 set pcolor black]
;To assign the number of nodes we use porcent variables and totaladistribuir variable.
set persons_party1 floor (porcentA * totaladistribuir)
set persons_party2 floor (porcentB * totaladistribuir)
set persons_party3 floor (porcentC * totaladistribuir)
set persons_party4 nnodos - persons_party1 - persons_party2 - persons_party3
;To have an ordered list of patches
set npixel []
set i 0
set j 0
repeat netorder + 1 ; Run r times the inner repeat
[
repeat netorder + 1 ; Run r times set npixel...
[
set npixel sentence npixel patch i j
set j j + 1 ; Increases j from 0 to 99
]
set i i + 1 ; Increases i from 0 to 99
set j 0
]
;Here npixel is an ordered list o patches pairs, length(npixel)=10000
set Caux npixel
;10000 = N
set N nnodos
;It is distributed patches according to persons_party1, persons_party2, and persons_party3
;List to be filled with the patche distribution per party. Initialized to empty list
set tduni1 []
set tduni2 []
set tduni3 []
set tduni4 []
;To distribute A nodes
repeat persons_party1 ;Repeat participante1 times
[
set z random N ; 0 <= z <= 9999
ask item z npixel [set pcolor 2 set partido 1 set influencia 1] ;Selects a random patch in npixel list then change its attributes
set npixel replace-item z npixel item (N - 1) npixel;npixel is indiced from 0 to N-1
set tduni1 sentence tduni1 item z npixel
set N N - 1
]
;To distribute B nodes
;Last N value comes in the previous cycle then it has N - persons_party1
repeat persons_party2
[
set z random N
ask item z npixel [set pcolor 8 set partido 2 set influencia 1]
set npixel replace-item z npixel item (N - 1) npixel
set tduni2 sentence tduni2 item z npixel
set N N - 1
]
;To distribute C nodes, takint in account if C is or not #V(R)/2
;Last N value comes in the previous cycle then it has N - persons_party1 - persons_party2
ifelse persons_party3 = nnodos / 2
[
ask patches with [pcolor = black] [ set pcolor white set partido 3 set influencia 1 ]
;set N 0
;set i pxcor
;set j pycor
;set tduni3 sentence tduni3 patch i j ]
]
[
; to enter here persons_party3 is less (or more) than #V(R)
repeat persons_party3
[
set z random N
ask item z npixel [set pcolor white set partido 3 set influencia 1]
set npixel replace-item z npixel item (N - 1) npixel
set tduni3 sentence tduni3 item z npixel
set N N - 1
]
;stop
]
;If persons_party1 + persons_party + persons_party3 not equal to network order, by floors and
;we have no null nodes, then assign the node to party3
if N - persons_party4 > 0 and persons_party4 > 0
[
ask (patches with [pcolor = black]) [set pcolor white set partido 3 set influencia 1]
]
if persons_party4 > 0
[
ask patches with [pcolor = black] [
set i pxcor
set j pycor
set tduni4 sentence tduni4 patch i j
]
]
set blacks count patches with [pcolor = black]
;Contamos los individuos de cada partido
set tparty_1 count patches with [partido = 1]
set tparty_2 count patches with [partido = 2]
set tparty_3 count patches with [partido = 3]
set tparty_4 count patches with [partido = 4]
set tparty_5 count patches with [pcolor = 8 or pcolor = 2]
;Variable to count draws under main MR
set contempate-mr 0
;Variable to count coalition draws under MR
set contempate-ab 0
;Variables para contar cada actualización realizada
set contadorAct 0 ;Este contador nos permite contar el numero de pasos de actualizacion y se usa al dibujar la cuadricula
set contadorActNull 0 ;Este contador nos permita contar el numero de ciclos antes de acabar con indecisos
;To know minimum and maximum size party and to fix initial proportion.
;I = Im / Ig
ifelse tparty_1 < tparty_2
[
set menorav 2 ;minor is party1
set mayorav 8 ;mayor is party2
set propini tparty_1 / (tparty_2)
set propiniab tparty_1 / (tparty_1 + tparty_2)
]
[
set menorav 8 ;minor is party2
set mayorav 2 ;mayor is party1
set propini tparty_2 / (tparty_1)
set propiniab tparty_2 / (tparty_1 + tparty_2)
]
set propfin 0 ; initially we set propfin to 0
reset-ticks ; reset tick counter variable to count the number of entrances to setup procedure
end
;INICIO PROCEDURE. Apply repetition scheme and inspection of patches
;-------------------------------------------------------------------
to inicio
;A repetition or a cycle is a selection of totaladistribuir nodes with or without repetition, here, following Redner we use 600 as the maximum number of repetitions
repeat 1400 ;Stripe
[
;Condicion para terminar el la dinámica del modelo, escencialmente es que se llege al concenso o que se efectuen todos los 600 ciclos
if (tparty_1 = nnodos) or (tparty_2 = nnodos) or (tparty_3 = nnodos) or (tparty_4 = nnodos) or (tparty_5 = nnodos) [stop]
set N nnodos
set npixel Caux ; Return npixel to the previos before modified in setup procedure.
;Repeat nnodos - lattice network order - A CYCLE
repeat nnodos
[
;Choose a random item for patch list
set z random N ;0 <= z <= nnodos-1
;Computations over the 4-neighbourhood for patche (xi,yj)
ask item z npixel
[
;Choose a patch with coordinates (xi,yj) then save it in personas list
set personas sentence personas item z npixel
;To determinate how is theh neighbourhood of patch (xi,yj) in termos of number of nodes per party
ask item z npixel [set sum-color1 sum ([influencia] of neighbors4 with [pcolor = 2])] ;Party 1
ask item z npixel [set sum-color2 sum ([influencia] of neighbors4 with [pcolor = 8])] ;Party 2
ask item z npixel [set sum-color3 sum ([influencia] of neighbors4 with [pcolor = white])] ;Party 3
set sum-color4 4 - sum-color1 - sum-color2 - sum-color3 ;Party 4, the null node arround patch xi yj, they has influencia = 0
;To count number of inspections we made
set contadorAct contadorAct + 1
;To know the number of cycles when null nodes desapair
if tparty_4 > 0
[
set contadorActNull contadorActNull + 1
]
;Party 1 = A color soft black code 2, party 2 = B color gray code 8, party 3 = C color white code white, null = 0 color black code 0
;To add central node and take it in account
if (pcolor = 2)
[
set sum-color1 sum-color1 + 1
]
if (pcolor = 8)
[
set sum-color2 sum-color2 + 1
]
if (pcolor = white)
[
set sum-color3 sum-color3 + 1
]
if (pcolor = black)
[
set sum-color4 sum-color4 + 1
]
if (sum-color4 > 0) [stop]
;To enter into the 4-neighbourhood analysis excluding cases when only have C's or only have A's and B's
;if (sum-color3 > 0 and (sum-color1 > 0 or sum-color2 > 0)) or (sum-color4 > 0 and (sum-color1 > 0 or sum-color2 > 0) or (sum-color4 > 0 and sum-color3 > 0)) [
;To enter here, we considering a 4-neighbourhood AB, C excluding C's or only A's and B's
;To enter and inspect a group G: we consider a 4-neighbourhood with AB, C, 0 excluding C's or only A's and B's or only 0's
;The logic negation is sum-color3=0 or (sum-color1=0 and sum-color2=0) which means only C's and only A's and B's then is correct!
if(sum-color3 > 0 and (sum-color1 > 0 or sum-color2 > 0))
[
;Mayority rule for AB VS C and 0
if (sum-color1 + sum-color2 > sum-color3)
[
;AB wins and exist A's and B's with at least one C or one 0 then flip a coin and select between A o B.
;Example subcase 2: ACBAA ---> random(A,B) --> AAAAA
;Example subcase 2: ABB00 ---> random(A,B) --> BBBBB possibly,
;Case coalition has at least one member from A and one from B
if (sum-color1 > 0 and sum-color2 > 0 and sum-color1 != sum-color2)
[
ifelse random 2 = 0
[
set acolor 2 ;soft black,opinion1
]
[
set acolor 8 ;gray, opinion2
]
;change
ask item z npixel [set pcolor acolor set partido 5 set influencia 1]
ask neighbors4 [set pcolor acolor set partido 5 set influencia 1]
]; ends case when random update is applied: only if exists at least one member for each coalition opinion and becomes different
;We count for majority rule draws, but DO NOTHING rule is applied
if (sum-color1 > 0 and sum-color2 > 0 and sum-color1 = sum-color2) ; if A's = B's then do random selection between {A,B}
[
;Empate coalicion bajo regla de mayoria
ifelse random 2 = 1
[set colorempate2rm 2] ;
[set colorempate2rm 8] ;
ask item z npixel [set pcolor colorempate2rm set partido 5 set influencia 1]
ask neighbors4 [set pcolor colorempate2rm set partido 5 set influencia 1]
;Just delete random rule for the variation
set contempate-ab contempate-ab + 1
;Count cases with 0's here
if(sum-color1 = 1 and sum-color2 = 1 and sum-color4 = 3) ;AB000
[set c7 c7 + 1]
if(sum-color1 = 1 and sum-color2 = 1 and sum-color3 = 1 and sum-color4 = 2) ;ABC00
[set c8 c8 + 1]
if(sum-color1 = 2 and sum-color2 = 2 and sum-color4 = 1) ;AABB0
[set c9 c9 + 1]
if(sum-color1 = 2 and sum-color2 = 2 and sum-color3 = 1) ;AABBC
[set c10 c10 + 1]
]
if(sum-color1 = 0)
[
ask item z npixel [set pcolor 8 set partido 5 set influencia 1]
ask neighbors4 [set pcolor 8 set partido 5 set influencia 1]
]
if(sum-color2 = 0)
[
ask item z npixel [set pcolor 2 set partido 5 set influencia 1]
ask neighbors4 [set pcolor 2 set partido 5 set influencia 1]
]
] ;END coalition AB wins to C in the 4-neighbourhood with central A
;If C wins
if (sum-color3 > sum-color1 + sum-color2)
[
ask item z npixel [set pcolor white set partido 3 set influencia 1]
ask neighbors4 [set pcolor white set partido 3 set influencia 1]
]
;The system has 0's and MR no decides
if (sum-color3 = sum-color1 + sum-color2)
[
;Draw under mr
set contempate-mr contempate-mr + 1
if(sum-color4 = 5) ;00000
[set c1 c1 + 1]
if(sum-color1 = 1 and sum-color3 = 1 and sum-color4 = 3) ;AC000
[set c2 c2 + 1]
if(sum-color2 = 1 and sum-color3 = 1 and sum-color4 = 3) ;BC000
[set c3 c3 + 1]
if(sum-color1 = 2 and sum-color3 = 2 and sum-color4 = 1) ;AACC0
[set c4 c4 + 1]
if(sum-color2 = 2 and sum-color3 = 2 and sum-color4 = 1) ;BBCC00
[set c5 c5 + 1]
if(sum-color1 = 1 and sum-color2 = 1 and sum-color3 = 2 and sum-color4 = 1) ;ABCC0
[set c6 c6 + 1]
]
;--
] ;END coalition AB wins to C in the 4-neighbourhood with central A
if repeticion = false
[ set npixel replace-item z npixel item (N - 1) npixel ;remplace item z of npixel list with item N-1 of npixel, puts final npixel's item on z place
set N N - 1 ]
] ;END ask item z npixel
;if N = 0
;[ stop ]
] ;END repeat nnodos END 1 CYCLE
;To count number of patches per color, after cycle.
set tparty_1 count patches with [pcolor = 2]
set tparty_2 count patches with [pcolor = 8]
set tparty_3 count patches with [pcolor = white ]
set tparty_4 count patches with [pcolor = black]
set tparty_5 count patches with [pcolor = 8 or pcolor = 2]
;To stablish final proportion
if ((menorav = 2) and (tparty_2 != 0)) ;party A is the minimum size party
[
set propfin tparty_1 / tparty_2
]
if ((menorav = 8) and (tparty_1 != 0)) ;party B us the minimum size party
[
set propfin tparty_2 / tparty_1
]
;Aftwer one cycle completion we register final proportion
;set listpropfin sentence listpropfin propfin
] ;END repeat 1400 cycles
stop
end
;Color codes: 45 es white , 55 es 8, 105 es 2, black es 0
; REPORTERS
; proportional report colors 2, 8
to-report proportional
let h random-float 1
if menorav = 2 and h <= propiniab
[report 2]
if menorav = 2 and h > propiniab
[report 8]
if menorav = 8 and h <= propiniab
[report 8]
if menorav = 8 and h > propiniab
[report 2]
end
@#$#@#$#@
GRAPHICS-WINDOW
231
10
439
219
-1
-1
2.0
1
10
1
1
1
0
1
1
1
0
99
0
99
0
0
1
ticks
30.0
BUTTON
819
33
882
66
NIL
setup\n
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
882
33
946
66
NIL
inicio\n
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
SLIDER
801
128
988
161
persons_party1
persons_party1
0
(netorder + 1)*(netorder + 1)
2500.0
1
1
NIL
HORIZONTAL
SLIDER
801
168
988
201
persons_party2
persons_party2
0
(netorder + 1)*(netorder + 1)
2500.0
1
1
NIL
HORIZONTAL
INPUTBOX
290
578
445
638
tparty_1
4650.0
1
0
Number
INPUTBOX
457
578
612
638
tparty_2
3329.0
1
0
Number
INPUTBOX
624
579
779
639
tparty_3
2021.0
1
0
Number
SLIDER
802
207
989
240
persons_party3
persons_party3
0
(netorder + 1)*(netorder + 1)
5000.0
1
1
NIL
HORIZONTAL
INPUTBOX
290
646
445
706
tparty_4
0.0
1
0
Number
INPUTBOX
624
648
779
708
nnodos
10000.0
1
0
Number
INPUTBOX
456
647
613
707
tparty_5
7979.0
1
0
Number
MONITOR
26
75
157
140
2#Draw AC000
c2
17
1
16
MONITOR
26
140
157
205
3#Draw CB000
c3
17
1
16
MONITOR
26
204
157
269
4#Draw AACC0
c4
17
1
16
MONITOR
26
269
157
334
5#Draw BBCC0
c5
17
1
16
MONITOR
786
580
867
625
#Empate MR
contempate-mr
17
1
11
SLIDER
960
82
1141
115
totaladistribuir
totaladistribuir
0
(netorder + 1) * (netorder + 1)
10000.0
1
1
NIL
HORIZONTAL
SLIDER
996
129
1175
162
porcentA
porcentA
0
1
0.25
0.001
1
NIL
HORIZONTAL
SLIDER
997
167
1175
200
porcentB
porcentB
0
1
0.25
0.001
1
NIL
HORIZONTAL
SLIDER
996
206
1175
239
porcentC
porcentC
0
1
0.5
0.001
1
NIL
HORIZONTAL
MONITOR
25
435
191
500
AB#Draw AB000
c7
17
1
16
MONITOR
25
498
191
563
AB#Draw ABC00
c8
17
1
16
MONITOR
24
563
191
628
AB#Draw AABB0
c9
17
1
16
MONITOR
23
628
191
693
AB#Draw AABBC
c10
17
1
16
MONITOR
1190
130
1390
175
#MINOR ini / #MAYOR ini
propini
17
1
11
MONITOR
1190
174
1390
219
#MINOR fin / #MAYOR fin
propfin
17
1
11
MONITOR
822
321
969
366
MinorPartyAB
menorav
17
1
11
MONITOR
976
321
1127
366
Criterio Propor Inicial
propiniab
17
1
11
MONITOR
1008
579
1238
624
Num de actualizaciones A = nnodos x #Ciclos
contadorAct
17
1
11
MONITOR
950
580
1001
625
# Ciclos
contadorAct / nnodos
17
1
11
SWITCH
962
33
1074
66
repeticion
repeticion
1
1
-1000
MONITOR
822
370
948
415
GreatPartyAB
mayorav
17
1
11
CHOOSER
1087
33
1179
78
netorder
netorder
49 74 99 114 149 199 249 299 349 399 449 499 999
2
SWITCH
1189
33
1323
66
districtdraw
districtdraw
1
1
-1000
MONITOR
26
10
183
75
1#Draw 00000 )(
c1
17
1
16
MONITOR
25
333
157
398
6#Draw ABCC0
c6
17
1
16
MONITOR
872
580
945
625
#Empate AB
contempate-ab
17
1
11
TEXTBOX
826
423
1025
537
2 = Soft Black -> tparty1\n8 = Gray -> tparty2\nwhite -> tparty3\n0 = Black -> tnull\n
16
14.0
1
SLIDER
802
247
989
280
persons_party4
persons_party4
0
(netorder + 1) * (netorder + 1)
0.0
1
1
NIL
HORIZONTAL
@#$#@#$#@
## WHAT IS IT?
This is a opinion dynamics model evolving in a system composed of a finite toroidal lattice network R, three active parties (A,B,C) and a possibly a set of uncommited
inactive voters (0). Parties A,B form the coalition AB. We are under assumption of no external influence into the system.
R is a square lattice network with 50,75,100,....,10000 nodes per side, its boundary conditions embbed R on a torus and can be modified by NetLogo by editing the world. R has orders 2500,5620,...,1000000.
he model goal is to shows and update rule which statistically led profit to the
party with high initial voters.
## HOW IT WORKS
This is a opinion dynamics model evolving in a system composed of a finite toroidal lattice network R, three active parties (A,B,C) and a possibly a set of uncommited
inactive voters (0). Parties A,B form the coalition AB. We are under assumption of no external influence into the system.
R is a square lattice network with 50,75,100,....,10000 nodes per side, its boundary conditions embbed R on a torus and can be modified by NetLogo by editing the world. R has orders 2500,5620,...,1000000.
The model goal is to shows and update rule which statistically led profit to the
party with high initial voters.
## HOW IT WORKS
The model starts by setting the initial conditions: number of coalition nodes (A nodes plus B nodes), third party C nodes, and uncommited nodes O.
Network size can be selected with netorder global variable through selector button by choosing its number of nodes per side among 49 (50x50 nodes), 74 (75x75), 99 (100x100),
114 (115x115) or 149 (150x150), or even network sizes of 499 (500x500) and
999 (1000000). But this model has a slow behaviour setting randomly party opinions
with network sizes greater than 150x150. After selecting netorder variable the world is resized.
The model needs as entries C value (usually fixed to .5#V(R)). C is a value
in [0,1] to indicate the proportion of nodes to be assigned for party C, then we need to indicate A (party A proportion) value having in account that B=C-A thus 0 <= A <= C. Once we have fixed C,A we have B (party B proportion).
With A,B, and C, SETUP procedure determinates persons_party1 = A*#V(R), persons_party2 = B*#V(R), and persons_party3 = C*#V(R).
The repetition scheme can be: with repetition or without, in this case is the selection scheme is WITHOUT REPETITION. In the former it means the model inspect #V(R) nodes per cycle but may repeat nodes (faster option), in the later is inspected exactly #V(R) nodes per cycle (low speed option).
If global variable totaladistribuir is less than V(R) then initialization process distribute a total of V(R)-totaladistribuir null nodes.
It has two main procedures: SETUP and INICIO
SETUP
Setup procedure initialize the world conditions by distributing active agents
into the network, this with an uniform distribution fashion.
Starts computing an order list of patches npixel starting from (patch 0 1)
and finishing with (patch netorder netorder).
SETUP initialize i=j=0 then creates npixel list by set (netorder + 1)^2 = #V(R)
thus an exterior cycle of (netorder + 1) repetitions for j=0,...,99 each
value for j, enters in a cycle of (netorder + 1) repetitions for i=0,...,99 and
fill list npixel with patch i j, i.e:
npixel = [(0 0) (0 1) ... (0 99) (1 0) (1 1) ... (1 99) ... (99 0) (99 1) ... (99 99)]
Using npixel list SETUP distributes randomly voters for A, by repeating persons_party1
times the selection of a random index z for npixel, this is acomplished by
set z random N (with N<-#V(R)), then setting patch at item z npixel its variables party = 1, pcolor = 2, influencia = 1, after that interchange item z npixel with
item N npixel, and decreasing N to N-1, with this erasing item z npixel,
After initialize A's N has the value N-persons_party1, then applies same mechanism
for B: repeat a cycle of persons_party2 lenght then, select a random index
set z random N, then change its party, pcolo and influence of patch at item z of npixel.
At this point N has value N - pensons_party1 - persons_party2. Finally, by same
way distribute C patches.
Initialize tparty_1,...,tparty3, with the number of patches with color A,B and C
and tparty_4, tparty_5 with the number of 0's and A+B's respectively.
Initialize variables contempate-mr (mayority rule draws) and contempate-ab (coalition draws) to 0.
Initialize actualization variables contadorAct (number of patches supposed to
be inspected) and contadorActNull (number of patches inspected before 0's disappear).
Initialize list P1,P2,P3, negro, blanco, to empty list.
Those list saves the number of A,B,C,O, and A+B patches
after each cycle.
Decides by comparing cardinalities tparty_1 and tparty_2, who is the minor population party, and saves it in menorav, mayorav variables.
Then compute initial proportion in variable propini: minor party / mayorp party,
and propiniab: minor party / (mayor party + minor party).
INICIO
Then INICIO procedure starts the dynamics on nodes, mainly according to MR.
Exists several monitor buttons which helps to the observer to follow
the evolution of the variables constantly.
Initially set N again to #V(R) and recover npixel list through Caux list
It has a cycle of 1400 out of what the model evolution is consider to be a stripe
configuration. Previous to enter one cycle we recover npixel list trough Caux
and set N to #V(R).