Class FunctionalScheduler

java.lang.Object
modelarium.scheduler.FunctionalScheduler
All Implemented Interfaces:
ModelScheduler

public class FunctionalScheduler extends Object implements ModelScheduler
A scheduler implementation that delegates each simulation tick to a user-defined function.

This allows flexible tick behaviour without requiring subclassing or direct implementation of the ModelScheduler interface. The user provides a Consumer 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(Consumer<AgentSet> tickFunction)
      Constructs a FunctionalScheduler with the specified tick function.
      Parameters:
      tickFunction - the logic to execute on each tick, defined as a Consumer of AgentSet
  • Method Details

    • runTick

      public void runTick(AgentSet agentSet)
      Executes a single simulation tick by delegating to the user-provided function.
      Specified by:
      runTick in interface ModelScheduler
      Parameters:
      agentSet - the set of agents to act upon during this tick