Random 如何结合和命令IFELSE条件,以达到最大值?

Random 如何结合和命令IFELSE条件,以达到最大值?,random,netlogo,agent-based-modeling,economics,Random,Netlogo,Agent Based Modeling,Economics,我的海龟是公司,他们有海龟自己的,这是公司的自动化水平。在设置时,此参数是介于0和1之间的随机值 在go,它随着研发投资成比例地上升。它应该上升到0.99,因为达到99%的完全自动化。这就是为什么我加了一个条件说 IFELSE公司层面的自动化程度低于1 如果进行研发投资,仍低于1 设定与研发投资成比例的增长。 否则设置为上一轮的水平,因为企业应该停止投资,并将研发投资设置为零 breed [ firms firm ] firms-own [ firm-level-of-automa

我的海龟是公司,他们有海龟自己的,这是公司的自动化水平。在设置时,此参数是介于0和1之间的随机值

在go,它随着研发投资成比例地上升。它应该上升到0.99,因为达到99%的完全自动化。这就是为什么我加了一个条件说 IFELSE公司层面的自动化程度低于1 如果进行研发投资,仍低于1 设定与研发投资成比例的增长。 否则设置为上一轮的水平,因为企业应该停止投资,并将研发投资设置为零

breed [ firms firm ]


firms-own [   
  firm-level-of-automation    ;; efficiency in automation on the firm level
  r&d-investment   ;; particular share of the total income which is used to invest in R&D
   income   ;; defined value
]

to setup
 ask firms [ 
    set firm-level-of-automation 0 + random-float 1 if firm-level-of-automation > 1 [ set firm-level-of-automation 1 ]   ;; initially random between >0 and <1
    set r&d-investment income * 0.04 ]   ;; R&D investment is a particular share of a firm's income
end

to go  
  tick   
  ask firms [
    ifelse ( firm-level-of-automation < 1 ) AND ( firm-level-of-automation + ( r&d-investment * 0.02 ) < 1 ) [   ;; IF automation on the firm level is below 1 AND still below 1 in case R&D investment would happen
      set firm-level-of-automation firm-level-of-automation + ( r&d-investment * 0.02 ) ]   ;; initially random between >0 and <1 but increases proportionally according to R&D investment
    [ set firm-level-of-automation 0.99 ]
end
品种[公司]
公司拥有[
公司层面的自动化;;公司层面的自动化效率
研发投资;用于研发投资的总收入中的特定份额
收入;固定价值
]
设置
询问公司[

如果公司自动化水平>1,则设置公司自动化水平0+随机浮动1[设置公司自动化水平1];最初在>0和之间是随机的。主要问题是,您没有初始化
收入的值,而您的
Ifelse
是正常的。如果您不这样做,
r&d-investment
就没有价值,可以通过
Ifelse
语句将其添加到
公司自动化水平e修改了下面的代码。添加的行已注释

breed [ firms firm ]


firms-own [   
  firm-level-of-automation    ;; efficiency in automation on the firm level
  r&d-investment   ;; particular share of the total income which is used to invest in R&D
   income   ;; defined value
]

to setup
  ca ;; ADDED

  create-firms 10 [set color red setxy random-xcor random-ycor set size 2] ;;ADDED, for illustration


 ask firms [ 
    set firm-level-of-automation 0 + random-float 1 if firm-level-of-automation > 1 [ set firm-level-of-automation 1 ]   ;; initially random between >0 and <1
    set income 100  ;; ADDED, needed to be initilaized, otherwise r&d-investment  would remain r&d-investment 0. The value 100 is choosen arbitrarily. 
    set r&d-investment income * 0.04  ;; R&D investment is a particular share of a firm's income

  ]   
  reset-ticks ;; ADDED, otherwise tick counter will not start
end

to go  

  ask firms [
    ifelse ( firm-level-of-automation < 1 ) AND ( firm-level-of-automation + ( r&d-investment * 0.02 ) < 1 ) [   ;; IF automation on the firm level is below 1 AND still below 1 in case R&D investment would happen
      set firm-level-of-automation firm-level-of-automation + ( r&d-investment * 0.02 ) ]   ;; initially random between >0 and <1 but increases proportionally according to R&D investment
    [ set firm-level-of-automation 0.99 ]
  ]

  tick ;; ADDED 
end
品种[公司]
公司拥有[
公司层面的自动化;;公司层面的自动化效率
研发投资;用于研发投资的总收入中的特定份额
收入;固定价值
]
设置
ca;;添加
创建公司10[设置颜色红色setxy random xcor random ycor set size 2];添加,用于说明
询问公司[
如果公司自动化水平>1,则将公司自动化水平设置为0+随机浮动1[设置公司自动化水平1];初始随机范围为>0到