IBM / rl-testbed-for-energyplus

Reinforcement Learning Testbed for Power Consumption Optimization using EnergyPlus
MIT License
189 stars 77 forks source link

How to modify the number of game steps in each cycle? #116

Open luckypipitao opened 12 months ago

luckypipitao commented 12 months ago

Hi! I can only force the environment to stop at the desired number of steps by stopping it outside the environment. for example:

for b in range(num_timesteps):
            train_num +=1
            # a = env.action_space.sample()
            action,_ = agent.take_action(state)
            print(action)
            next_state, reward, done, truncated = env.step(action)
            # state, action, reward, done
            episode_return += reward
            data_save.add(state,action,reward,done)
            # state, action, reward, next_state, done
            replay_buffer.add(state, action, reward, next_state, done)
            state = next_state
            if replay_buffer.size() > minimal_size:
                b_s, b_a, b_r, b_ns, b_d = replay_buffer.sample(batch_size)
                transition_dict = {
                        'states': b_s,
                        'actions': b_a,
                        'next_states': b_ns,
                        'rewards': b_r,
                        'dones': b_d
                        }

                agent.update(transition_dict)

i used num_timesteps to control the number of steps I want to modify the steps from the environment. What parameters should I modify?

I sincerely hope to receive help. Thanks

antoine-galataud commented 12 months ago

Hi @luckypipitao. If I understand you want to control the number of steps per episode, or episode length. By default the episode length equals to the number of hours in the simulation run period multiplied by the number of time steps per hour.

You have several solutions: