intelligent-environments-lab / CityLearn

Official reinforcement learning environment for demand response and load shaping
MIT License
468 stars 171 forks source link

Question: Mapping discrete actions to continuous space #98

Closed KandBM closed 8 months ago

KandBM commented 9 months ago

I've trained a PPO using 20 discrete actions (controlling electrical SOC) and I'm trying to explain what each action does, is there a way to map them back to the continuous space from [-1.0, 1.0]? I'm assuming 0 is a full charge and equivalent to 1.0, and 19 to -1.0, but how could I map out the intermediate values?

Thanks!

kingsleynweye commented 8 months ago

@KandBM, you can create your own custom wrapper that helps you with the mapping. The idea behind wrappers in explained in the Gym docs.

Alternatively, you may be able to use the in-built DiscreteObservationWrapper and DiscreteActionWrapper wrappers. You can also use the DiscreteSpaceWrapper wrapper that combines the two. These wrappers were written for the purpose of being able to use a Tabular Q-Learning agent in the environment but might work for your PPO implementation. If you want to see an example of how they are used, see the An Introduction to Tabular Q-Learning Algorithm as an Adaptive Controller section of the tutorial notebook.

Some things to note when using our current implementation of discretizing spaces: