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

Method step

src/pymgrid/envs/base/base.py:179–224  ·  view source on GitHub ↗

Run one timestep of the environment's dynamics. When the end of the episode is reached, you are responsible for calling `reset()` to reset the environment's state. Accepts an action and returns a tuple (observation, reward, done, info). Parameters

(self, action, normalized=True)

Source from the content-addressed store, hash-verified

177 return self._get_obs()
178
179 def step(self, action, normalized=True):
180 """
181 Run one timestep of the environment's dynamics.
182
183 When the end of the episode is reached, you are responsible for calling `reset()`
184 to reset the environment's state.
185
186 Accepts an action and returns a tuple (observation, reward, done, info).
187
188 Parameters
189 ----------
190 action : int or np.ndarray
191 An action provided by the agent.
192
193 normalized : bool, default True
194 Whether the passed action is normalized or not.
195
196 Returns
197 -------
198 observation : dict[str, list[float]] or np.ndarray, shape self.observation_space.shape
199 Observations of each module after using the passed ``action``.
200 ``observation`` is a nested dict if :attr:`~.flat_spaces` is True and a one-dimensional numpy array
201 otherwise.
202
203 reward : float
204 Reward/cost of running the microgrid. A positive value implies revenue while a negative
205 value is a cost.
206
207 done : bool
208 Whether the microgrid terminates.
209
210 info : dict
211 Additional information from this step.
212
213 """
214 self._microgrid_logger.log(net_load=self.compute_net_load())
215
216 action = self.convert_action(action)
217 self._log_action(action, normalized)
218
219 obs, reward, done, info = super().step(action, normalized=normalized)
220 obs = self._get_obs()
221
222 self.step_callback(**self._get_step_callback_info(action, obs, reward, done, info))
223
224 return obs, reward, done, info
225
226 @abstractmethod
227 def convert_action(self, action):

Callers

nothing calls this directly

Calls 6

compute_net_loadMethod · 0.95
convert_actionMethod · 0.95
_log_actionMethod · 0.95
_get_obsMethod · 0.95
logMethod · 0.45

Tested by

no test coverage detected