eta_ctrl.core_utils module
- eta_ctrl.core_utils.vectorize_environment(env: type[BaseEnv], config_run: ConfigRun, env_settings: EnvSettings, callback: Callable[[BaseEnv], None], verbose: int = 2, vectorizer: type[DummyVecEnv | SubprocVecEnv] | None = None, n: int = 1, seed: int | None = None, *, training: bool = False, monitor_wrapper: bool = False, norm_wrapper_obs: bool = False, norm_wrapper_reward: bool = False) VecNormalize | VecEnv[source]
Vectorize the environment and automatically apply normalization wrappers if configured.
- Parameters:
env – Environment class which will be instantiated and vectorized.
config_run – Configuration for a specific optimization run.
env_settings – Configuration settings dictionary for the environment which is being initialized.
callback – Callback to call with an environment instance.
verbose – Logging verbosity to use in the environment.
vectorizer – Vectorizer class to use for vectorizing the environments.
n – Number of vectorized environments to create.
training – Flag to identify whether the environment should be initialized for training or playing. If true, it will be initialized for training.
norm_wrapper_obs – Flag to determine whether observations from the environments should be normalized.
norm_wrapper_reward – Flag to determine whether rewards from the environments should be normalized.
- Returns:
Vectorized environments, possibly also wrapped in a normalizer.
- eta_ctrl.core_utils.initialize_model(algo: type[BaseAlgorithm], policy: type[BasePolicy], envs: VecEnv | VecNormalize, algo_settings: AlgoSettings, seed: int | None = None, *, tensorboard_log: bool = False, log_path: Path | None = None) BaseAlgorithm[source]
Initialize a new model or algorithm.
- Parameters:
algo – Algorithm to initialize.
policy – The policy that should be used by the algorithm.
envs – The environment which the algorithm operates on.
algo_settings – Additional settings for the algorithm.
seed – Random seed to be used by the algorithm.
tensorboard_log – Flag to enable logging to tensorboard.
log_path – Path for tensorboard log. Online required if logging is true
- Returns:
Initialized model.
- eta_ctrl.core_utils.load_model(algo: type[BaseAlgorithm], envs: VecEnv | VecNormalize, algo_settings: AlgoSettings, model_path: Path, *, tensorboard_log: bool = False, log_path: Path | None = None) BaseAlgorithm[source]
Load an existing model.
- Parameters:
algo – Algorithm type of the model to be loaded.
envs – The environment which the algorithm operates on.
algo_settings – Additional settings for the algorithm.
model_path – Path to load the model from.
tensorboard_log – Flag to enable logging to tensorboard.
log_path – Path for tensorboard log. Online required if logging is true
- Returns:
Initialized model.