facebookresearch / mbrl-lib

Library for Model Based RL
MIT License
945 stars 154 forks source link

[Feature Request] More general reward #115

Open mkolodziejczyk-piap opened 3 years ago

mkolodziejczyk-piap commented 3 years ago

Hi, currently reward_fn is independent from environment class (mbrl.models.ModelEnv) and accepts as input actions and next observation. In practice more general, dependent on environment parameters reward functions are needed. For example,

My initial thought is to change reward_fn from external function to class function of ModelEnv and then we could use self.parameter of that class. I wonder if this is "safe" and doesn't mess with other features

Regards,

luisenp commented 3 years ago

Hi @mkolodziejczyk-piap. This is an interesting suggestion. Can you give a more concrete example to help me sketch out something?

As a starting point, in the current state of the code it should already be possible to use a reward_fn that is a class, as long as you implement a __call__ method with the same inputs (actions and next observation). This will allow you to keep some internal state, but depending on how you'd to use the ModelEnv you may need to have your own version of evaluate_action_sequences.

I'm happy to take a deeper look at this with more details in hand.