0

My turtles are firms and they have a turtles-own which is firm-level-of-automation. At setup, this parameter is a random value between 0 and 1.

At go, it proportionally rises with the R&D-investment. It should rise up until 0.99, as full automation at 99% is reached. This is why I added a condition saying that IFELSE automation on the firm level is below 1 AND still below 1 in case R&D investment would happen SET rise proportionally with the r&d-investment. otherwise SET to the level of the previous round, because firms should stop investing then AND set r&d-investment to zero.

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

The code I have so far does not make the firm-level-of-automation jump to 0.99. Too, it would be nicer to know the last R&D investment to fill the gap.

user11277648
  • 53
  • 1
  • 5

1 Answers1

1

The main problem is, that you did not initialized a value for income, while your Ifelse is ok. If you don“t do this, there is no value for r&d-investment, which can be added to firm-level-of-automation by the Ifelse statement. Please check the revised code below. Lines added are commented.

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

Does this work for you?

geruter
  • 386
  • 1
  • 6