一组补丁的平均值

时间:2014-05-27 20:45:59

标签: patch mean netlogo

对于下面发布的模型,我想知道如何获得变量的平均值"土地适用性"为每个农场。我想在界面中放置一个情节或监视器来显示土地适宜性的平均值。我已经尝试过在记者中使用具有此功能的显示器 - 这意味着海龟的适应性 - 但我得到的只是海龟适合的地方,而不是所有的农场......我怎样才能为此目的撰写报告?

  turtles-own  [
     profit-from-fuel
     profit-from-food
     expected-fuel-sell-price
     expected-food-sell-price
     profit
     farm
     farm-size
      ]

patches-own  [
  fuel-yeld
 `enter code here`food-yeld

  land-sustainability
  water-level
  belongs-to
  food
  fuel

 ]

globals      [
  fuel-sell-price
  food-sell-price
  governs        
   ]


to setup        
 clear-all
 clear-all-plots
 create-farmers
 setup-land
 reset-ticks

  ask turtles
     [     set-farm-in-radius farm-size   ]

set fuel-sell-price 184 + random 55 + random -55 
set food-sell-price 184 + random 55 + random -55 

end


to create-farmers


create-turtles 30

[
 set shape "person farmer"
 setxy random-pxcor random-pycor 
 set profit-from-fuel  0  ; indicizzazione del profitto iniziale a 0
 set profit-from-food 0  ; indicizzazione del profitto iniziale a 0 

 set farm-size random 5 + 1
 set label farm-size
 ]
 end


 to setup-land

 ask patches [set belongs-to nobody]

 ask  patches
  [

   set pcolor 3
   set food-yeld 13000 
   set fuel-yeld 13000
   set land-sustainability random-float 0.9 + 0.1 ; per creare un moltiplicatore che     vada da 0.1  a 1
   set water-level random 3 * 1000
   if water-level = 0 [set water-level 1000]
    ]

  end


to set-farm-in-radius [d]
 move-to one-of patches with [not any? other patches in-radius d with [belongs-to !=     nobody]]
 set farm patches in-radius farm-size
 ask farm [set belongs-to myself]
 let c random 6 + 61
 ask farm [set pcolor c]
 end


to set-farm-distance [d]
  move-to one-of patches with [not any? other patches with [belongs-to != nobody and   distance myself < d]]
  set farm patches with [distance myself < d] 
  ask farm [set belongs-to myself]
  let c random 6 + 61
  ask farm [set pcolor c]
end



to go



ask turtles [

  set expected-fuel-sell-price fuel-sell-price + random 5 + random -5           
  if expected-fuel-sell-price < 0 [set expected-fuel-sell-price 1]
  set expected-food-sell-price food-sell-price  + random 5 + random -5
  if expected-food-sell-price < 0 [set expected-food-sell-price 1]
  set profit profit-from-fuel + profit-from-food
  if profit = 0 [ set profit 1 ]
  ]

 ask turtles [ 

  cultivate
   ask farm [recolor-farm]
      set profit profit-from-food + profit-from-fuel
    ]



  set fuel-sell-price fuel-sell-price + random 55 + random -55 
  if fuel-sell-price < 126 [set fuel-sell-price 126 ]
  if fuel-sell-price > 245 [set fuel-sell-price 245]                  ; è corretta come   assunzione? su un arco di 30 anni è ragionevole suppore che il limite massimo del prezzo    
  set food-sell-price food-sell-price + random 55 + random -55        ; sia di soli 5  euro più alto rispetto al massimo delgi ultimi 10 anni
  if food-sell-price < 126   [set food-sell-price 126]  
  if food-sell-price > 245 [set food-sell-price 245]

 if ticks =  Duration [ stop ] 
 if ticks > Duration [stop]

 ask patches 
 [ set food 0
   set fuel 0
   if land-sustainability  < 0.1 [set land-sustainability 0.1]        ; all'interno del  modello la land susitability varia in base alle colture utilizzate
   if land-sustainability > 1 [set land-sustainability 1 ]            ; ma questa non può comunque essere inferiore a 0.1 o maggiore di 1  
   ]

 tick

end

to cultivate
  let r risk-attitude 
  let e-f expected-fuel-sell-price
  let e-food expected-food-sell-price

  ask farm [
    ifelse land-sustainability < 0.35 or water-level < 1100           ; 0.35 è un valore arbitrario che può essere modificato vedere i documenti FAO
    [ ask myself [set profit-from-food sum  [food-sell-price * (((food-yeld  ) ^ (alfa)) * (((water-level) ^ (1 - gamma)) * ((land-sustainability) ^ (gamma))))] of farm 
      ]
    set food 2
    set fuel 0 
    set land-sustainability land-sustainability + 0.1   ; la scelta di coltivare prodotti destinati alla produzione di cibo incrementa il livello l-s del terreno così coltivato
    set pcolor 52.5
     ]

    [

     if land-sustainability >= 0.35 or water-level  = 0
     [

    let utility-from-food e-food * ((food-yeld  ) ^ (alfa)) * ((water-level) ^ (gamma)) * ((land-sustainability) ^ (beta))    ; da riscrivere la nuova formula con l'utilità di 
    let utility-from-fuel e-f *(( fuel-yeld) ^ (alfa)  * ((water-level) ^ (1 - gamma)  * (land-sustainability) ^ (gamma) ))


    ifelse utility-from-food < utility-from-fuel
    [
      ask myself [set profit-from-fuel sum [fuel-sell-price * (((fuel-yeld ) ^ (alfa)) * (((water-level) ^ (1 - gamma)) * ((land-sustainability) ^ (gamma))))] of farm ] ; ricominciare da qui cobb-douglas
      set fuel 1 
      set food 0
      set land-sustainability land-sustainability  - 1
    ]
    [ ask myself [set profit-from-food sum [food-sell-price * (((food-yeld ) ^ (alfa)) * (((water-level) ^ (1 - gamma)) * ((land-sustainability) ^ (gamma))))] of farm ]
      set food 1
      set fuel 0
      set land-sustainability land-sustainability + 0.5

    ]

  ]
]


  ]
  end

to recolor-farm
      if (food = 1 and fuel = 0 ) [set pcolor green ]
      if (fuel = 1 and food = 0 )[set pcolor yellow]
      if (fuel = 1 and food = 1) [set pcolor pink]       ; check
      if (fuel = 0 and food = 0) [set pcolor blue]       ; check
end

2 个答案:

答案 0 :(得分:1)

mean [land-sustainability] of farm将为特定的农民(乌龟)提供给你。我相信mean [ land-sustainability of patches with [ belongs-to != nobody ]会为你提供所有农场补丁。

答案 1 :(得分:1)

你的每只海龟都有一个farm变量,其中包含构成这只海龟养殖场的一组补丁。你想要 海龟的 的平均土地可持续性

[ mean [ land-sustainability ] of farm ] of turtles