Package modelarium
Class Config.ConfigBuilder
java.lang.Object
modelarium.Config.ConfigBuilder
- Enclosing class:
Config
Class for assisting in the constructing of a
Config record.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a builder initialised with Modelarium's default configuration values. -
Method Summary
Modifier and TypeMethodDescriptionagentGenerator(AgentGenerator agentGenerator) Sets theAgentGeneratorinstance the model will use to generate agents.areThreadsSynced(boolean areThreadsSynced) Sets whether the model's threads are synchronised or not.build()Creates a new instance ofConfigbased on the configuration settings provided using the other methods.environmentGenerator(EnvironmentGenerator environmentGenerator) Sets theEnvironmentGeneratorinstance the model will use to generate the environment.populationSize(int populationSize) Sets the model's population size.runLogDatabaseFactory(AttributeSetLogDatabaseFactory runLogDatabaseFactory) (Optional) Sets theAttributeSetLogDatabaseFactoryinstance the model will use to generate the database for storing the attribute logs of each entity.(Optional) Sets theSchedulerinstance the model will use to sequence the running of agents at each time step.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.threadCount(int threadCount) Sets the number of worker threads the model will use to run.threadTimeout(Duration threadTimeout) (Optional) Sets the duration of time needed before a thread's request to another thread times out.tickCount(int tickCount) Sets the number of ticks in the model.
-
Constructor Details
-
ConfigBuilder
public ConfigBuilder()Constructs a builder initialised with Modelarium's default configuration values.
-
-
Method Details
-
populationSize
Sets the model's population size.- Parameters:
populationSize- the number of agents the model will contain- Returns:
- this updated
Config.ConfigBuilderinstance
-
tickCount
Sets the number of ticks in the model.- Parameters:
tickCount- the number of time steps the model will perform- Returns:
- this updated
Config.ConfigBuilderinstance
-
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.ConfigBuilderinstance
-
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.ConfigBuilderinstance
-
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.ConfigBuilderinstance
-
agentGenerator
Sets theAgentGeneratorinstance 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.ConfigBuilderinstance
-
environmentGenerator
Sets theEnvironmentGeneratorinstance 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.ConfigBuilderinstance
-
scheduler
(Optional) Sets theSchedulerinstance 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
InOrderSchedulerby 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.ConfigBuilderinstance
-
runLogDatabaseFactory
public Config.ConfigBuilder runLogDatabaseFactory(AttributeSetLogDatabaseFactory runLogDatabaseFactory) (Optional) Sets theAttributeSetLogDatabaseFactoryinstance 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
MemoryBasedAttributeSetLogDatabaseFactoryby 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.ConfigBuilderinstance
-
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.ConfigBuilderinstance
-
build
Creates a new instance ofConfigbased on the configuration settings provided using the other methods.- Returns:
- a new
Configinstance
-