2017-07-31 72 views
0

在我的模型中,我在整個環境中生產食物。我知道總共應該有多少食物,而且我按照特定的分佈包裝它,在這種情況下是Gamma。如何根據具體分佈限制我的模型中產生的食物量

大部分食物在一天結束時衰減,於是我想再次開始第二天的過程。 (我確實有一些食物代理需要更長的時間來衰減,但這不應該影響我在這裏尋找的東西)。

我想是這樣的,但之後不能完全得到它:

if ticks = 0 [while [sum [mass] of foods < 100000] [ 
create-foods n-foods [ ;; this could be arbitrarily high to allow the model to keep making food up to the limit of the mass 
set mass random-gamma 1.2 0.002 
]]] 

爲了完整,後來我問食品代理商遞增衰減計數器,我用它來告訴他們是否不在一天結束的時候死:

ask foods with [decay = 2] [die] 

希望你能幫助

+1

你的代碼對我來說看起來很好。你有什麼問題嗎?你怎麼知道它不起作用? –

+0

總的食物質量總是超過我爲mas設置的限制(100000) –

+0

我不認爲問題出現在您向我們顯示的代碼中。 –

回答

1

我發現,通過使用補丁萌芽的食品對我工作的解決方案。

ask patches [ 
    while [sum [mass] of foods < random-normal 6000 100] [ 
sprout-foods 1 [ 
set mass random-gamma 1.2 0.004 
setxy random-pxcor random-pycor 
]] 
相關問題