aaa---micro-macro_evolve_salzano.nlogo

来自「NETLOGO」· NLOGO 代码 · 共 951 行 · 第 1/5 页

NLOGO
951
字号
    to i-friends_satisfaction ; ask all individuals. If they are in the group of friends receive informations about their levels of satisfaction.              set inaaa 0 set in 0 set inbbb 0               ask individual [set satisfggg_oth-turtle []]                                 while [in <= Individuals_N - 1] [                   ask turtle in [                   while [inbbb <= Firms_N - 1] [                         ifelse (length values-from individual with [choosen = inbbb and member? in friends-list] [who] != 0) ;[;ifelse (choosen-of turtle (in) = inbbb)                         [set satisfggg_oth-turtle lput ((sum values-from individual with [choosen = inbbb and member? in friends-list] [satisfggg]) / (length values-from individual with [choosen = inbbb and member? in friends-list] [who])) satisfggg_oth-turtle                           ]                          [set satisfggg_oth-turtle lput 0 satisfggg_oth-turtle                           ]                         set inbbb inbbb + 1                         ]]                         set in in + 1 set inbbb 0]           end ;;;;;;;----------------------------------------------------- the core procedure of information communicate and modify! ------------------------------------------------                                            to l-communicate ;; The individual collect information from how other individual (her friends) fill exchanging goods and working with each firm.                      ;; She know with which firm, but she does not know the level of optimum of the individual she has meet.                     ; Therefore, she will obtain knowledge only about how much the other individual agent fill satisfied (implicitly the distance from her Walrassian point)                     ; This procedure is here applied only to individuals. A similar proceduce could be used for firms. This could be strongly usefull for innovation.                                           if(Individuals_N > 1 and hmanyfrom_gr > 0)[ ; check if it is possible to have friends                       i-friends_satisfaction]        ask individual [set oth-turtle []]                 set inaaa 0                    while [inaaa <= Individuals_N - 1] [ask turtle inaaa [ ; ask all individuals. If they are in the group of friends receive informations about their levels of satisfaction.              set inbbb 0              while [inbbb <= Firms_N - 1] [                   if(choosen = inbbb)[                    ifelse ((oth-turtle != nobody) and (Individuals_N > 1 and hmanyfrom_gr > 0)) ; if there is one there and she is a friend                   [set list_in_bbI replace-item inbbb (list_in_bbI) (( (item inbbb (list_in_bbI) * past-inf-val) + satisfggg + (item inbbb satisfggg_oth-turtle * other-inf-val)) / 3)]                   [set list_in_bbI replace-item inbbb (list_in_bbI) (( (item inbbb (list_in_bbI) * past-inf-val) + satisfggg) / 2)] ; Past information loose weight; Information from other has less value then direct one.                                ]; Information about my last time choosen firm from my self, and if the case, from others .                             set inbbb inbbb + 1]                              set inaaa inaaa + 1]                            ]                                   z-Plot-Phase-Diagram; This is the phase diagram of information     end                                                                     ; color turtles with message red, and those without message blue    to m-color-turtles  ; a turtle procedure        ask individual[ set color (5 + ((satisfggg * satisfwww) * 50))]    end;-----------------------------------------------------Calculate each firm total demand ------------------------------------------------          to q-firm-global-demand                             ; to calculate the global demand meet by each firm - 2 ways: a) who chooses each firm;                                                         ; b) each firm is choosen by who.;        ask individual [set mylist1-length length mylist1]         Set sum-list1 []        while [num  < Firms_N] [ask turtle (num + Individuals_N ) [         Set index 0            repeat mylist1-length            [ ; add to the end of sum-list the sum of all items at index "index" all individual mylists            set sum-list1 lput (precision sum values-from individual with [choosen = num] [item (index) mylist1] 3) sum-list1              ; increment index            set index index + 1            ]            set index 0            set total-firm-good-dem sum-list1]             set sum-list1 []  set num num + 1]            set num 0                    ask individual [set mylist2-length length mylist2]        Set sum-list2 []        while [num  < Firms_N] [ask turtle (num + Individuals_N ) [         Set index 0            repeat mylist2-length            [ ; add to the end of sum-list the sum of all items at index "index" all individual mylists            set sum-list2 lput (precision sum values-from individual with [choosen = num] [item (index) mylist2a] 3) sum-list2            ; increment index            set index index + 1            ]            set index 0            set total-firm-work-off sum-list2]            set sum-list2 []  set num num + 1]            set num 0        ask individual [set work_r-list-length length work_r-list]        Set sum-listw []        while [num  < Firms_N] [ask turtle (num + Individuals_N ) [         Set index 0            repeat work_r-list-length            [ ; add to the end of sum-list the sum of all items at index "index" all individual mylists            set sum-listw lput (precision sum values-from individual with [choosen = num] [item (index) work_r-lista] 3) sum-listw          ; increment index            set index index + 1            ]            set index 0            set total-firm-raz-w sum-listw]            set sum-listw []  set num num + 1]            set num 0        ask individual [set good_r-list-length length good_r-list]        Set sum-listg []        while [num  < Firms_N] [ask turtle (num + Individuals_N ) [         Set index 0            repeat good_r-list-length            [ ; add to the end of sum-list the sum of all items at index "index" all individual mylists            set sum-listg lput (precision sum values-from individual with [choosen = num] [item (index) good_r-lista] 3) sum-listg            ; increment index            set index index + 1            ]            set index 0             set total-firm-raz-g sum-listg]            set sum-listg []  set num num + 1]            set num 0                                      ask firm [if count individual with [choosen = num] > 0 [                          set T_H replace-item 0 T_H (max values-from individual with [choosen = num] [item 0 H])  ;; the Walrasian condition for the Total - individuals meting a firm                          set T_H replace-item 1 T_H (max values-from individual with [choosen = num] [item 1 H])  ;; the Walrasian condition for the Total - individuals meting a firm                          ] ]          z-do-plot-Customer_for_firm              end    ;;;;;;;;;;;;;;;;;=========================================================================================================================================================     to prepare-plot-I-Rationed-firm-market         set-current-plot "I Rationed market - Exchange - Work and Good" clear-plot set-current-plot-pen "I Total Good d." plot-pen-reset set-current-plot-pen "I Total Work o."  plot-pen-reset                      ask turtle (Individuals_N + Firm1-to-check - 1) [without-interruption[            (foreach             total-firm-good-dem total-firm-work-off total-firm-raz-w total-firm-raz-w;total-firm-raz-g             [            set TtdI ?1 set Tt-oI ?2 set Tt-rwI ?3  set Tt-rgI ?4            z-do-plot-I-Rationed-firm-market             ])]]         set-current-plot "I Rationed market - Exchange - Work and Good" ;clear-plot set-current-plot-pen "I Total Good d." plot-pen-reset set-current-plot-pen "I Total Work o."  plot-pen-reset                      ask turtle (Individuals_N + Firm1-to-check - 1) [without-interruption[            (foreach            tp1-list tw-list two-list             [            set tpI ?1 set tdI ?2 set t-oI ?3             z-do-plot-I-Rationed-firm-market             ])]]    end    to prepare-aggregate-plot         set-current-plot "Rationated Aggregate Market"          clear-plot          set-current-plot-pen "Indiv _g" plot-pen-reset set-current-plot-pen "Indiv_w"  plot-pen-reset                  ask Agg_individual [           Set index 0            while [index < length Ag-mylist1] [            set Atd item (index) Ag-mylist1            set Atp item (index) Ag-work_r-list            set At-o item (index) Ag-mylist2            set Atg item (index) Ag-work_r-list            z-do-plot-Agg              set index index + 1            ]             ]         set-current-plot "Rationated Aggregate Market"          set-current-plot-pen "Firm_g" plot-pen-reset set-current-plot-pen "Firm_w"  plot-pen-reset                  ask firm [           Set index 0            while [index < length mylist3] [            set Atdf (precision sum values-from firm [item (index) mylist3a] 3)             set Atp1 (precision sum values-from firm [item (index) work_r1-lista] 3)            set Atwo (precision sum values-from firm [item (index) mylist4a] 3)            set Atgf (precision sum values-from firm [item (index) work_r1-lista] 3)            z-do-plot-Agg            set index index + 1            ]            ]    end            to o1-prepare-plot-1  ;1        set f1tc (Individuals_N + Firm1-to-check - 1)  ; set the firm l... to check        Ask turtle f1tc [set itc1 (item 0 individual-choose)]         set-current-plot "1? Ind checked - Work and Good"            clear-plot            set-current-plot-pen "work I" plot-pen-reset set-current-plot-pen "w-offer I"  plot-pen-reset                     ask (turtle itc1) [set index 0 while [index < length i-mylist3]            [set twI item (index) i-mylist3 set twoI item (index) i-mylist4 set tpI1 item(index) i-work_r1-list           z-do-plot1 set index index + 1]]                    set-current-plot "1? Ind checked - Work and Good"        set-current-plot-pen "demand I" plot-pen-reset set-current-plot-pen "d-offer I" plot-pen-reset           ask turtle itc1 [set lwl length work_r-list]           ask turtle (itc1)[           set index 0 while [index < (length work_r-list) ][           set tpI item (index) work_r-list set tdI item(index) mylist2 set t-oI item(index) mylist1           z-do-plot1            set index index + 1]]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?