Package modelarium.entities.generators
Class DefaultAgentGenerator
java.lang.Object
modelarium.entities.generators.AgentGenerator
modelarium.entities.generators.DefaultAgentGenerator
- Direct Known Subclasses:
FunctionalDefaultAgentGenerator
Abstract base class for generating agent populations in a simulation.
This class provides methods to:
- Generate a full set of agents based on model settings
- Distribute agents evenly across multiple processing threads
Concrete subclasses must implement the generateAgent(Config, RandomGenerator) method,
which defines how individual agents are constructed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AgentgenerateAgent(Config config, RandomGenerator random) Abstract method for generating a single agent instance.generateAgents(Config config, RandomGenerator random) Generates a completeAgentSetbased on the number of agents specified in the model settings.generateAgentsForEachThread(Config config, RandomGenerator random) Distributes agents across processing threads in a round-robin fashion.Methods inherited from class modelarium.entities.generators.AgentGenerator
reset
-
Constructor Details
-
DefaultAgentGenerator
public DefaultAgentGenerator()Constructs a default agent generator.
-
-
Method Details
-
generateAgents
Generates a completeAgentSetbased on the number of agents specified in the model settings.- Parameters:
config- the simulation configuration containing the agent countrandom- the random generator the agent generator can use for constructing agents- Returns:
- an
AgentSetcontaining all generated agents
-
generateAgentsForEachThread
Distributes agents across processing threads in a round-robin fashion. This ensures an even workload split for multithreaded simulations.- Specified by:
generateAgentsForEachThreadin classAgentGenerator- Parameters:
config- the simulation settings containing agent and thread countsrandom- the random generator the agent generator can use for constructing agents- Returns:
- a list of
AgentSetobjects, one per thread
-
generateAgent
Abstract method for generating a single agent instance. Must be implemented by concrete subclasses.- Parameters:
config- the model settings passed to the agent during creationrandom- the random generator the agent generator can use while constructing the agent- Returns:
- a new
Agentinstance
-