aaa---micro-macro_evolve_salzano.nlogo

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

NLOGO
951
字号
         set satisfpermang (satisfpermang / permanence)  set satisfpermanw (satisfpermanw / permanence)             set ind-indiv ind-indiv + 1]]  end  to bpreference-evolution                                                 ; ================== For Individuals ==============             ;;;;;;; If there we want preferences evolution according with level of historical satisfaction                                  ;;;;;;;;;;;;;;;For GOODS and WORK             bpermanence            let logcoef (-0.50) set ind-indiv 0 while [ind-indiv <= Individuals_N - 1] [ask turtle (ind-indiv) [set x-work 0              while [x-work < length mylist1][                                 set mylist1 replace-item x-work mylist1 ((item x-work mylist1) * (299.5 + (1 / (1 + exp (- ((logcoef + satisfpermang) * 12 ))))) / 300)                                   set mylist2 replace-item x-work mylist2 (item x-work mylist2 * (299.5 + (1 / (1 + exp (- ((logcoef + satisfpermang) * 12 ))))) / 300)                                  set work_r-list replace-item x-work work_r-list (item x-work work_r-list  * (299.5 + (1 / (1 + exp (- ((logcoef + satisfpermanw) * 12 ))))) / 300)                                  set x-work x-work + 1]] set ind-indiv ind-indiv + 1                                 ]; close ask turtle (ind-indiv)        end   ;----------------------------------------------------- This puts values in the lists of Total Domand and Total Offer ------------------------------------------------                                            To d-sum-mylists ; observer procedure                ;;;; Sum individuals lists (Good and Work)        Set sumT-H []        Set index 0            repeat 2            [ ; add to the end of sumT-H the sum of items 0 1 of all H            set sumT-H lput (precision sum values-from individual [item (index) H] 2) sumT-H            set index index + 1            ]        Set sum-list1 []        Set index 0            repeat mlt            [ ; add to the end of sum-list the sum of all items at index "index" all cat my-lists            set sum-list1 lput (precision sum values-from individual [item (index) mylist1] 2) sum-list1            set index index + 1             ]                     Set sum-list2 []        Set index 0            repeat mlt            [ ; add to the end of sum-list the sum of all items at index "index" all my-lists            set sum-list2 lput (precision sum values-from individual [item (index) mylist2a] 2) sum-list2            set index index + 1            ]                    Set sum-listw []        Set index 0            repeat mlt            [ ; add to the end of sum-list the sum of all items at index "index" all my-lists            set sum-listw lput (precision sum values-from individual [item (index) work_r-lista] 2) sum-listw            set index index + 1            ]                     ask Agg_individual [            set Ag-H replace-item 0 Ag-H (max values-from individual [item 0 H]);; the Walrasian condition for the Aggregate - individual            set Ag-H replace-item 1 Ag-H (max values-from individual [item 1 H])  ;; the Walrasian condition for the Aggregate - individual                          ]                                          ;;;; Sum firms lists (Good and Work)        Set index 0 Set sumT-F []            repeat 2            [ ; add to the end of sumT-F the sum of all items O 1 of F            set sumT-F lput (precision sum values-from firm [item (index) F] 2) sumT-F            set index index + 1            ]        Set index 0 Set sum-list3 []            repeat mltf            [ ; add to the end of sum-list the sum of all items at index "index" all my-lists            set sum-list3 lput (precision sum values-from firm [item (index) mylist3a] 2) sum-list3            set index index + 1            ]                   Set index 0 Set sum-list4 []            repeat mltf            [ ; add to the end of sum-list the sum of all items at index "index" all  my-lists            set sum-list4 lput (precision sum values-from firm [item (index) mylist4a] 2) sum-list4            set index index + 1            ]                    Set index 0 Set sum-listwf []            repeat mltf           [ ; add to the end of sum-list the sum of all items at index "index" all my-lists            set sum-listwf lput (precision sum values-from firm [item (index) work_r1-lista] 2) sum-listwf            set index index + 1            ]                end                                                 ;-----------------------------------------------------Riempie coi valori le liste di domanda e offerta totali ------------------------------------------------                                                                                                     to e-bbbb               f-move-random                g-move1               if (Perf-Inf = false) [i-satisfaction l-communicate               ]               m-color-turtles             p1-prepare-aggregate-plot           ifelse (Individuals_N = 1) [o1-prepare-plot-1] [o1-prepare-plot-1 o2-prepare-plot-2]           q-firm-global-demand            wait .2     end     to i-satisfaction        if (time >= 1) [ ; the procedure is not walid for the first run - "item 1 H" and "item 0 H" are respectively the work and good walrassian points for individuals           ask individual [ifelse (item 0 H > 0) [set satisfggg ((item 0 H - (item 0 H - Iggg))/ item 0 H) ; Individual evaluate the % of satisfaction ONLY about good with respect to her optimal point - simplest hypothesis.                           set satisfwww ((item 1 H - (item 1 H - Iwww))/ item 1 H)][set satisfggg 0 set satisfwww 0]                           i-timesatisf                            ]]                          ; Individual evaluate the % of satisfaction ONLY about work with respect to her optimal point - simplest hypothesis.     end     to i-timesatisf                             ifelse (time > 21)                                        ; build the 20 timesatisfggg, timesatifwww timegood & timework for each individual                            [set timesatisfggg but-first timesatisfggg set timesatisfwww but-first timesatisfwww                             set timegood but-first timegood set timework but-first timework                                 set timesatisfggg lput satisfggg timesatisfggg set timesatisfwww lput satisfwww timesatisfwww                                 set timegood lput Iggg timegood set timework lput Iwww timework]                            [set timesatisfggg lput satisfggg timesatisfggg set timesatisfwww lput satisfwww timesatisfwww                            set timegood lput Iggg timegood set timework lput Iwww timework]     end          to a3-setup-form-individual-price-image       set index 0 ask individual [set list_in_aaI [] set Ind_price_image [] ]        repeat Individuals_N [        set tickbf 0             ask turtle index [                repeat Firms_N [                    set list_in_aaI lput (value-from turtle (Individuals_N  + tickbf)[price]) list_in_aaI       ; list_in_aaI is the real price met by each individual                    set Ind_price_image lput ((item (tickbf) list_in_aaI) * (item (tickbf) list_in_bbI)) Ind_price_image            ;            type " index: " type index type " tickbf: " type tickbf type " Ind_price_image: " print Ind_price_image                    set tickbf tickbf + 1    ; Ind_price_image is the price image each individual has for each firms she meet.                                    ]  ; the individual has a price-image of the real price of the firm as consequence of received information about quality ad complimentary services.                                               ]         set index index + 1                         ]          set crowd [] repeat Firms_N [set crowd lput 0 crowd] ; set the initial crowd = 1 (the same individual) for all the firms                    end                to h-choosing_the_firm               set index 0 ask individual [set list_in_aaI [] set Ind_price_image [] ]        repeat Individuals_N [        set tickbf 0             ask turtle index [                repeat Firms_N [                    set list_in_aaI lput (value-from turtle (Individuals_N  + tickbf)[price]) list_in_aaI            ; list_in_aaI is the real price met by each individual                    set Ind_price_image lput ((item (tickbf) list_in_aaI) * (item (tickbf) list_in_bbI)) Ind_price_image set tickbf tickbf + 1    ; Ind_price_image is the price immage each individual has for each firms she meet.                                    ]  ; the individual has a price-immage of the real price of the firm as consequence of her information.                             ]         set index index + 1                           ]                     ;;; ---------------------- each individual chooses the best firm for him. She takes into account his firm's price image and the level of crowd of the firm ------------------------------        ask individual [set Ind_price_image_temp []]        ask firm [set individual-choose [] ]                  ;; "individual-choose []" take the ID of individual that have choosen the firm        set index 0 set inn 0 while [index < Individuals_N] [                 ; The price image of individual is corrected by the past crowd of each firm.        ask turtle index [while [inn < Firms_N] [                set Ind_price_image replace-item inn Ind_price_image ((item inn Ind_price_image * (1 - (Crowd/satisf_w / 100))) + ((((item inn crowd)) /(Individuals_N / Firms_N)) * (Crowd/satisf_w / 100))); to set the incidence of crowd and price_image                set inn (inn + 1) ]                ] set index index + 1]                ; Then we ask each individual in our word on the base of his price image.         ask individual [set Ind_price_image_temp [] set Ind_price_image_temp Ind_price_image]        let i 2 set index 0 while [index < Individuals_N] [set tickbf 0         ask turtle index [while [tickbf < Firms_N] [   ; for each firm we ask the individual if she chooses it.              if (item tickbf Ind_price_image_temp = min value-from turtle (index)[Ind_price_image_temp] ) [                       set choosen tickbf              ask turtle (Individuals_N + tickbf) [set individual-choose lput index individual-choose ; set for each firm a list of all the individuals that have chosen it              ]                 set tickbf Firms_N] set tickbf tickbf + 1 ]       ; this is the index of increment of the firms        ask individual [        set Ind_price_image_temp replace-item (position min Ind_price_image_temp Ind_price_image_temp) Ind_price_image_temp (min Ind_price_image_temp * i) set i i + 1         ] set i 2; QUESTA E LA PRECEDENTE      ]          set index index + 1 ]          set tickbf 0 while [tickbf < Firms_N] [set crowd replace-item tickbf crowd number-of-customers-of turtle (Individuals_N + tickbf) set tickbf tickbf + 1]        ask firm [set number-of-customers length individual-choose]         w-calculate-division-of-offre         i-modify-firms-to-check    end        to i-modify-firms-to-check        set to-check [] set index 0        while [(index < Firms_N)] [ask turtle (Individuals_N + index) [if (length individual-choose > 0)[set to-check lput (index) to-check] ] set index index + 1]        ifelse (length to-check = 1)  [set Firm1-to-check (item 0 to-check) + 1 set Firm2-to-check (item 0 to-check) + 1]              [set Firm1-to-check (item 0 to-check) + 1   set Firm2-to-check (item 1 to-check) + 1]     end

⌨️ 快捷键说明

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