sinergym.utils.logger.CSVLogger

class sinergym.utils.logger.CSVLogger(monitor_header: str, progress_header: str, log_progress_file: str, log_file: str | None = 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: str | None = None, flag: bool = True)

Methods

__init__(monitor_header, progress_header, ...)

activate_flag()

Activate Sinergym CSV logger

deactivate_flag()

Deactivate Sinergym CSV logger

log_episode(episode)

Log episode main information using steps_data param.

log_step(obs, action, reward, done, info)

Log step information and store it in steps_data attribute.

log_step_normalize(obs, action, reward, ...)

Log step information and store it in steps_data 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(obs: List[Any], action: int | ndarray | List[Any], reward: float | None, done: bool, info: Dict[str, Any] | None) None

Log step information and store it in steps_data attribute.

Parameters:
  • obs (List[Any]) – Observation from step.

  • action (Union[int, np.ndarray, List[Any]]) – Action done in step.

  • reward (float) – Reward returned in step.

  • done (bool) – Done flag in step.

  • info (Dict[str, Any]) – Extra info collected in step.

log_step_normalize(obs: List[Any], action: int | ndarray | List[Any], reward: float | None, done: bool, info: Dict[str, Any] | None) None

Log step information and store it in steps_data attribute.

Parameters:
  • obs (List[Any]) – Observation from step.

  • action (Union[int, np.ndarray, List[Any]]) – Action done in step.

  • reward (Optional[float]) – Reward returned in step.

  • done (bool) – Done flag in step.

  • info (Optional[Dict[str, Any]]) – Extra info collected in step.

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.