releso.base_parser.BaseParser
- class releso.base_parser.BaseParser(*, save_location: Path, logger_name: str | None = None, verbosity: Verbosity = None, agent: PPOAgent | DDPGAgent | SACAgent | PretrainedAgent | DQNAgent | A2CAgent, environment: Environment, number_of_timesteps: ConstrainedIntValue, number_of_episodes: ConstrainedIntValue | None = None, validation: Validation | None = None, n_environments: ConstrainedIntValue | None = 1, normalize_training_values: bool = False, multi_env_sequential: bool = False, episode_log_update: ConstrainedIntValue = 100, export_step_log: bool = False, step_log_update: ConstrainedIntValue = 0, step_log_info: bool = False)
Bases:
BaseModelClass parses the experiment definition and conducts the training.
This class can be used to initialize the ReLeSO Framework from the command line by reading in a json representation of the RL based Shape Optimization problem which is to be solved via Reinforcement Learning.
- __init__(**data: Any) None
Constructor of the base parser.
Initializes the class correctly and also adds the correct logger to all subclasses.
Methods
convert_to_pathlib_add_datetime(v)Add timestamp to save_location, of applicable.
evaluate_model([validation_env, ...])Validate the current agent.
get_logger()Gets the currently defined environment logger.
learn()Starts the training that is specified in the loaded json file.
save_model([file_name])Save the state of the agent.
set_logger_name_recursively(logger_name)Set the logger_name variable for all child elements.
Attributes
Defining the verbosity of the training process and environment loading
Definition of the agent to be used during training and/or validation of the RL use case
Definition of the environment which encodes the parameters of the RL use case
Number of timesteps the training process should run for
Number of episodes the training process should run for.
Definition of the validation .
Number of environments to train in parallel.
but the training might be a little bit more unstable.
Should the multi environment be run sequentially (True) or with multi processing (False).
Number of episodes after which the episode_log is updated.
Flag indicating whether the step information (like actions, observations, ...) should be logged to file.
Number of steps after which the step_log is updated.
Flag indicating whether the step_log should also contain the information of the environment step.
save_locationDefinition of the save location of the logs and validation results.
logger_namename of the logger.
- agent: PPOAgent | DDPGAgent | SACAgent | PretrainedAgent | DQNAgent | A2CAgent
Definition of the agent to be used during training and/or validation of the RL use case
- environment: Environment
Definition of the environment which encodes the parameters of the RL use case
- episode_log_update: ConstrainedIntValue
Number of episodes after which the episode_log is updated. It will be updated at the end of the training in any case. But making this number higher will lower the computational overhead. Defaults to 100.
- evaluate_model(validation_env: None | Environment = None, throw_error_if_none: bool = False) None
Validate the current agent.
Evaluate the model with the parameters defined in the validation variable. If an agent is already loaded use this agent, else get the agent from the agent variable. Validation will be done inside the
- Parameters:
validation_env (Union[None, Environment], optional) – If validation
validation (environment already exists it will be used else a new)
None. (environment will be created. Defaults to)
throw_error_if_none (bool, optional) – If this is set and the
False. (validation variable is None an error is thrown. Defaults to)
- Raises:
ValidationNotSet – Thrown if validation is absolutely needed.
If not absolutely needed the validation will not be done but no –
error will be thrown. –
- export_step_log: bool
Flag indicating whether the step information (like actions, observations, …) should be logged to file. Defaults to False.
- learn() None
Starts the training that is specified in the loaded json file.
Successive calls to this function does not train the agent further
but reinitialize the agent.
- multi_env_sequential: bool
Should the multi environment be run sequentially (True) or with multi processing (False). Defaults to False.
- n_environments: ConstrainedIntValue | None
Number of environments to train in parallel. Defaults to None.
- normalize_training_values: bool
but the training might be a little bit more unstable. Defaults to False.
- number_of_episodes: ConstrainedIntValue | None
Number of episodes the training process should run for. If given both timesteps and max episodes can stop the trainings progress. Default: None
- number_of_timesteps: ConstrainedIntValue
Number of timesteps the training process should run for
- save_model(file_name: str | None = None) str
Save the state of the agent.
Saves the current agent to the specified location or to a default location.
- Parameters:
file_name (Optional[str]) – Path where the agent is saved to. If
will (None will see if json had a save location if also not given)
None. (use a default location. Defaults to)
- Returns:
Path where the agent was saved to.
- Return type:
str
- step_log_info: bool
Flag indicating whether the step_log should also contain the information of the environment step. Defaults to False.
- step_log_update: ConstrainedIntValue
Number of steps after which the step_log is updated. It will be updated at the end of the training in any case. But making this number higher will lower the computational overhead. Defaults to 0 which triggers the output after every episode.
- validation: Validation | None
Definition of the validation . Defaults to None.