Package modelarium.entities.generators
Class FunctionalAgentGenerator
java.lang.Object
modelarium.entities.generators.AgentGenerator
modelarium.entities.generators.FunctionalAgentGenerator
Class for generating agents by delegating creation logic to a user-defined function.
This implementation of AgentGenerator is intended for flexibility and cross-language use
(e.g. from Python).
-
Constructor Summary
ConstructorsConstructorDescriptionFunctionalAgentGenerator(BiFunction<Config, RandomGenerator, List<AgentSet>> getAgentsForEachThreadFunction) Constructs a new generator with the specified logic and uses the default reset logic.FunctionalAgentGenerator(BiFunction<Config, RandomGenerator, List<AgentSet>> getAgentsForEachThreadFunction, Runnable resetFunction) Constructs a new generator with the specified logic. -
Method Summary
Modifier and TypeMethodDescriptiongenerateAgentsForEachThread(Config config, RandomGenerator random) Generates the model's agents using the logic specified during construction and distributes them across the model's worker cores.protected voidreset()Resets the state of the generator.
-
Constructor Details
-
FunctionalAgentGenerator
public FunctionalAgentGenerator(BiFunction<Config, RandomGenerator, List<AgentSet>> getAgentsForEachThreadFunction, Runnable resetFunction) Constructs a new generator with the specified logic.- Parameters:
getAgentsForEachThreadFunction- the function used to generate agent sets for each threadresetFunction- the function used to reset the state of the generator after agents are generated
-
FunctionalAgentGenerator
public FunctionalAgentGenerator(BiFunction<Config, RandomGenerator, List<AgentSet>> getAgentsForEachThreadFunction) Constructs a new generator with the specified logic and uses the default reset logic.- Parameters:
getAgentsForEachThreadFunction- the function used to generate agent sets for each thread
-
-
Method Details
-
generateAgentsForEachThread
Generates the model's agents using the logic specified during construction and distributes them across the model's worker cores.- Specified by:
generateAgentsForEachThreadin classAgentGenerator- Parameters:
config- the model settings containing the agent and thread countsrandom- the random generator the agent generator can use for constructing agents- Returns:
- a list of
AgentSetobjects, one per thread
-
reset
protected void reset()Resets the state of the generator.- Overrides:
resetin classAgentGenerator
-