StructuredVectorEnv

class maze.train.parallelization.vector_env.structured_vector_env.StructuredVectorEnv(n_envs: int, action_spaces_dict: Dict[Union[str, int], gym.spaces.Space], observation_spaces_dict: Dict[Union[str, int], gym.spaces.Space], agent_counts_dict: Dict[Union[str, int], int], logging_prefix: Optional[str] = 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

(overrides StructuredEnvSpacesMixin)

implementation of StructuredEnvSpacesMixin interface

property action_spaces_dict

Return the action space of one of the vectorised envs.

actor_id()maze.core.env.structured_env.ActorID

(overrides StructuredEnv)

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

property agent_counts_dict

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() → Optional[numpy.ndarray]

(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_stats(level: maze.core.log_stats.log_stats.LogStatsLevel)maze.core.log_stats.log_stats.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: maze.core.log_stats.log_stats.LogStatsLevel, name: Optional[str] = None) → Union[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

(overrides StructuredEnvSpacesMixin)

implementation of StructuredEnvSpacesMixin interface

property observation_spaces_dict

Return the observation space of one of the vectorised envs.

write_epoch_stats()

(overrides LogStatsEnv)

Trigger the epoch statistics generation.