Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Impact of Reward Calculators State Collection #45

Open
dvanbrug opened this issue May 29, 2024 · 0 comments · May be fixed by #46
Open

Performance Impact of Reward Calculators State Collection #45

dvanbrug opened this issue May 29, 2024 · 0 comments · May be fixed by #46
Assignees

Comments

@dvanbrug
Copy link

By default, the RewardCalculator class will collect the current true state of the environment to pass on to each reward calculator subclass.

def calculate_simulation_reward(self, env_controller):
"""Calculates the reward from the environment controller"""
current_state = env_controller._filter_obs(env_controller.get_true_state(env_controller.INFO_DICT['True'])).data
action = env_controller.action
agent_observations = env_controller.observation
done = env_controller.done
return self.calculate_reward(current_state, action, agent_observations, done, env_controller.state)

However, neither BlueRewardMachine nor EmptyRewardCalculator use this state as part of their calculate_reward methods. Additionally, the collection of this state is very time consuming, taking up 40-60% of the time associated with stepping through the environment.

If both RewardCalculator subclasses remove this current state collection, performance of the environment is improved dramatically. For example, stepping through 500 steps goes from 12s down to 4s.

@dvanbrug dvanbrug linked a pull request May 29, 2024 that will close this issue
@MitchellKiely MitchellKiely self-assigned this May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants