Class DefaultAgentGenerator

java.lang.Object
modelarium.entities.generators.AgentGenerator
modelarium.entities.generators.DefaultAgentGenerator
Direct Known Subclasses:
FunctionalDefaultAgentGenerator

public abstract class DefaultAgentGenerator extends AgentGenerator
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 Details

    • DefaultAgentGenerator

      public DefaultAgentGenerator()
      Constructs a default agent generator.
  • Method Details

    • generateAgents

      public AgentSet generateAgents(Config config, RandomGenerator random)
      Generates a complete AgentSet based on the number of agents specified in the model settings.
      Parameters:
      config - the simulation configuration containing the agent count
      random - the random generator the agent generator can use for constructing agents
      Returns:
      an AgentSet containing all generated agents
    • generateAgentsForEachThread

      public List<AgentSet> generateAgentsForEachThread(Config config, RandomGenerator random)
      Distributes agents across processing threads in a round-robin fashion. This ensures an even workload split for multithreaded simulations.
      Specified by:
      generateAgentsForEachThread in class AgentGenerator
      Parameters:
      config - the simulation settings containing agent and thread counts
      random - the random generator the agent generator can use for constructing agents
      Returns:
      a list of AgentSet objects, one per thread
    • generateAgent

      protected abstract Agent generateAgent(Config config, RandomGenerator random)
      Abstract method for generating a single agent instance. Must be implemented by concrete subclasses.
      Parameters:
      config - the model settings passed to the agent during creation
      random - the random generator the agent generator can use while constructing the agent
      Returns:
      a new Agent instance