smartgrid.observation.local_observation.LocalObservation

class smartgrid.observation.local_observation.LocalObservation(personal_storage, comfort, payoff)[source]

Bases: LocalObservation

Observations that are local (individual) to a single Agent.

These observations are not shared with other agents, and contain the following measures:

personal_storage

The amount of energy currently available in the Agent’s personal battery. This amount is represented as a ratio between 0 (empty) and 1 (full), w.r.t. the Agent’s battery capacity. See Agent.storage_ratio for details.

comfort

This represents to which degree the agent satisfied its need by consuming energy. Intuitively, the more an agent’s consumption is close to its need, the closer the comfort will be to 1. Conversely, if an agent does not consume, its comfort will tend towards 0. Comfort is computed through the Agent’s comfort function; we describe several examples in the comfort module, which rely on generalized logistic curves (similar to a sigmoid).

payoff

The agent’s current amount of money. Money can be won by selling energy from the personal battery to the national grid, or lost by buying money from the national grid to the personal battery. The payoff observation is interpolated from the agent’s real payoff and the payoff range to obtain a value between 0 (a loss) and 1 (a win), with 0.5 being the neutral value (neither win nor loss).

__init__()

Methods

__init__()

compute(world, agent)

Return local observations for a single agent.

count(value, /)

Return number of occurrences of value.

index(value[, start, stop])

Return first index of value.

reset()

Reset the LocalObservation class.

Attributes

comfort

Alias for field number 1

payoff

Alias for field number 2

personal_storage

Alias for field number 0

_asdict()

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

classmethod _make(iterable)

Make a new LocalObservation object from a sequence or iterable

_replace(**kwds)

Return a new LocalObservation object replacing specified fields with new values

comfort

Alias for field number 1

classmethod compute(world: World, agent: Agent)[source]

Return local observations for a single agent.

This function extracts the relevant measures from an Agent. Most of the computing has already been done in the Agent.update() and Agent.handle_action() methods.

Parameters:
  • world – The World in which the Agent is contained, for eventual data stored outside the agent.

  • agent – The Agent for which we want to compute the local observations.

Return type:

LocalObservation

count(value, /)

Return number of occurrences of value.

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

Return first index of value.

Raises ValueError if the value is not present.

payoff

Alias for field number 2

personal_storage

Alias for field number 0

classmethod reset()[source]

Reset the LocalObservation class.

This method currently does nothing but is implemented to mirror the behaviour of GlobalObservation, and to allow extensions to use complex mechanisms that require a reset.