mardi 16 avril 2019

How to command IFELSE condition in combination with AND and a maximum value to be reached?

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.




Aucun commentaire:

Enregistrer un commentaire