smartgrid.observation.global_observation.GlobalObservation

class smartgrid.observation.global_observation.GlobalObservation(hour, available_energy, equity, energy_loss, autonomy, exclusion, well_being, over_consumption)[source]

Bases: GlobalObservation

Global observations of the World, shared by all Agents in the smart grid.

These observations are not directly linked to a particular agent, but rather to the whole society of agents in the World, i.e., in this smart grid. Thus, the measures are the same for all agents.

To optimize computations, we thus create global observations only once each step.

A global observation is a vector containing the following measures:

hour

The current hour in the simulated world. It is computed as a ratio between 0 and 1, and days are ignored by using a modulo. Specifically, assuming that the current time step is t, the hour measure is computed as (t % 24) / 24.

available_energy

The quantity of energy available in the grid, which is accessible to all agents. This is a large pool of energy, however they should avoid over-consuming it, and take an appropriate quantity so as to let other agents profit as well. This measure is normalized as a value between 0 and 1, from the real available quantity, w.r.t. the bounds of energy that could have been generated at this step. See the energy_generator module for more details on energy generators, and their bounds.

equity

The equity of comforts between all agents in the grid, i.e., to which degree do they have a similar comfort. It is computed as a statistical indicator of dispersion named the Hoover index, which is a well-known tool in economy, originally made to describe income inequality. equity is computed as 1 - hoover(comforts), such that 0 represents a perfect inequality (one person has everything, the others nothing), and 1 a perfect equality (everybody has the same comfort).

energy_loss

The quantity of energy that was available to agents, but not used (i.e., neither consumed nor stored) at this time step.

autonomy

This measure represents the autonomy, or self-sustainability, of the smart grid. It is measured based on the transactions (i.e., selling or buying energy from and to the national grid), w.r.t. the total amount of energy exchanged within the grid (given, stored, consumed).

exclusion

The proportion of agents that have a comfort lower than half the median of agents’ comforts. Such agents are said to be excluded.

well_being

The median of all agents’ comfort. Using a median rather than an average reduces the impact of outliers.

over_consumption

The quantity of energy that agents have consumed, but was not originally available in the grid. We assume that the grid automatically bought this missing energy from the national grid. It is computed as the sum of energy consumed from the grid and stored from the grid, by all agents, minus the sum of energy given by all agents, and the energy initially available, divided by the sum of energy taken by all agents, to obtain a ratio between 0 and 1. If the measure is less than 0, we set it to 0.

__init__()

Methods

__init__()

compute(world)

Return the global observations computed from the World state.

count(value, /)

Return number of occurrences of value.

index(value[, start, stop])

Return first index of value.

reset()

Reset the counter of steps computed, i.e., the memoization.

Attributes

autonomy

Alias for field number 4

available_energy

Alias for field number 1

computed

Memoized global observations, computed at the time step indicated by last_step_compute.

energy_loss

Alias for field number 3

equity

Alias for field number 2

exclusion

Alias for field number 5

hour

Alias for field number 0

last_step_compute

Last time step at which global observations were computed.

over_consumption

Alias for field number 7

well_being

Alias for field number 6

_asdict()

Return a new dict which maps field names to their values.

classmethod _is_compute(world: World) bool[source]

Private method to know whether the current step has already been computed.

classmethod _make(iterable)

Make a new GlobalObservation object from a sequence or iterable

_replace(**kwds)

Return a new GlobalObservation object replacing specified fields with new values

autonomy

Alias for field number 4

available_energy

Alias for field number 1

classmethod compute(world: World)[source]

Return the global observations computed from the World state.

This method uses memoization through computed, _is_compute() and last_step_compute to avoid re-computing already known observations. In such cases, the cached instance is returned. Otherwise, measures are computed, and a new instance is created, memoized, and returned.

Parameters:

world (smartgrid.world.World) – The World for which we want to compute the global observations.

Return type:

GlobalObservation

computed = None

Memoized global observations, computed at the time step indicated by last_step_compute.

count(value, /)

Return number of occurrences of value.

energy_loss

Alias for field number 3

equity

Alias for field number 2

exclusion

Alias for field number 5

hour

Alias for field number 0

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

last_step_compute = -1

Last time step at which global observations were computed.

This is used to optimize the computations and avoid re-computing already known observations, since these are the same for all agents at a given time step.

over_consumption

Alias for field number 7

classmethod reset()[source]

Reset the counter of steps computed, i.e., the memoization.

well_being

Alias for field number 6