smartgrid.observation.observations.Observation¶
- class smartgrid.observation.observations.Observation(personal_storage, comfort, payoff, hour, available_energy, equity, energy_loss, autonomy, exclusion, well_being, over_consumption)[source]¶
Bases:
Observation
Observations are information that agents receive about the environment.
They describe the current state of the environment through various metrics, and are used to take decisions (actions). We represent Observations as named tuples, so that these metrics can be easily accessed by name, e.g.,
obs.hour
.Most algorithms use NumPy vectors, or even TensorFlow / PyTorch tensors, to represent observations, instead of named tuples. To simplify their use, instances of this class can be transformed into NumPy vectors through the usual
numpy.asarray()
, e.g.,np.asarray(obs)
returns the NumPy vector corresponding to the named tupleobs
.The observation space, i.e., the domain in which observations take their values, can be programmatically accessed at runtime through the
Observation.get_observation_space()
class method.- __init__()¶
Methods
__init__
()Verifies that values are in the correct interval.
count
(value, /)Return number of occurrences of value.
create
(local_observation, global_observation)Create a new Observation from existing local and global ones.
Describes the space in which Observations take their values.
index
(value[, start, stop])Return first index of value.
Attributes
Alias for field number 7
Alias for field number 4
Alias for field number 1
Alias for field number 6
Alias for field number 5
Alias for field number 8
Alias for field number 3
Alias for field number 10
Alias for field number 2
Alias for field number 0
Alias for field number 9
- _asdict()¶
Return a new dict which maps field names to their values.
- classmethod _make(iterable)¶
Make a new Observation object from a sequence or iterable
- _replace(**kwds)¶
Return a new Observation object replacing specified fields with new values
- autonomy¶
Alias for field number 7
- available_energy¶
Alias for field number 4
- check_between_0_and_1()[source]¶
Verifies that values are in the correct interval.
This method is mainly used internally, when a new Observation is created, to ensure that the vector’s values are correct, w.r.t. the space.
If some values are not in [0,1], they are signalled (name and value) through a warning.
- comfort¶
Alias for field number 1
- count(value, /)¶
Return number of occurrences of value.
- classmethod create(local_observation: LocalObservation, global_observation: GlobalObservation)[source]¶
Create a new Observation from existing local and global ones.
The fields of both
LocalObservation
andGlobalObservation
are merged.- Return type:
- energy_loss¶
Alias for field number 6
- equity¶
Alias for field number 5
- exclusion¶
Alias for field number 8
- classmethod get_observation_space()[source]¶
Describes the space in which Observations take their values.
This method is useful if an algorithm has assumptions or requirements on the observation space. For example, values can be interpolated, by knowing their original domain.
- Return type:
gym.spaces.Box
- Returns:
A gym Box, whose
low
field indicates the minimum value of each element of the observation vector. Similarly, thehigh
field indicates the maximum value of each element, such that each element i of the vector is contained betweenlow[i]
andhigh[i]
. The Box’s shape is the number of fields.
- hour¶
Alias for field number 3
- index(value, start=0, stop=9223372036854775807, /)¶
Return first index of value.
Raises ValueError if the value is not present.
- over_consumption¶
Alias for field number 10
- payoff¶
Alias for field number 2
- personal_storage¶
Alias for field number 0
- well_being¶
Alias for field number 9