eta_utility.eta_x.eta_x module

class eta_utility.eta_x.eta_x.ETAx(root_path: str | os.PathLike, config_name: str, config_overwrite: Mapping[str, Any] | None = None, relpath_config: str | os.PathLike = 'config/')[source]

Bases: object

Initialize an optimization model and provide interfaces for optimization, learning and execution (play).

Parameters:
  • root_path – Root path of the eta_x application (the configuration will be interpreted relative to this).

  • config_name – Name of configuration .ini file in configuration directory (should be JSON format).

  • config_overwrite – Dictionary to overwrite selected configurations.

  • relpath_config – Relative path to configuration file, starting from root path.

path_config

Path to the configuration file.

config: ConfigOpt

ConfigOpt object for the optimization run.

config_run: ConfigOptRun | None

Configuration for an optimization run.

environments: VecEnv | VecNormalize | None

The vectorized environments.

interaction_env: VecEnv | None

Vectorized interaction environments.

model: BaseAlgorithm | None

The model or algorithm.

prepare_environments_models(series_name: str | None, run_name: str | None, run_description: str = '', reset: bool = False, training: bool = False) Generator[source]
prepare_run(series_name: str, run_name: str, run_description: str = '') None[source]

Prepare the learn and play methods by reading configuration, creating results folders and the model.

Parameters:
  • series_name – Name for a series of runs.

  • run_name – Name for a specific run.

  • run_description – Description for a specific run.

prepare_model(reset: bool = False) None[source]

Check for existing model and load it or back it up and create a new model.

Parameters:

reset – Flag to determine whether an existing model should be reset.

prepare_environments(training: bool = True) Generator[source]

Context manager which prepares the environments and closes them after it exits.

Parameters:

training – Should preparation be done for training (alternative: playing)?

learn(series_name: str | None = None, run_name: str | None = None, run_description: str = '', reset: bool = False, callbacks: MaybeCallback = None) None[source]

Start the learning job for an agent with the specified environment.

Parameters:
  • series_name – Name for a series of runs.

  • run_name – Name for a specific run.

  • run_description – Description for a specific run.

  • reset – Indication whether possibly existing models should be reset. Learning will be continued if model exists and reset is false.

  • callbacks – Provide additional callbacks to send to the model.learn() call.

play(series_name: str | None = None, run_name: str | None = None, run_description: str = '') None[source]

Play with previously learned agent model in environment.

Parameters:
  • series_name – Name for a series of runs.

  • run_name – Name for a specific run.

  • run_description – Description for a specific run.