I am implementing multiple RL agents which share a lot of common attributes and methods but differ in only one. Namely the one that calculates the td_error. Out of the top of my head I can think of 3 options to implement this:
- Use an Agent abstract class (ABCMeta) and let the subclasses each implement all their methods.
- Use a normal base class Agent, implement all the common methods and just do
pass
on the one that is specific to each subclass. - Use just one class Agent and use an attribute to specify the type of td_error to calculate and then just use
if else
to achieve the specific behavior.
Here is what I don't like about each option:
- I would need to repeat myself when implementing the common methods in each subclass.
- It would be possible to create instances of the base class Agent but it wouldn't work since the specific function is not defined.
- It is ugly and seems very naive.
I have been presented with this situation before and I normally go with option 2. but I am pretty sure there is a more correct way of achieving this.
Aucun commentaire:
Enregistrer un commentaire