Class FunctionalScheduler

java.lang.Object
modelarium.scheduler.functional.FunctionalScheduler
All Implemented Interfaces:
Scheduler

public class FunctionalScheduler extends Object implements Scheduler
Class for scheduling agents using a user-defined function to run each simulation tick.

This class allows flexible tick behaviour without requiring subclassing or direct implementation of the Scheduler interface. The user provides a TickFunction that defines what should happen during a single simulation tick for a given set of agents.

Typical use cases include passing a lambda expression or method reference to customise the tick logic externally, for example from another Java module or from Python via JPype with a proxy.

  • Constructor Details

    • FunctionalScheduler

      public FunctionalScheduler(TickFunction tickFunction)
      Constructs a new functional scheduler with the specified tick function.
      Parameters:
      tickFunction - the logic to execute on each tick
  • Method Details

    • runTick

      public void runTick(String threadName, ReadOnlyClock clock, ReadOnlyEnvironment environment, AgentSet agentSet, RandomGenerator random)
      Executes a single simulation tick by delegating to the user-provided function.
      Specified by:
      runTick in interface Scheduler
      Parameters:
      threadName - the name of the worker thread running the tick
      clock - the model's clock, giving the current tick
      environment - a read-only view of the worker's environment
      agentSet - the set of agents to act upon during this tick
      random - the random generator the tick logic can use