我一直致力于基于Nelson-Winter模型模拟企业家的NetLogo模型。在模型中,每个滴答都有一个产品的需求和供应,然后价格=需求/供应,所以每个滴答企业家有机会建立公司和赚钱,设置公司的概率是有效的通过同一组中的企业家建立的其他公司的收入,同一组中的企业家共享相同的伽玛和lambda,伽玛决定投入研发的利润比例(创新和模仿),lambda决定比例R& D资金投入到创新中。 RD的成功将提高产量。最终它将返回由集团平均的公司的结果,同一组中的公司将具有相同的公司NO和相同的gamma和lambda。 这个过程似乎运行正常,但运行速度非常慢,我担心我无法进行多次模拟。有关如何加快这一过程的任何想法?在没有组的早期版本模型中,模型工作得非常快,所以我认为问题在于分组。模型代码变得很长,所以我只添加了与分组相关的部分。如果问题似乎在其他地方,我可以向某人提供更多代码。任何帮助将不胜感激!
globals[
S;;aggregate supply
SafterDie
D;;aggregate demand
P;;price of demand,P=D/S
g b eta;;used for get demand
file1
file2
totalGamma
totalLambda
NO
]
breed [entrepreneurs a-entrepreneur]
breed [companies a-company]
entrepreneurs-own[
humanCapital
timesOfChuangYe
chuangYe?;;chuang ye mei de
gaiLv
renGamma
renLambda
renNO
]
companies-own[
humanCapital
tempHumanCapital;;20140516
oldHumanCapital
initialCap
initialTech
companiesNO
capitalK;;capital K,nedd money c*K
gamma;;money uesd for R&D
lambda;;money used for innovation in terms of imitation
lifeLength
RecentRevenue;;profit every tick
production;;production of the tick
profit
accumulatedInnovation
accumulatedImitation
]
to setup
foreach n-values NoOfgroup [?] [
set bigGamma (random-in-range 0.4 1);;money uesd for innovation
set bigLambda (random-in-range 0.1 1);;money used for innovation VS imitation
set NO (? + 1)
create-entrepreneurs numberOfentreprenursInEveryGroup [ entrepreneur-setup ]
]
to entrepreneur-setup ;; turtle procedure
set color red
set shape "line";;line
move-to one-of patches
set humanCapital random-in-range 0 1
set chuangYe? 0;;if Entrepreneurship,0 no,1 yes
set timesOfChuangYe 0;;Entrepreneurship times
set renGamma bingGamma
set renLambda bingLambda
set renNO NO
end
to ifChuangYe
ask entrepreneurs with [chuangYe? = 0]
[
let node1 self
set gaiLv 0;;probability of entrepreneurship
getProbabilitiOfEntrepreueur node1
if (random-float 1 <= gaiLv)[
set chuangYe? 1
set timesOfChuangYe (timesOfChuangYe + 1)
hatch-companies 1 [
set color yellow
set shape "house"
create-link-with node1 [set color yellow]
set humanCapital ([humanCapital] of node1);;!!!
set companyNO ([renNO] of node1)
set gamma ([renGamma] of node1);;money uesd for RD
set lambda ([renLambda] of node1);;money used for innovation VS imitation
set initialTech humanCapital
set tempHumanCapital humanCapital
set oldHumanCapital humanCapital
company-setup
]
]
]
end
to getProbabilitiOfEntrepreueur [node1]
ask node1[
let number renNO
let co1 no-turtles
let en1 entrepreneurs with [renNO = number];;get entrepreneur
ask en1 [
set co1 link-neighbors;;get company
]
let total 0
ask co1 [;;to link
if lifeLength != 0 [
let k lifeLength
let singleRevenue 0
if lifeLength >= 6 [set k 6]
foreach n-values k [?] [
set singleRevenue (singleRevenue + (item ? RecentRevenue)/ (? + 1))
];;RecentRevenue is a list to collect a company's profit of every tick
set total total + singleRevenue
]
]
set gaiLv (1 / 50 * total + 5 / 100)
;;show gaiLv
]
end
to imitation
let newH 0
ask companies[
set accumulatedImitation (accumulatedImitation + (1 - lambda)* gamma * profit)
if accumulatedImitation >= 0.3 * (capitalK ^ 3) [
let co2 companies with [companyNO = companyNo]
set newH max ([humanCapital] of co2)
if newH > humanCapital [set humanCapital newH set imNO imNO + 1]
set accumulatedImitation (accumulatedImitation - 0.3 * (capitalK ^ 3))
]
]
端