Package modelarium.scheduler.functional
Class FunctionalScheduler
java.lang.Object
modelarium.scheduler.functional.FunctionalScheduler
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionFunctionalScheduler(TickFunction tickFunction) Constructs a new functional scheduler with the specified tick function. -
Method Summary
Modifier and TypeMethodDescriptionvoidrunTick(String threadName, ReadOnlyClock clock, ReadOnlyEnvironment environment, AgentSet agentSet, RandomGenerator random) Executes a single simulation tick by delegating to the user-provided function.
-
Constructor Details
-
FunctionalScheduler
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:
runTickin interfaceScheduler- Parameters:
threadName- the name of the worker thread running the tickclock- the model's clock, giving the current tickenvironment- a read-only view of the worker's environmentagentSet- the set of agents to act upon during this tickrandom- the random generator the tick logic can use
-