aaa---micro-macro_evolve_salzano.nlogo

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

NLOGO
951
字号
;Model procedures    globals [x-work RNS RNSF             in instruction group_N             Agg.-Reg Regime-1 Regime-2 rr inrr              sum-list1 sum-list2 sum-listw sum-listg sum-list3 sum-list4 sum-listwf sum-listgf sumT-F sumT-H             offer_d                 xf yf exwa0 exwa1 exw1a0 exw1a1              exch www Twww Tggg              tp-list td-list t-o-list tw-list two-list tp1-list             tpI tdI t-oI tpI1 twI twoI tpII tdII t-oII tpII1 twII twoII             Atp Atd At-o Atg Atdf Atwo Atp1 Atgf              tickbf tickbf2 flag2 index              inaaa inbbb                                                                     ; temporary index for "1-comunicate" procedure - It is possible to modify them             mlpf mltf mlp mlt             itc1 itc2             flag             f1tc f2tc             lwl time             mylist1-length mylist2-length work_r-list-length good_r-list-length num             TtdI Tt-oI TtdII Tt-oII Tt-rwI Tt-rgI Tt-rwII Tt-rgII                           ; Values for "Plot procedure "             Information-shock             to-check             Firm2-to-check             T-exc T-Exc-W F1-Exc F1-Exc-W F2-Exc F2-Exc-W F3-Exc                            ; Values for "Plot Pen procedure "             F3-Exc-W F4-Exc F4-Exc-W F5-Exc F5-Exc-W                                        ; Values for "Plot Pen procedure "             indexf                                                                          ; counter of individuals for friends calculation             ind-indiv                                                                       ; counter of individuals for .... calculation             GF GH                                                                           ; counter of Individual for the "CALCULATION OF THE DIFFERENT REGIMES OF RATIONING AND EXCHANGE";             Glist1 Glist2 Glist3 Glist4 Glistw Glistw1 FlagR FlagR1 inR inn in2             ; temporary-global variables taking time by time the values for calculating the market regime, exchange and relative plots.             inex                                                                            ; counter of Firms             IXI IXF                                                                         ; string and values for building "individual" and "firm" demand and offer             Repr-Agents Perfect-Information             crowd              indrnd                                                                          ; temporary for building friends-list              group                                                                           ; the index of groups of individual             worklist             inperm                                                                          ; level of permanence             ]             ;;;;;;;;; Other used variables - they are used in controls Interface             ; Ag-off_coef              ; Ag-work_coef_s             ; Ag-interc_off             ; Ag-interc_off_w     breed [ individual ]breed [ firm ]breed [ Agg_individual ]breed [ Agg_firm ]breed [ friends_group ]    turtles-own [is-individual? is-firm?]     individual-own [                     mylist1 mylist2 work_r-list good_r-list                                  ; Initial values od individual demand and offer for goods and work                    mylist1a mylist2a work_r-lista good_r-lista                              ; a temporary variable that consider the fact the demand and offer did not reduce with less rationing                    i-mylist3 i-mylist4 i-work_r1-list i-good_r1-list i-F                    ; "i-mylist3" the offer by the firm choosen meet by each individual and similarly for other variables - i-F                     i-mylist3a i-mylist4a                     H                                                                        ; The list of two coordinates for the Warrasian point for individual                    work_r good_r                                                            ; The independent variables for individuals - good_r = work_r step 0.1                    list_in_aaI list_in_bbI Ind_price_image Ind_price_image_temp             ; the individual real price requested by firm; his information modifier; the individual price immage of price asked by each firms                    choosen gotox gotoy                                                      ; the firm choosen by each individual and the spatial localization of this firm.                    exa0 exa1 exb0 exb1 exc0 exc1 exd0 exd1 Iwww Iggg                    IReg InReg                                                               ; Economic regimes of individual - Controllare 15 righe rosso con Aggregated Individual Controllare anche Iwww e Iggg                    satisfwww satisfggg oth-turtle friends-list satisfggg_oth-turtle         ; level of satisfation about work ; level of satisfation about goods; other turtle????; List of friends of an individual (It could be not symmetric)                    RND                                                                      ; a random value for each individual                    RN                                                                       ; tempory for randon RND construction                    timesatisfggg timesatisfwww                                              ; 20 time the levels of satisfaction of each individual                    timegood timework                                                        ; 20 time the levels of good and work of each individual                    satisfpermang satisfpermanw                    ]    firm-own        [offer_s work_s                     interc_w_s interc_off interc_off_w                                       ; Coefficients for good and work preference functions of each firm                    mylist3 mylist4 work_r1-list good_r1-list                                ; The offer of goods - ....... - the demand of work force - .......                    mylist3a mylist4a work_r1-lista                     F                                                                        ; The list of two coordinates for the Walrasian condition for Firms                    work_r1 good_r1                                                          ; The independent variables for firms - good_r1 = work_r1 step 0.1                    sum-mylist1 sum-mylist2 sum-work_r-list sum-good_r-list sum-H                    individual-choose total-firm-good-dem total-firm-work-off                     total-firm-raz-w total-firm-raz-g                    number-of-customers                    T_H                                                                      ; Max value from firm                        Mwww Mggg                    MReg                    price                    RND                    RN                                                                       ; tempory for randon RND construction                    ]    Agg_individual-own [Ag-demand_p Ag-work_p                     Net-Ag-interc_dem Net-Ag-interc_w                    Ag-quantity_d                    Ag-mylist1 Ag-mylist2 Ag-work_r-list Ag-good_r-list                    Ag-H                                                                     ; The list of two coordinates for the Walrasian condition for Aggregate Individual                    Ag-work_r Ag-good_r                                                      ; Figurative x axes for aggregated work and aggregated good - Necessary for calculation of "pseudo inverse" function                    ml                    exa0 exa1 exb0 exb1 exc0 exc1 exd0 exd1 Iwww Iggg                    IReg InReg                                                               ; Economic regimes of Aggregated individual                    timeTggg timeTwww]    Agg_firm-own    [Ag-offer_s Ag-work_o                                                    ; The temporary variables holding the level of demand and offer of goods and work for each level of axis or independent variable (they are not list)                    Ag-interc_w_s                       Net-Ag-interc_off Net-Ag-interc_off_w  Ag-work_s                     Ag-offer_d                     Ag-mylist3 Ag-mylist4 Ag-work_r1-list Ag-good_r1-list                    Ag-F                                                                     ; The list of two coordinates for the Walrasian condition for Aggregate firm                    Ag-work_r1 Ag-good_r1                    Total-good Total-Work                    Av_price                    ]   friends_group-own [group_of_friends]                       ;;;;--------------------------- a1setup ---------------------------------------------------------------------------------------    to a1setup         ca         clear-output         a1-setup-instruction             set instruction "If you are happy with the run's parameters - Click on Go - Otherwise modify the run's parameters."                ;;;; ---------------- Set the cases of Representative Agents or Not, Perfect Information or Not, and the level of Public Expenditure ---------------------         ifelse Repr-Ag = true [set Repr-Agents "Yes"] [set Repr-Agents "No"]  ifelse Perf-Inf = true [set Perfect-Information "Yes"] [set Perfect-Information "No"]                    ;;;;  --------------------------------  Create Individual, Firms, Aggregated Individual and Firms  -------------------------------------------------------         create-individual Individuals_N              ask individual [set size 2  fd 3 set shape "person" set mylist1 [] set mylist2 [] set work_r-list [] set good_r-list [] set H [0 0]                   set list_in_aaI [] set list_in_bbI [] set Ind_price_image [] set timesatisfggg [] set timesatisfwww [] set timegood [] set timework []]         create-firm Firms_N              ask firm [set size 3 fd 10 set shape "shop-shape" set mylist3 [] set mylist4 [] set work_r1-list [] set good_r1-list [] set F [0 0] set T_H [0 0] set price 10]         create-Agg_individual 1             ask Agg_individual [set Net-Ag-interc_dem (Ag-interc_dem - HeadTax) set Net-Ag-interc_w (Ag-interc_w - HeadTax) ; Of course, here it is possible to introduce a total amount tax on individuals                  set Ag-mylist1 [] set Ag-mylist2 [] set Ag-work_r-list [] set Ag-good_r-list [] set Ag-H [0 0]]         create-Agg_firm 1               ask Agg_firm [ set Net-Ag-interc_off (Ag-interc_off - PublicExpenditure)                              set Net-Ag-interc_off_w (Ag-interc_off_w - PublicExpenditure); The effect of Public Expenditure                   set Av_price 10; It is possible to consider different prices                  set Ag-mylist3 [] set Ag-mylist4 [] set Ag-work_r1-list [] set Ag-good_r1-list [] set Ag-F [0 0] ]                                  set GF [] set GH [] set GF [0 0] Set GH [0 0]                  if (hmanyfrom_gr >= Individuals_N - 1)[set hmanyfrom_gr Individuals_N - 1]                                    if(Individuals_N > 1 and hmanyfrom_gr > 0)[ ; check if it is possible to have friends                   if (hmanyfrom_gr >= Individuals_N - 1)[set hmanyfrom_gr Individuals_N - 1]                                    ifelse ((Individuals_N / hmanyfrom_gr)- int (Individuals_N / hmanyfrom_gr) = 0 )                  [set group_N int (Individuals_N / hmanyfrom_gr)] [set group_N int (Individuals_N / hmanyfrom_gr) + 1]                  create-friends_group group_N          a2-setup-build-friends-list ]     ;;;;;;;;;;;;;;;; Build a random value for each Agent - This is usefull for the following calculations and is based on the level of "randomnity of preferences"                          set RNS 0 set IXI 0 while [IXI < (Individuals_N - 1)]                    [ask turtle (IXI) [set RND precision ((1 / Individuals_N) - (((Individuals_N - 1)/ 1000 / 2) - ((random-float Individuals_N) / 1000))) 4 set RNS RNS + RND set IXI IXI + 1 ]]                   ask turtle (IXI) [set RND precision (1 - RNS) 4 ]                   set IXF Individuals_N while [IXF < (Individuals_N + Firms_N - 1)]                    [ask turtle (IXF) [set RND precision ((1 / Firms_N) - (((Firms_N - 1)/ 1000 / 2) - ((random-float Firms_N)  / 1000))) 4  set RNSF RNSF + RND set IXF IXF + 1 ]]                   ask turtle (IXF) [set RND precision (1 - RNSF) 4 ]      ;;;;;;;;;;;;;;;; Build the Initial Demand and Offer for Individual ;; and Firms                   ask Agg_individual [set x-work 0 if (x-work = 0)                     [set Ag-demand_p Net-Ag-interc_dem + Ag-dem_coef * 4 * x-work - (x-work * .53) ^ (68 / 50)                     set Ag-mylist1 lput Ag-demand_p Ag-mylist1                     set Ag-work_p Net-Ag-interc_w + Ag-work_coef_p * x-work + (x-work * 1) ^ (61 / 50)                     set Ag-mylist2 lput Ag-work_p Ag-mylist2                      set Ag-work_r-list lput x-work Ag-work_r-list                     set x-work x-work + 1]                 while [item (x-work - 1) Ag-mylist2 < item (x-work - 1) Ag-mylist1]                     [set Ag-demand_p Net-Ag-interc_dem + Ag-dem_coef * 4 * x-work - (x-work * .53) ^ (68 / 50)                     set Ag-mylist1 lput Ag-demand_p Ag-mylist1                     set Ag-work_p Net-Ag-interc_w + Ag-work_coef_p * x-work + (x-work * 1) ^ (61 / 50)                     set Ag-mylist2 lput Ag-work_p Ag-mylist2                      set Ag-work_r-list lput x-work Ag-work_r-list                     set x-work x-work + 1]                     ]               ask Agg_firm [set x-work 0 if (x-work = 0)                    [set Ag-offer_s Net-Ag-interc_off + Ag-off_coef * 4 * x-work - (x-work * .23) ^ 2                      set Ag-mylist3 lput Ag-offer_s Ag-mylist3                     set Ag-work_s Net-Ag-interc_off_w + Ag-work_coef_s * 5 * x-work - (x-work * .13) ^ (77 / 50)                     set Ag-mylist4 lput Ag-work_s Ag-mylist4                       set Ag-work_r1-list lput x-work Ag-work_r1-list                     set x-work x-work + 1]                 while [item (x-work - 1) Ag-mylist4 < item (x-work - 1) Ag-mylist3]                    [set Ag-offer_s Net-Ag-interc_off + Ag-off_coef * 4 * x-work - (x-work * .23) ^ 2                      set Ag-mylist3 lput Ag-offer_s Ag-mylist3                     set Ag-work_s Net-Ag-interc_off_w + Ag-work_coef_s * 5 * x-work - (x-work * .13) ^ (77 / 50)                     set Ag-mylist4 lput Ag-work_s Ag-mylist4                       set Ag-work_r1-list lput x-work Ag-work_r1-list                     set x-work x-work + 1]                     p1-prepare-aggregate-plot                      ] 

⌨️ 快捷键说明

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