colinsheppard / time

A NetLogo extension that brings date/time utilities and discrete event scheduling to NetLogo
12 stars 13 forks source link

task:go-shuffled for randomized order of executing tasks at a given time tick #46

Closed MHX792 closed 7 years ago

MHX792 commented 8 years ago

Let's assume I have two agentsets A and B. A should execute a task at ticks = 0 and B at ticks = 3. As I found out by trying the order of adding the agentsets to the schedule list is critical and there is no option to shuffle the list after adding both agentsets.

to setup-schedule
  time:schedule-event-shuffled agentsetA (task go) 0
  time:schedule-event-shuffled agentsetB (task go) 3
end

When the simulation starts I want to add individual turtles to the schedule list for a certain tick. Since adding them and shuffling the schedule list is not possible they get executed in the order they've been added to the schedule list.

task:go-shuffled or alternativeley making task:schedule-event-shuffled work for individual turtles would solve this problem (see https://github.com/colinsheppard/time/issues/45).

colinsheppard commented 8 years ago

I'm marking this issue as an enhancement. Unfortunately, the way I store events in the schedule is by using a java.util.TreeSet, which allows me to maintain a sorted list optimized to quickly dispatch a schedule of events without randomization. Implementing the requested feature would require non-trivial reorganization of how I manage events and would likely sacrifice performance under default (non-randomizing) conditions.

In other words, I will spend some time thinking on this, but at this point I don't see a clear path toward implementation that would allow me to maintain the current level of performance which I consider a higher priority.

In the meantime, you could achieve your intended effect using NetLogo by doing the following:

I realize this may be less than ideal, but I would recommend pursuing such a path in the near term as my time is limited in the present and I won't likely be able to build the requested enhancement until this summer at the earliest.

Best.