Package modelarium

Class Config.ConfigBuilder

java.lang.Object
modelarium.Config.ConfigBuilder
Enclosing class:
Config

public static class Config.ConfigBuilder extends Object
Class for assisting in the constructing of a Config record.
  • Constructor Details

    • ConfigBuilder

      public ConfigBuilder()
      Constructs a builder initialised with Modelarium's default configuration values.
  • Method Details

    • populationSize

      public Config.ConfigBuilder populationSize(int populationSize)
      Sets the model's population size.
      Parameters:
      populationSize - the number of agents the model will contain
      Returns:
      this updated Config.ConfigBuilder instance
    • tickCount

      public Config.ConfigBuilder tickCount(int tickCount)
      Sets the number of ticks in the model.
      Parameters:
      tickCount - the number of time steps the model will perform
      Returns:
      this updated Config.ConfigBuilder instance
    • threadCount

      public Config.ConfigBuilder threadCount(int threadCount)
      Sets the number of worker threads the model will use to run.
      Parameters:
      threadCount - the number of worker threads the model will use
      Returns:
      this updated Config.ConfigBuilder instance
    • threadTimeout

      public Config.ConfigBuilder threadTimeout(Duration threadTimeout)
      (Optional) Sets the duration of time needed before a thread's request to another thread times out.

      If this method is not used, the thread timeout duration is set to 60 seconds by default.

      Parameters:
      threadTimeout - the maximum duration a thread should wait for a response from another thread
      Returns:
      this updated Config.ConfigBuilder instance
    • areThreadsSynced

      public Config.ConfigBuilder areThreadsSynced(boolean areThreadsSynced)
      Sets whether the model's threads are synchronised or not.
      Parameters:
      areThreadsSynced - whether the threads are synchronised or not, determining if interaction of entities over multiple threads is possible
      Returns:
      this updated Config.ConfigBuilder instance
    • agentGenerator

      public Config.ConfigBuilder agentGenerator(AgentGenerator agentGenerator)
      Sets the AgentGenerator instance the model will use to generate agents.
      Parameters:
      agentGenerator - an instance of an agent generator class which is used by the model to generate agents
      Returns:
      this updated Config.ConfigBuilder instance
    • environmentGenerator

      public Config.ConfigBuilder environmentGenerator(EnvironmentGenerator environmentGenerator)
      Sets the EnvironmentGenerator instance the model will use to generate the environment.
      Parameters:
      environmentGenerator - an instance of an environment generator class which is used by the model to generate an environment
      Returns:
      this updated Config.ConfigBuilder instance
    • scheduler

      public Config.ConfigBuilder scheduler(Scheduler scheduler)
      (Optional) Sets the Scheduler instance the model will use to sequence the running of agents at each time step.

      If this method is not used, the model is set by default to use a newly created instance of InOrderScheduler by default.

      Parameters:
      scheduler - an instance of a scheduler class which is used by the model to order the running of each agent as the model progresses
      Returns:
      this updated Config.ConfigBuilder instance
    • runLogDatabaseFactory

      public Config.ConfigBuilder runLogDatabaseFactory(AttributeSetLogDatabaseFactory runLogDatabaseFactory)
      (Optional) Sets the AttributeSetLogDatabaseFactory instance the model will use to generate the database for storing the attribute logs of each entity.

      If this method is not used, the model's attribute set log database factory is set to a newly created instance of MemoryBasedAttributeSetLogDatabaseFactory by default.

      Parameters:
      runLogDatabaseFactory - an instance of an attribute set log database factory which the model uses to create a database that can store attribute logs as the model progresses
      Returns:
      this updated Config.ConfigBuilder instance
    • seed

      public Config.ConfigBuilder seed(long seed)
      (Optional) Sets the seed value the model will use to generate its core random generator which model components and entities can then use.

      If this method is not used, the seed value is set to the current time in nanoseconds by default.

      Parameters:
      seed - the seed value used for the core random generator used by the model
      Returns:
      this updated Config.ConfigBuilder instance
    • build

      public Config build()
      Creates a new instance of Config based on the configuration settings provided using the other methods.
      Returns:
      a new Config instance