StructuredVectorEnv

class maze.train.parallelization.vector_env.structured_vector_env.StructuredVectorEnv(n_envs: int, action_spaces_dict: Dict[str | int, gymnasium.spaces.Space], observation_spaces_dict: Dict[str | int, gymnasium.spaces.Space], agent_counts_dict: Dict[str | int, int], logging_prefix: str | None = None)

Common superclass for the structured vectorised env implementations in Maze.

Parameters:
  • n_envs – The number of vectorised environments.

  • action_spaces_dict – Action spaces dict (not vectorized, as it is the same for all environments)

  • observation_spaces_dict – Observation spaces dict (not vectorized, as it is the same for all environments)

  • logging_prefix – If set, will report epoch statistics under this logging prefix.

property action_space: gymnasium.spaces.Space

(overrides StructuredEnvSpacesMixin)

implementation of StructuredEnvSpacesMixin interface

property action_spaces_dict: Dict[int | str, gymnasium.spaces.Space]

Return the action space of one of the vectorised envs.

actor_id() ActorID

(overrides StructuredEnv)

Current actor ID (should be the same for all envs, as only synchronous envs are supported).

property agent_counts_dict: Dict[str | int, int]

Return the agent counts of one of the vectorised envs.

clear_epoch_stats() None

(overrides LogStatsEnv)

Clear out episode statistics collected so far in this epoch.

abstract get_actor_rewards() numpy.ndarray | None

(overrides StructuredEnv)

Individual implementations need to override this to support structured rewards.

get_env_time() numpy.ndarray

(overrides TimeEnvMixin)

Return current env time for all vectorised environments.

get_next_seed() Any | None

Return the next seed to use.

Returns:

The next seed to use.

get_stats(level: LogStatsLevel) LogStatsAggregator

(overrides LogStatsEnv)

Returns the aggregator of the individual episode statistics emitted by the parallel envs.

param level:

Must be set to LogStatsLevel.EPOCH, step or episode statistics are not propagated

get_stats_value(event: Callable, level: LogStatsLevel, name: str | None = None) int | float | numpy.ndarray | dict

(overrides LogStatsEnv)

Obtain a single value from the epoch statistics dict.

param event:

The event interface method of the value in question.

param name:

The output_name of the statistics in case it has been specified in maze.core.log_stats.event_decorators.define_epoch_stats()

param level:

Must be set to LogStatsLevel.EPOCH, step or episode statistics are not propagated.

is_actor_done() numpy.ndarray

(overrides StructuredEnv)

Return the done flags of all actors in a list.

property observation_space: gymnasium.spaces.Space

(overrides StructuredEnvSpacesMixin)

implementation of StructuredEnvSpacesMixin interface

property observation_spaces_dict: Dict[int | str, gymnasium.spaces.Space]

Return the observation space of one of the vectorised envs.

write_epoch_stats()

(overrides LogStatsEnv)

Trigger the epoch statistics generation.