0

I've set up firms (turtles) in an industry (world) which either produce at home (firms-at-home located > ycor) or have offshored their production (offshore-firms located < ycor). I have given them a firms-own called offshored? which is answered with either true or false. At setup, they also get a firms-own firm-level-of-automation which is random between 0 and 1.

Now, I would like to have 30 % of them with the lowest firm-level-of-automation to move production to < 0 ycor and report: offshored? = true

breed [ firms firm ]

firms-own [
 firm-level-of-automation   ;; initially random between 0 and 1
 offshored?   ;; true or false
]

to go
tick
ask firms [
 set firm-level-of-automation 0 + random-float 1

 if min [ firm-level-of-automation ] of firms [
   count firms * 0.3 firms [ setxy random-xcor random-between ( -10 ) -1   ;; distribute randomly abroad in an area < 0 ycor
   set offshored? true ] ] ]
end

I don't know how to mix the if and min command best here. Any suggestions?

user11277648
  • 53
  • 1
  • 5

1 Answers1

1

Not sure why you are being down voted for this, it seems like a sensible question. Anyway, there is no need to mix min and if, you can simply ask the 30% of turtles with the lower values to do what you want. Look up the min-n-of primitive in the dictionary, you will want something like:

ask min-n-of (0.3 * count firms) firms [firm-level-of-automation]
[ setxy random-xcor random-between ( -10 ) -1 
  set offshored? true
]
JenB
  • 17,620
  • 2
  • 17
  • 45