4

I have agents called 'orders' Within these agents there is a number of devices as an attribute. Depending on the age of each of the devices, a certain number of devices will break in accordance with a random-poisson process. For example:

Orders have attributes:

  • Number of installed devices (amount-installed)
  • Number of broken devices (amount-broken)
  • Number of devices broken this timestep (broken-this-year)
  • Age of the devices in this order (order-age)
  • Average lifespan of the order (average-lifespan)

I have found a few ways on how to implement this using a filter in a list approach:

ask orders [
    let broken-list n-values amount-installed [random-poisson order-age]
    set broken-list filter [s -> s >= average-lifespan] broken-list
    set broken-this-year length broken-list
    set amount-installed amount-installed - broken-this-year
    set amount-broken amount-broken + broken-this-year
]

Another way I have found to implement this is using a while-loop approach:

 ask orders [
    while [amount-checked < amount-installed] [
      if random-poisson order-age >= average-lifespan [
        set broken-this-year broken-this-year + 1
      ]
      set amount-checked amount-checked + 1
    ]
    set amount-installed amount-installed - broken-this-year
    set amount-broken amount-broken + broken-this-year
]

There should therefore be a number of the installed devices that break, while a number of devices still remain working. However, each order consists of several thousands of devices, and there are hundreds of orders in my model. This process therefore takes an extremely long time to the point that the computer freezes. There must be a way to attain the same results without using a loop method. Does anyone know a better way to approach this?

DvB09
  • 41
  • 2
  • Am I correct in thinking that the devices are all identical, at least within one order? That is, you only need to count the devices within an order and keep track of the number running and broken, they don't have different characteristics such as age. If so, I believe you can use a poisson distribution to return the number of new broken as a single operation for each order. This means the number of devices per order has no effect on performance. – JenB Jan 03 '19 at 10:51

0 Answers0