Search code examples
schedulerrepast-simphony

Repast Simphony scheduling method priority


I have a model with about 10 scheduled methods. Now I am a little bit confused on controlling their execution. I want these scheduled methods to be executed in a certain order.

How can I have ScheduleParameters.FIRST_PRIORITY, ScheduleParameters.Second_PRIORITY, ScheduleParameters.THIRD_PRIORITY, ..., and ScheduleParameters.LAST_PRIORITY.


Solution

  • The various ScheduleParameters.createX methods all take a double value that specifies priority. For example, if you have

    ScheduleParameters sp1 = ScheduleParameters.createRepeating(1, 1, 0); ScheduleParameters sp2 = ScheduleParameters.createRepeating(1, 1, 10);

    the priorities are 0 for sp1 and 10 for sp2. Actions scheduled with sp1 and sp2 will occur at tick 1 and then every tick thereafter. But sp2 actions will occur before the sp1 actions scheduled at the same tick.

    There are also two special priority values ScheduleParameters.FIRST_PRIORITY and ScheduleParameters.LAST_PRIORITY that can be used to make sure an action executes before or after any other action schedule for the same tick.

    See https://repast.github.io/docs/api/repast_simphony/repast/simphony/engine/schedule/ScheduleParameters.html for more info.