sinergym.utils.common.CSVLogger
- class sinergym.utils.common.CSVLogger(monitor_header: str, progress_header: str, log_progress_file: str, log_file: Optional[str] = None, flag: bool = True)
CSV Logger for agent interaction with environment.
- Parameters
monitor_header – CSV header for sub_run_N/monitor.csv which record interaction step by step.
progress_header – CSV header for res_N/progress.csv which record main data episode by episode.
log_file – log_file path for monitor.csv, there will be one CSV per episode.
log_progress_file – log_file path for progress.csv, there will be only one CSV per whole simulation.
flag – This flag is used to activate (True) or deactivate (False) Logger in real time.
etc (steps_data, rewards, powers,) – These arrays are used to record steps data to elaborate main data for progress.csv later.
total_timesteps – Current episode timesteps executed.
total_time_elapsed – Current episode time elapsed (simulation seconds).
comfort_violation_timesteps – Current episode timesteps whose comfort_penalty!=0.
steps_data – It is a array of str’s. Each element belong to a step data.
- __init__(monitor_header: str, progress_header: str, log_progress_file: str, log_file: Optional[str] = None, flag: bool = True)
Methods
__init__
(monitor_header, progress_header, ...)Activate Sinergym CSV logger
Deactivate Sinergym CSV logger
log_episode
(episode)Log episode main information using steps_data param.
log_step
(timestep, date, observation, ...)Log step information and store it in steps_data attribute.
log_step_normalize
(timestep, date, ...)Log step information and store it in steps_data_normalized attribute.
set_log_file
(new_log_file)Change log_file path for monitor.csv when an episode ends.
- activate_flag() None
Activate Sinergym CSV logger
- deactivate_flag() None
Deactivate Sinergym CSV logger
- log_episode(episode: int) None
Log episode main information using steps_data param.
- Parameters
episode (int) – Current simulation episode number.
- log_step(timestep: int, date: List[int], observation: List[Any], action: Union[List[Union[int, float]], List[None]], simulation_time: float, reward: Optional[float], total_power_no_units: Optional[float], comfort_penalty: Optional[float], power: Optional[float], done: bool) None
Log step information and store it in steps_data attribute.
- Parameters
timestep (int) – Current episode timestep in simulation.
date (list) – Current date [month,day,hour] in simulation.
observation (list) – Values that belong to current observation.
action (list) – Values that belong to current action.
simulation_time (float) – Total time elapsed in current episode (seconds).
reward (float) – Current reward achieved.
total_power_no_units (float) – Power consumption penalty depending on reward function.
comfort_penalty (float) – Temperature comfort penalty depending on reward function.
power (float) – Power consumption in current step (W).
done (bool) – It specifies if this step terminates episode or not.
- log_step_normalize(timestep: int, date: List[int], observation: List[Any], action: Union[List[Union[int, float]], List[None]], simulation_time: float, reward: Optional[float], total_power_no_units: Optional[float], comfort_penalty: Optional[float], done: bool) None
Log step information and store it in steps_data_normalized attribute.
- Parameters
timestep (int) – Current episode timestep in simulation.
date (List[int, int, int]) – Current date [month,day,hour] in simulation.
observation (List[Any]) – Values that belong to current observation.
action (List[Union[int, float]]) – Values that belong to current action.
simulation_time (float) – Total time elapsed in current episode (seconds).
reward (float) – Current reward achieved.
total_power_no_units (float) – Power consumption penalty depending on reward function.
comfort_penalty (float) – Temperature comfort penalty depending on reward function.
done (bool) – It specifies if this step terminates episode or not.
- set_log_file(new_log_file: str) None
Change log_file path for monitor.csv when an episode ends.
- Parameters
new_log_file (str) – New log path depending on simulation.