Package modelarium.entities.generators
Class FunctionalEnvironmentGenerator
java.lang.Object
modelarium.entities.generators.EnvironmentGenerator
modelarium.entities.generators.FunctionalEnvironmentGenerator
Class for generating the environment by delegating creation logic to a user-provided function.
This implementation of EnvironmentGenerator is useful when working across languages (e.g. from
Python), or when modular configuration is required without subclassing.
-
Constructor Summary
ConstructorsConstructorDescriptionFunctionalEnvironmentGenerator(BiFunction<Config, RandomGenerator, Environment> generatorFunction) Constructs a new functional generator and uses the default reset logic.FunctionalEnvironmentGenerator(BiFunction<Config, RandomGenerator, Environment> generatorFunction, Runnable resetFunction) Constructs a new functional generator. -
Method Summary
Modifier and TypeMethodDescriptiongenerateEnvironment(Config config, RandomGenerator random) Generates the environment by applying the user-provided generator function.protected voidreset()Resets the state of the generator.
-
Constructor Details
-
FunctionalEnvironmentGenerator
public FunctionalEnvironmentGenerator(BiFunction<Config, RandomGenerator, Environment> generatorFunction, Runnable resetFunction) Constructs a new functional generator.- Parameters:
generatorFunction- the function used to generate the environmentresetFunction- the function used to reset the state of the generator the environment is generated
-
FunctionalEnvironmentGenerator
public FunctionalEnvironmentGenerator(BiFunction<Config, RandomGenerator, Environment> generatorFunction) Constructs a new functional generator and uses the default reset logic.- Parameters:
generatorFunction- the function used to generate the environment
-
-
Method Details
-
generateEnvironment
Generates the environment by applying the user-provided generator function.- Specified by:
generateEnvironmentin classEnvironmentGenerator- Parameters:
config- the global model settings used to configure the environmentrandom- the random generator the environment generator can use for constructing an environment- Returns:
- a new
Environmentinstance
-
reset
protected void reset()Resets the state of the generator.- Overrides:
resetin classEnvironmentGenerator
-