smartgrid.observation.observation_manager.ObservationManager¶
- class smartgrid.observation.observation_manager.ObservationManager(local_observation: ~typing.Type[~smartgrid.observation.local_observation.LocalObservation] = <class 'smartgrid.observation.local_observation.LocalObservation'>, global_observation: ~typing.Type[~smartgrid.observation.global_observation.GlobalObservation] = <class 'smartgrid.observation.global_observation.GlobalObservation'>, observation: ~typing.Type[~smartgrid.observation.observations.Observation] = <class 'smartgrid.observation.observations.Observation'>)[source]¶
Bases:
object
The ObservationManager is responsible for computing observations.
Its primary purpose is to allow extensibility: the attributes
global_observation
andlocal_observation
, which are set through the constructor, control which Observation classes will be used in the simulator. It is thus possible to subclassGlobalObservation
and/orLocalObservation
to use different observations.The computing calls (
compute_agent()
andcompute_global()
) are delegated to the corresponding calls through these attributes.- __init__(local_observation: ~typing.Type[~smartgrid.observation.local_observation.LocalObservation] = <class 'smartgrid.observation.local_observation.LocalObservation'>, global_observation: ~typing.Type[~smartgrid.observation.global_observation.GlobalObservation] = <class 'smartgrid.observation.global_observation.GlobalObservation'>, observation: ~typing.Type[~smartgrid.observation.observations.Observation] = <class 'smartgrid.observation.observations.Observation'>)[source]¶
Methods
__init__
([local_observation, ...])compute_agent
(world, agent)Create the local observation for an Agent.
compute_global
(world)Create the global observation for the World.
reset
()Reset the ObservationManager.
Attributes
Describe the shapes of the various Observations (local, global, merged).
The class that will be used to compute global observations.
The class that will be used to compute local observations.
The class that will be used as the "complete" observation.
- compute_agent(world: World, agent: Agent) LocalObservation [source]¶
Create the local observation for an Agent.
- compute_global(world) GlobalObservation [source]¶
Create the global observation for the World.
- global_observation: Type[GlobalObservation]¶
The class that will be used to compute global observations. It should be a subclass of
GlobalObservation
to ensure that necessary methods are present. Please note that this field should be set to a class itself, not an instance, e.g.,GlobalObservation
(instead ofGlobalObservation()
).
- local_observation: Type[LocalObservation]¶
The class that will be used to compute local observations. It should be a subclass of
LocalObservation
to ensure that necessary methods are present. Please note that this field should be set to a class itself, not an instance, e.g.,LocalObservation
(instead ofLocalObservation()
).
- observation: Type[Observation]¶
The class that will be used as the “complete” observation.
- reset()[source]¶
Reset the ObservationManager.
It is particularly important to reset the memoization process of
GlobalObservation
.
- property shape: Dict[str, int]¶
Describe the shapes of the various Observations (local, global, merged).
- Return type:
- Returns:
A dict comprised of:
agent_state
,local_state
, andglobal_state
. Each of these fields describe the shape (i.e., number of dimensions) of the corresponding observation. Note thatagent_state
refers to the merged (both local and global) case.