MCPcopy Create free account
hub / github.com/ahalev/python-microgrid / append

Method append

src/pymgrid/microgrid/utils/step.py:13–31  ·  view source on GitHub ↗
(self, module_name, obs, reward, done, info)

Source from the content-addressed store, hash-verified

11 self._info = dict(absorbed_energy=[], provided_energy=[])
12
13 def append(self, module_name, obs, reward, done, info):
14 try:
15 self._obs[module_name].append(obs)
16 except KeyError:
17 self._obs[module_name] = [obs]
18 self._reward += reward
19 if done:
20 self._done = True
21
22 try:
23 self._info[module_name].append(info)
24 except KeyError:
25 self._info[module_name] = [info]
26
27 for key, value in info.items():
28 try:
29 self._info[key].append(value)
30 except KeyError:
31 pass
32
33 def balance(self, shape_reward=False):
34 provided_energy = np.sum(self._info['provided_energy'])

Callers 7

stepMethod · 0.95
get_subcontainersFunction · 0.45
deserialize_instanceMethod · 0.45
_get_module_containerMethod · 0.45
get_forecast_horizonMethod · 0.45
__len__Method · 0.45
deserialize_instanceMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected