-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimplified_v.0.95.nlogo
2050 lines (1738 loc) · 47.8 KB
/
Simplified_v.0.95.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
breed [farms farm] ; N. agents
breed [giBoards giBoard] ; One agent
breed [ftokens ftoken] ; Just a token to visualise farms' plots
globals [
nFarms ; 680
wineYield ; 50 hl/ha
qualityStandard ; mean wineQ of vine plots at start
giWinePrice ; 1.5
stdWinePrice ; 1
farmExits ; Count farm exits
globalPlantingRights ; Collects planting rights when farms exit
plantingRightsPrice ; Fixed price of one Planting right
colBrandValue ; The stock variable of the intangible capital in which the GI board invests each year
qualityLev
colBrandLev
giFarmsLev
giPrestige ; A 0 - 4 scale integer affecting GI wine price (average of quality, colBrand and Farms levels).
countdown ; Used
ballotBox ; in the
freqBallots ; institutional
votingOutcome ; change
historyVotes ; process
minQuality ; Both for graphical representation
maxQuality ;
]
patches-own [
elevation ; 0-1000 Interval randomly gen and smoothed
microclimate
soilQ ; 0-1 Interval randomly gen and smoothed
wineQ ; 0-1 Interval wighted function microclimate and soilQ
ageVines ; Vine productive after 3 years since implanted
owner ; Farm number or nobody
pastOwners ; List all past owners
farmStead ; Bolean (1 if farstead here)
fallow ; Bolean (1 if fallow fallow plot)
varCost ; For productive plots (ageVines >3); Increasing with slope (not in simplified model)
fixCost ; For each plot owned
prof ; Patch specific profit
giLabel ; Bolean (1 if quality here > quality standard)
landPrice ; Function of Quality and GI label
]
farms-own [
capital ; Stock variable
revenue ; In each year
profit ; In each year
pastProfits ; List (Memory of past profits)
myPlots ; Agentset farm's plots
myQuality ; Avg. quality of myPlots
plantingRights ; Necessary to plat new vines
pastVintages ; List (Memory quality of past vintages)
ballot ; Farm's vote to change quality standard
]
giBoards-own [
giRevenue ; Revenue generated by fees collected from farms
mktExp ; Investment in marketing in year t (increasing the stock colBrandValue)
]
;# ###################### #
;# --- Initialisation --- #
;# ###################### #
to setup
clear-all
initiate-globals
setup-elevation
setup-microclimate
setup-soilQ
setup-quality
setup-patches
setup-farmers
setup-giBoard
setup-giArea
setup-landPrice
setup-plotProfit
reset-ticks
end
; # --- Globals
to initiate-globals
set wineYield 5000 ; Yields in litres of wine per hectare (50 hl/ha)
set nFarms 340
set giWinePrice 1.5 ; Price of premium quality wine (quality > standard)
set stdWinePrice 1 ; Price of standard quality wine (quality < standard)
ask patches [set varCost 3500 set fixCost 2500] ; is you sell wine at normal price of 1 can barely cover variable costs of one hectare
set globalPlantingRights 0 ; Collect farms' planting rights when they exit the market (i.e., when they "die")
set plantingRightsPrice 50000
set ballotBox [] ; List will collect ballots for institutinal change
set countdown everyXyears ; Timing for initiation of the institutional change process
set historyVotes [] ; Returns history of institutional change outcomes
set colBrandValue 0 ; Stock variable follows intangible capital dinamics
set qualityLev 0 ; Level variable 0 - 4
set colBrandLev 0 ; Level variable 0 - 4
set giFarmsLev 0 ; Level variable 0 - 4
end
; #--- Patches
to setup-elevation
ask patches [set elevation (random-float 1000)]
repeat SmoothElev [ diffuse elevation 0.5]
end
to setup-soilQ
ask patches [set soilQ (random-float 1)]
repeat SmoothSoil [diffuse soilQ 0.5]
end
to setup-microclimate
let mean-elev mean [elevation] of patches
ask patches
[
ifelse elevation <= mean-elev
[set microclimate avgGStemp + 0.0098 * (mean-elev - elevation)]
[set microclimate avgGStemp - 0.0098 * (elevation - mean-elev)]
]
end
to setup-quality
ask patches
[
;set wineQ (0.4 * soilQ ) + (0.6 * (1 - (abs((optGStemp - microclimate)/ optGStemp))))
set wineQ precision (((1 - 0.6) * soilQ) + 0.6 * (1 - ( ((optGStemp - microclimate) ^ 2) / optGStemp))) 4 ; QUADRATIC
]
end
to setup-patches
resize-world 0 49 0 49
set minQuality (min [wineQ] of patches)
set maxQuality (max [wineQ] of patches)
ask patches [
set pcolor scale-color violet wineQ maxQuality minQuality
set owner nobody
set pastOwners []
]
end
; # --- Farmers
to setup-farmers
set-default-shape farms "person"
set-default-shape ftokens "square 3"
let bestPlots max-n-of 925 patches [wineQ]
ask n-of 925 bestPlots
[
sprout-fTokens 1
]
create-farms nFarms
[
move-to one-of bestPlots with [not any? farms-here and any? fTokens-here]
let poscol filter [ x -> not member? x ([color] of (other farms in-radius 4)) ] base-colors
ifelse not empty? poscol [set color one-of poscol] [set color one-of base-colors]
ask patch-here
[
set owner farms-here
set farmStead 1
set ageVines 20
]
]
ask fTokens
[
set color [color] of min-one-of farms [distance myself]
ask patch-here
[
set owner min-one-of farms [distance myself]
set ageVines 20
]
]
ask farms
[
set myPlots patches with [owner = myself]
set myQuality mean [wineQ] of myPlots
set pastVintages []
set pastProfits []
set capital 3 * (sum [fixCost] of myPlots + sum [varCost] of myplots) ; they can cover 3 years total costs of their plots
]
end
; # --- GI
to setup-giBoard
ask one-of patches with [not any? turtles-here] [sprout-giBoards 1]
ask giBoards [move-to one-of patches with-min [wineQ] set color BLACK set shape "star"]
end
to setup-giArea
set qualityStandard min [myQuality] of farms ; All farms can initially fullfill the quality standard
; GI AREA DEFINED with QUALITY STANDARD
let giPatches patches with [wineQ >= qualityStandard]
ask giPatches [set giLabel 1 set plabel-color black set plabel "GI"]
end
to setup-landPrice
ask patches [set landPrice ((wineQ * 40000) + (giLabel * 10000))] ; In France 70000 €/ha on average (Champagne excluded. In this representative region the maximum price is 50000.
end
to setup-plotProfit
ask patches
[
ifelse giLabel = 1
[set prof ((wineYield * giWinePrice) - fixCost - varCost)]
[set prof ((wineYield * stdWinePrice) - fixCost - varCost)]
]
end
;# ##################################### #
;# --- Model Dynamics and Iterations --- #
;# ##################################### #
to go
climateChange
operationalArena
collectiveChoiceArena
tick
end
; --------------------------------------------------------------------------
; # Environmental Change
; --------------------------------------------------------------------------
to climateChange
; INCREASE TEMPERATURE AND UPDATE PATCHES WINE QUALITY
ask patches [
if ClimateScenario = "+ 2°C"
[set microclimate microclimate + 0.0125
update-wineQuality]
if ClimateScenario = "+ 3°C"
[set microclimate microclimate + 0.025
update-wineQuality]
]
refreshWorld
end
to update-wineQuality
; set wineQ ((0.4 * SoilQ) + 0.6 * (1 - (abs((optGStemp - microclimate)/ optGStemp))))
set wineQ precision (((1 - 0.6) * soilQ) + 0.6 * (1 - ( ((optGStemp - microclimate) ^ 2) / optGStemp))) 4 ; QUADRATIC
end
; --------------------------------------------------------------------------
; # Operational Arena
; --------------------------------------------------------------------------
to operationalArena
farmHeuristic
giBoardAction
end
; # --- FARMS
to farmHeuristic
ask farms
[
heuristic
]
; expandFarms
end
to heuristic
; # Reactivate fallow plots that are now suitable (it could happen with high elevation plots and with institutional change)
let goodFallow myPlots with [fallow = 1 and wineQ >= qualityStandard ]
ask goodFallow [set fallow 0 set pcolor scale-color violet wineQ maxQuality minQuality]
let myProdPlots myPlots with [ageVines > 3 and fallow = 0]
; # If no productive plots (e.g., just planted plots and fallow plots, wait and update capital).
if not any? myProdPlots
[
exit-updateCapital
; # Skip sellWine and go to land purchase module
landAdaptation
stop
]
; # Check Average quality
set myQuality mean [wineQ] of myProdPlots
ifelse myQuality < qualityStandard
[
; # MIXED STRATEGY: Farm receive gi wine price only for high quality patches, (i.e., selling standard and gi wine separately)
; # the farm will also set fallow the plots that are not profitable (i.e., when the profit is lower that the fixed cost to keep it fallow , €2500)
ask myProdPlots with [prof <= -2500] [set fallow 1 set pcolor black] ; The patch's state variable "prof" is used here
set myProdPlots myPlots with [ageVines > 3 and fallow = 0]
; # Here might be there are no patches left
if not any? myProdPlots
[
exit-updateCapital
; # Skip sellWine and go to land purchase module
landAdaptation
stop
]
]
[
; # POOL STRATEGY: Farm receive gi wine price for each plot
; # the farm will also set fallow the plots that are not profitable (i.e., when the profit is lower that the fixed cost to keep it fallow , €2500)
ask myProdPlots with [((wineYield * giWinePrice) - fixCost - varCost) <= -2500] [set fallow 1 set pcolor black]
; # And update list of productive plots
set myProdPlots myPlots with [ageVines > 3 and fallow = 0]
; # Here might be there are no patches left
if not any? myProdPlots
[
exit-updateCapital
; # Skip sellWine and go to land purchase module
landAdaptation
stop
]
]
sellWine
landAdaptation
abandonFarming
end
to sellWine
; # 2) SELL WINE
let myProdPlots myPlots with [ageVines > 3 and fallow = 0]
let totalCost sum [fixCost] of myPlots + sum [varCost] of myProdPlots
if capital < totalCost
[
set farmExits farmExits + 1
set plantingRights count myPlots
ask myPlots [
set owner nobody
set fallow 0
set ageVines 0
set pastOwners insert-item (length pastOwners) pastOwners ([who] of myself)
ask fTokens-on self [die]
set pcolor scale-color violet wineQ maxQuality minQuality
]
set globalPlantingRights globalPlantingRights + plantingRights
die
]
; # Calculate final profit and and update capital
let totalRevenue ifelse-value myQuality < qualityStandard
[((giWinePrice * (wineYield * count myProdPlots with [giLabel = 1] )) + (stdWinePrice * (wineYield * count myProdPlots with [giLabel = 0])))]
[(giWinePrice * (wineYield * count myProdPlots ))]
set profit totalRevenue - totalCost
set revenue totalRevenue ; I need this to anable the GI board to collect fees
set pastProfits insert-item (length pastProfits) pastProfits profit ; Save current profit in memory
set capital (capital + profit)
set pastVintages insert-item (length pastVintages) pastVintages (mean [wineQ] of myProdPlots) ; Save quality of vintage in farm's memory
ask myPlots [if ageVines < 20 [set ageVines ageVines + 1]] ; Assume that farmers manage vines to keep average age no higher than 20.
end
to exit-updateCapital
let totalCost sum [fixCost] of myPlots
if capital < totalCost
; # Bankruptcy EXIT -------------------------------------------------------------------------
[
set farmExits farmExits + 1
set plantingRights count myPlots
ask myPlots [
set owner nobody
set fallow 0
set ageVines 0
set pastOwners insert-item (length pastOwners) pastOwners ([who] of myself)
ask fTokens-on self [die]
set pcolor scale-color violet wineQ maxQuality minQuality
]
set globalPlantingRights globalPlantingRights + plantingRights
die
]
; # ---------------------------------------------------------------------------------------
; # Update Capital
set profit (- totalCost)
set revenue 0
set pastProfits insert-item (length pastProfits) pastProfits profit ; Save current profit in memory
set capital (capital + profit)
set pastVintages insert-item (length pastVintages) pastVintages 0 ; no Vintage
; # Update age of vines
ask myPlots [if ageVines < 20 [set ageVines ageVines + 1]] ; Assume that farmers manage vines to keep average age no higher than 20.
end
to landAdaptation
; # 3) Buy new plot
; # Is my quality decreasing in the last three years? I need to find new plots high quality plots!
if length pastVintages >= memory
[
let meanPV mean (sublist pastVintages (ticks - memory + 1) (ticks + 1))
if precision meanPV prec > precision myQuality prec ; NOW PRECISION IS INSERED ALSO HERE.
[
; # Only if there are interesting plots to buy makes sense to sell plots.
let interestingPlots ifelse-value inRadius?
[patches in-radius radius with [wineQ > qualityStandard and owner = nobody and (member? [who] of myself pastOwners) = false and prof > 0] with-max [prof]] ; They know if a plot is profitable, thus they avoid the slopy plots
[patch-set ([neighbors] of myPlots with [wineQ > qualityStandard and owner = nobody and (member? [who] of myself pastOwners) = false and prof > 0] with-max [prof])] ; [neighbors] of myPlots or patches in-radius x? include distance from farmstead in cost calculation
if any? interestingPlots
[
sellLowestQplot ; CHANGE SELL PLOT ONLY IF THERE IS ONE with HIGHER QUALITY AROUND
if plantingRights > 0 [buyNewPlot]
]
]
]
end
to sellLowestQplot
; # In this way the farmers will sell all low elevation plots up to the point in which the lowest plot is the farmstead plot.
let chosenPlot myPlots with [farmStead = 0 and elevation < mean [elevation] of [myPlots] of myself] with-min [wineQ]
ifelse any? chosenPlot
[
ask chosenPlot
[
set owner nobody
set fallow 0
set ageVines 0
set pastOwners insert-item (length pastOwners) pastOwners ([who] of myself)
ask fTokens-on self [die]
set pcolor scale-color violet wineQ maxQuality minQuality
]
set myPlots myPlots with [not member? self patch-set chosenPlot]
set capital capital + first [landPrice] of chosenPlot
set plantingRights plantingRights + 1
]
[]
end
to buyNewPlot
; # Check neighbouring plots with quality higher than standard and no owner
let interestingPlots ifelse-value inRadius?
[patches in-radius radius with [wineQ > qualityStandard and owner = nobody and (member? [who] of myself pastOwners) = false and prof > 0] with-max [prof]] ; They know if a plot is profitable, thus they avoid the slopy plots
[patch-set ([neighbors] of myPlots with [wineQ > qualityStandard and owner = nobody and (member? [who] of myself pastOwners) = false and prof > 0] with-max [prof])] ; [neighbors] of myPlots or patches in-radius x? include distance from farmstead in cost calculation
if any? interestingPlots
[
let installCost 3 * fixCost ; the installation cost is the fix cost of maintaning the new vineyard which is unproductive for 3 years (only generating fixed costs of maintenence).
if capital >= (first ([landPrice] of interestingPlots with-max [wineQ])) + installCost
[
let chosenPlot interestingPlots with-max [wineQ]
ask chosenPlot [set owner [who] of myself ; ONE FARM AT THE TIME (as for the whole heuristic): SOMEBODY WILL RANDOMLY BE SELECTED TO MOVE FIRST THEREFORE HAVING MORE PLOTS TO CHOOSE FROM.
sprout-fTokens 1
set ageVines 0]
ask fTokens-on chosenPlot [set color [color] of myself]
set myPlots (patch-set myPlots chosenPlot)
set capital capital - first [landPrice] of chosenPlot
set plantingRights plantingRights - 1
]
]
end
to abandonFarming
if length pastProfits >= 3
[
let posLastProfits filter [i -> i > 0] (sublist pastProfits (ticks - 3 + 1) (ticks + 1))
if empty? posLastProfits ; if three years of negative profits sell the least profitable plot
[
if (myPlots with [farmStead = 0]) = no-patches ; if the last plot is the farmstead, the farm exits.
[
set farmExits farmExits + 1
set plantingRights plantingRights + 1
ask patch-here
[
set owner nobody
set fallow 0
set ageVines 0
set pastOwners insert-item (length pastOwners) pastOwners ([who] of myself)
ask fTokens-on self [die]
set pcolor scale-color violet wineQ maxQuality minQuality
]
set globalPlantingRights globalPlantingRights + plantingRights
die
]
let chosenPlot one-of myPlots with [farmstead = 0 ] with-min [prof]
ask chosenPlot
[
set owner nobody
set fallow 0
set ageVines 0
set pastOwners insert-item (length pastOwners) pastOwners ([who] of myself)
ask fTokens-on self [die]
set pcolor scale-color violet wineQ maxQuality minQuality
]
set myPlots myPlots with [not member? self patch-set chosenPlot]
set capital capital + [landPrice] of chosenPlot
set plantingRights plantingRights + 1
]
]
end
;------------------------------------------------------------------------------
; # --- GI BOARD
to giBoardAction
reshapeGIarea
update-landPrices
collectFees
investMarketing
update-giPrestige
update-winePrice
update-plotProfit
end
to reshapeGIarea
; # Reassign GI label to patches with quality higer than the quality standard.
ask patches [ifelse wineQ < qualityStandard [set giLabel 0] [set giLabel 1]]
ask patches with [giLabel = 1] [set plabel-color black set plabel "GI"]
ask patches with [giLabel = 0] [set plabel ""]
end
to update-landPrices
ask patches [set landPrice ((wineQ * 40000) + (giLabel * 10000))]
end
to collectFees
ask farms
[
if revenue > 0
[
set profit profit - %fee * revenue
set capital capital - %fee * revenue
ask giBoards [set giRevenue giRevenue + %fee * [revenue] of myself]
]
]
end
to investMarketing
ask giBoards
[
set mktExp delta * giRevenue
set colBrandValue (colBrandValue + mktExp - (rho * colBrandValue))
set giRevenue 0 ; Nothing is retained, no profits, all the rest is spent in quality control
]
end
to update-giPrestige
let giProducers farms with [any? myPlots with [ageVines > 3 and giLabel = 1]]
let giprodQuality ifelse-value any? patches with [ageVines > 3 and giLabel = 1]
[mean [wineQ] of patches with [ageVines > 3 and giLabel = 1]] [0]
; # GI prestige in levels
; # QUALITY LEVELS
; # Level 1
set qualityLev 0
if giprodQuality >= 0.6 and giprodQuality < 0.7
[set qualityLev 1]
; # Level 2
if giprodQuality >= 0.7 and giprodQuality < 0.8
[set qualityLev 2]
; # Level 3
if giprodQuality >= 0.8 and giprodQuality < 0.9
[set qualityLev 3]
; # Level 4
if giprodQuality >= 0.9
[set qualityLev 4]
; # Marketing Investment LEVELS
; # Level 1
set colBrandLev 0
if colBrandValue >= basBrandValue and colBrandValue < 2 * basBrandValue
[set colBrandLev 1]
; # Level 2
if colBrandValue >= 2 * basBrandValue and colBrandValue < 3 * basBrandValue
[set colBrandLev 2]
; # Level 3
if colBrandValue >= 3 * basBrandValue and colBrandValue < 4 * basBrandValue
[set colBrandLev 3]
; # Level 4
if colBrandValue >= 4 * basBrandValue
[set colBrandLev 4]
; # GI Farms LEVELS
; # Level 1
set giFarmsLev 0
if (count giProducers / count farms) >= 0.5 and (count giProducers / count farms) < 0.7
[set giFarmsLev 1]
; # Level 2
if (count giProducers / count farms) >= 0.7 and (count giProducers / count farms) < 0.8
[set giFarmsLev 2]
; # Level 3
if (count giProducers / count farms) >= 0.8 and (count giProducers / count farms) < 0.9
[set giFarmsLev 3]
; # Level 4
if (count giProducers / count farms) >= 0.9
[set giFarmsLev 4]
; ##########################
set giPrestige round mean (list qualityLev colBrandLev giFarmsLev)
end
to update-winePrice
If giPrestige = 0 [set giWinePrice 1]
If giPrestige = 1 [set giWinePrice 1.5]
If giPrestige = 2 [set giWinePrice 1.75]
If giPrestige = 3 [set giWinePrice 2]
If giPrestige = 4 [set giWinePrice 3]
end
to update-plotProfit
ask patches
[
ifelse giLabel = 1
[set prof ((wineYield * giWinePrice) - fixCost - varCost)]
[set prof ((wineYield * stdWinePrice) - fixCost - varCost)]
]
end
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
to collectiveChoiceArena
if votingMechanism != "NO VOTE"
[
institutionalChange
if ticks = 49 or ticks = 99 [type "VOTING HISTORY :" print historyVotes]
]
end
to institutionalChange
; # Each Farm vote
set countdown countdown - 1
if countdown = 0
[
set ballotBox []
clear-output
let lowerStandard precision (qualityStandard - qualityDelta) prec
let higherStandard precision (qualityStandard + qualityDelta) prec
ask farms
[
if length pastVintages >= memory
[
let goodOldDays precision mean (sublist pastVintages 0 memory) prec
let meanPV precision mean (sublist pastVintages (ticks - memory + 1) (ticks + 1)) prec ; looking back of x years in pastVintages (driven by parameter memory).
ifelse precision myQuality prec < precision qualityStandard prec ; Of course if their quality is lower than the standard they are pressured to lower it
[
set ballot -1
set ballotBox insert-item (length ballotBox) ballotBox ballot
]
[ ; When it is not they will decide based on their memory
if precision myQuality prec < meanPV
[
set ballot -1
set ballotBox insert-item (length ballotBox) ballotBox ballot
]
if precision myQuality prec > meanPV and higherStandard < precision (myQuality) prec ; You want to avoid that they increase the standard and they cannot even respect it.
[
set ballot 1
set ballotBox insert-item (length ballotBox) ballotBox ballot
]
if precision myQuality prec = meanPV
[
set ballot 0
set ballotBox insert-item (length ballotBox) ballotBox ballot
]
]
]
]
;--------------------------------------------------------------------------
; # RELATIVE MAJORITY
if votingMechanism = "REL Majority"
[
set ballotBox sort ballotBox
set freqBallots map [ i -> frequency i ballotBox] (range -1 2)
let mode modes ballotBox
if mode = [1]
[
ifelse (qualityStandard + qualityDelta) < 1 [set qualityStandard qualityStandard + qualityDelta] [set qualityStandard 1]
let result "INCREASE!"
set votingOutcome 1
set historyVotes insert-item (length historyVotes) historyVotes result
output-type "YEAR " output-print (ticks + 1)
output-print "BALLOT COUNT:"
output-print " D C I "
output-print freqBallots
output-print result
]
if mode = [-1]
[
ifelse (qualityStandard - qualityDelta) > 0.5 [set qualityStandard qualityStandard - qualityDelta] [set qualityStandard 0.5]
let result "DECREASE!"
set votingOutcome -1
set historyVotes insert-item (length historyVotes) historyVotes result
output-type "YEAR " output-print (ticks + 1)
output-print "BALLOT COUNT:"
output-print " D C I "
output-print freqBallots
output-print result
]
if mode = [0]
[
let result "CONSTANT!"
set votingOutcome 0
set historyVotes insert-item (length historyVotes) historyVotes result
output-type "YEAR " output-print (ticks + 1)
output-print "BALLOT COUNT:"
output-print " D C I "
output-print freqBallots
output-print result
]
set countdown everyXyears
]
;--------------------------------------------------------------------------
; # ABSOLUTE MAJORITY
if votingMechanism = "ABS Majority"
[
set ballotBox sort ballotBox
set freqBallots map [ i -> frequency i ballotBox] (range -1 2)
if item 2 freqBallots >= (sum freqBallots / 2) + 1
[
ifelse (qualityStandard + qualityDelta) < 1 [set qualityStandard qualityStandard + qualityDelta] [set qualityStandard 1]
let result "INCREASE!"
set votingOutcome 1
set historyVotes insert-item (length historyVotes) historyVotes result
output-type "YEAR " output-print (ticks + 1)
output-print "BALLOT COUNT:"
output-print " D C I "
output-print freqBallots
output-print result
]
if item 0 freqBallots >= (sum freqBallots / 2) + 1
[
ifelse (qualityStandard - qualityDelta) > 0.5 [set qualityStandard qualityStandard - qualityDelta] [set qualityStandard 0.5]
let result "DECREASE!"
set votingOutcome -1
set historyVotes insert-item (length historyVotes) historyVotes result
output-type "YEAR " output-print (ticks + 1)
output-print "BALLOT COUNT:"
output-print " D C I "
output-print freqBallots
output-print result
]
if item 1 freqBallots >= (sum freqBallots / 2) + 1
[
let result "CONSTANT!"
set votingOutcome 0
set historyVotes insert-item (length historyVotes) historyVotes result
output-type "YEAR " output-print (ticks + 1)
output-print "BALLOT COUNT:"
output-print " D C I "
output-print freqBallots
output-print result
]
set countdown everyXyears
]
]
end
to-report frequency [an-item a-list]
report length (filter [ i -> i = an-item] a-list)
end
;# GRAPHIC STUFF
;-----------------------------------------
to refreshworld
; let minquality (min [wineQ] of patches)
; let maxquality (max [wineQ] of patches)
ask patches with [fallow = 0]
[if (wineQ <= 0) or (WineQ >= 0)[set pcolor scale-color violet wineQ maxQuality minQuality]]
ask patches with [fallow = 1]
[set pcolor black]
end
@#$#@#$#@
GRAPHICS-WINDOW
10
10
618
619
-1
-1
12.0
1
8
1
1
1
0
0
0
1
0
49
0
49
0
0
1
ticks
30.0
SLIDER
626
91
718
124
SmoothElev
SmoothElev
0
10
7.0
1
1
NIL
HORIZONTAL
BUTTON
624
10
687
43
NIL
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
MONITOR
626
129
687
174
mean elev
precision mean [elevation] of patches 2
17
1
11
MONITOR
691
129
746
174
max elev
precision max [elevation] of patches 2
17
1
11
MONITOR
750
129
802
174
min elev
precision min [elevation] of patches 2
17
1
11
MONITOR
627
251
686
296
mean clim
precision mean [microclimate] of patches 2
17
1
11
MONITOR
692
252
751
297
max clim
precision max [microclimate] of patches 2
17
1
11
MONITOR
752
252
803
297
min clim
precision min [microclimate] of patches 2
17
1
11
SLIDER
719
91
811
124
SmoothSoil
SmoothSoil
0
10
6.0
1