'AttributeError: 'list' object has no attribute 'i_sd'Which function can be used to get values from a Callback Class
The callback is called when specific events occur in an environment (e.g. at the beginning/end of a reset and beginning/end of a step). I have written a stub of a GEM-Callback and added it to the environment. That can be utilized to log data at every step.
Now, which function can be called to get data from that class in List Format / .CSV Format.
Code of callback class is attached below:
class CurrentLoggingCallback(gem.core.Callback):
def __init__(self):
super().__init__ ()
self._i_sd_idx = None
self._i_sq_idx = None
self._i_sd_max = None
self._i_sq_max = None
def set_env(self, env):
super().set_env(env)
assert 'i_sd'in env.state_names, 'the environment has no state "i_sd".'
assert 'i_sq'in env.state_names, 'the environment has no state "i_sq".'
self._i_sd_idx = env.state_names.index('i_sd')
self._i_sq_idx = env.state_names.index('i_sq')
#Environments Observations are normalized by their limits.
#for current values in Amperes, the observations have to be multiplied with their limits.
self._i_sd_max = env.limits[self._i_sd_idx]
self._i_sq_max = env.limits[self._i_sq_idx]
def on_step_end(self, k, state, reference, reward, done):
""" Gets called at the end of each step"""
i_sd = state[self._i_sd_idx] * self._i_sd_max
i_sq = state[self._i_sq_idx] * self._i_sq_max
i_sd_ref = reference[self._i_sd_idx] * self._i_sd_max
i_sq_ref = reference[self._i_sq_idx] * self._i_sq_max
# Append to list or store to file...
def on_reset_end(self, state, reference):
"""Gets called at the end of each reset """
i_sd = state[self._i_sd_idx] * self._i_sd_max
i_sq = state[self._i_sq_idx] * self._i_sq_max
i_sd_ref = reference[self._i_sd_idx] * self._i_sd_max
i_sq_ref = reference[self._i_sq_idx] * self._i_sq_max
# Append to list or store to file...
current_logger = CurrentLoggingCallback()
Now, i want to log values of i_sd and i_sq in list/.CSV .
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
