melgym.envs.pressure.PressureEnv

class melgym.envs.pressure.PressureEnv(melcor_model, control_cfs, min_action_value, max_action_value, setpoints, max_episode_len, max_deviation=None, render_mode=None, logging=False)

Pressure control environment.

This subclass re-implements the reset, saatep, compute_reward, check_termination, check_truncation, and rendering methods. for a pressure control environment.

Parameters:
  • melcor_model (str) – Path to the MELCOR model file.

  • control_cfs (list) – List of controlled CFs.

  • min_action_value (float) – Minimum action value.

  • max_action_value (float) – Maximum action value.

  • setpoints (list) – List of setpoints.

  • max_episode_len (float) – Maximum length of an episode for truncation.

  • max_deviation (float) – Maximum deviation from setpoints for truncation.

  • render_mode (str) – Render mode. Default is None.

  • logging (bool) – Logging option. Default is False.

__init__(melcor_model, control_cfs, min_action_value, max_action_value, setpoints, max_episode_len, max_deviation=None, render_mode=None, logging=False)

Initializes the MELCOR environment.

Parameters:
  • melcor_model (str) – Path to the MELCOR model file.

  • control_cfs (list[str]) – List of controlled CFs.

  • min_action_value (float) – Minimum action value.

  • max_action_value (float) – Maximum action value.

  • control_horizon (int) – Control horizon (timesteps between actions).

  • output_dir (Optional[str]) – Directory name for output files. If None, a default directory is used.

  • render_mode (Optional[str]) – Mode for rendering the environment.

  • melgen_path (Optional[str]) – Path to the MELGEN executable. If None, the default path in exec directory is used.

  • melcor_path (Optional[str]) – Path to the MELCOR executable. If None, the default path in exec directory is used.

Methods

__init__(melcor_model, control_cfs, ...[, ...])

Initializes the MELCOR environment.

close()

Closes the environment and cleans up resources.

get_wrapper_attr(name)

Gets the attribute name from the environment.

has_wrapper_attr(name)

Checks if the attribute name exists in the environment.

render()

Renders the controlled pressures.

reset(**kwargs)

Resets the environment and clears the plot.

set_wrapper_attr(name, value, *[, force])

Sets the attribute name on the environment with value, see Wrapper.set_wrapper_attr for more info.

step(action)

Redefinition of the step method to allow logging.

_check_termination(obs, info)

Checks if the episode has terminated.

Parameters:
  • obs (np.array) – Current observation.

  • info (dict) – Additional information about the current state.

Returns:

True if the episode should terminate, False otherwise.

Return type:

bool

_check_truncation(obs, info)

” Checks if the episode should be truncated based on time limit or maximum allowed deviation.

Parameters:
  • obs (np.array) – Current observation.

  • info (dict) – Additional information about the current state.

Returns:

True if the episode should be truncated, False otherwise.

Return type:

bool

_compute_reward(obs, info)

Computes the reward based on the current observation and the given setpoints.

Parameters:
  • obs (np.array) – Current observation.

  • info (dict) – Additional information about the current state.

Returns:

Computed reward.

Return type:

float

_init_csv_log()

Initializes the CSV log file with headers.

_update_plot()

Updates the pressures plot.

_write_csv_log(step, action, obs, reward, termination, truncation)

Appends a row to the CSV log file.

metadata: dict[str, Any] = {'render_fps': 30, 'render_modes': ['human']}
render()

Renders the controlled pressures.

reset(**kwargs)

Resets the environment and clears the plot.

Returns:

A tuple containing the initial observation (i.e., provided setpoints) and env information.

Return type:

tuple

step(action)

Redefinition of the step method to allow logging.

Returns:

A tuple containing the observation, reward, termination, truncation, and env information.

Return type:

tuple