Class FunctionalEnvironmentGenerator

java.lang.Object
modelarium.entities.generators.EnvironmentGenerator
modelarium.entities.generators.FunctionalEnvironmentGenerator

public class FunctionalEnvironmentGenerator extends EnvironmentGenerator
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 Details

    • FunctionalEnvironmentGenerator

      public FunctionalEnvironmentGenerator(BiFunction<Config,RandomGenerator,Environment> generatorFunction, Runnable resetFunction)
      Constructs a new functional generator.
      Parameters:
      generatorFunction - the function used to generate the environment
      resetFunction - 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

      public Environment generateEnvironment(Config config, RandomGenerator random)
      Generates the environment by applying the user-provided generator function.
      Specified by:
      generateEnvironment in class EnvironmentGenerator
      Parameters:
      config - the global model settings used to configure the environment
      random - the random generator the environment generator can use for constructing an environment
      Returns:
      a new Environment instance
    • reset

      protected void reset()
      Resets the state of the generator.
      Overrides:
      reset in class EnvironmentGenerator