Multi-Cartpole
Ver. 1.3.3 (2023-02-22)
This module provides an environment with multivariate state and action spaces based on the OpenAI Gym environment ‘CartPole-v1’.
- class mlpro.rl.pool.envs.multicartpole.MultiCartPole(p_num_envs=2, p_reward_type=0, p_visualize: bool = True, p_logging=True)
Bases:
Environment
This environment multivariate space and action spaces by duplicating the OpenAI Gym environment ‘CartPole-v1’. The number of internal CartPole sub-enironments can be parameterized.
- C_NAME = 'MultiCartPole'
- C_LATENCY = datetime.timedelta(seconds=1)
- C_INFINITY = 3.4028235e+38
- C_PLOT_ACTIVE: bool = True
- static load(p_path, p_filename)
Static method to load an object of the current class from a file using pickle/dill. During unpickling the given file, standard method __setstate__() is called. This in turn is implemented specifically and calls the MLPro custom method _complete_state(). This method allows the completion of the unpickled object from further externally stored data.
- Parameters:
p_path (str) – Path where file will be saved
p_filename (str = None) – File name (if None an internal filename will be used)
- Returns:
Object of the given class that was unpickled from the given file.
- Return type:
Object
- switch_logging(p_logging)
Sets new log level.
- Parameters:
p_logging – Log level (constant C_LOG_LEVELS contains valid values)
- static setup_spaces()
Static template method to set up and return state and action space of environment.
- Returns:
state_space (MSpace) – State space object
action_space (MSpace) – Action space object
- get_cycle_limit()
Returns limit of cycles per training episode.
- simulate_reaction(p_state: State, p_action: Action) State
Simulates a state transition based on a state and an action. The simulation step itself is carried out either by an internal custom implementation in method _simulate_reaction() or by an embedded external function.
- compute_success(p_state: State) bool
Assesses the given state whether it is a ‘success’ state. Assessment is carried out either by a custom implementation in method _compute_success() or by an embedded external function.
- Parameters:
p_state (State) – State to be assessed.
- Returns:
success – True, if the given state is a ‘success’ state. False otherwise.
- Return type:
bool
- compute_broken(p_state: State) bool
Assesses the given state whether it is a ‘broken’ state. Assessment is carried out either by a custom implementation in method _compute_broken() or by an embedded external function.
- Parameters:
p_state (State) – State to be assessed.
- Returns:
broken – True, if the given state is a ‘broken’ state. False otherwise.
- Return type:
bool
- init_plot(p_figure: Figure | None = None, p_plot_settings: list = Ellipsis, p_plot_depth: int = 0, p_detail_level: int = 0, p_step_rate: int = 0, **p_kwargs)
Initializes the plot functionalities of the class.
- Parameters:
p_figure (Matplotlib.figure.Figure, optional) – Optional MatPlotLib host figure, where the plot shall be embedded. The default is None.
p_plot_settings (PlotSettings) – Optional plot settings. If None, the default view is plotted (see attribute C_PLOT_DEFAULT_VIEW).
- update_plot(**p_kwargs)
Updates the plot.
- Parameters:
**p_kwargs – Implementation-specific plot data and/or parameters.