IBM / rl-testbed-for-energyplus

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

enviroment problem #120

Open paradox-jiatong opened 4 weeks ago

paradox-jiatong commented 4 weeks ago

Hello, I have a problem about environment. I installed ray, based on pip3 install -r requirements/ray.txt But I get the following AttributeError: module 'numpy' has no attribute 'bool'. If I change the version of numpy I get the incompatibility error again. Specifically as follows: (RolloutWorker pid=6470) Opening file /tmp/extctrl_6470_act timed out (RolloutWorker pid=6470) EnergyPlusEnv.step(): Failed to send an action. Quitting. (RolloutWorker pid=6470) EnergyPlusEnv: (quit) (RolloutWorker pid=6470) /root/miniconda3/lib/python3.8/site-packages/ray/rllib/utils/prechecks/env.py:375: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar. (This may have returned Python scalars in past versions. (RolloutWorker pid=6470) elif not isinstance(done, (bool, np.bool, np.bool)): (RolloutWorker pid=6470) 2024-10-29 16:30:45,379 ERROR worker.py:449 -- Exception raised in creation task: The actor died because of an error raised in its creation task, ray::RolloutWorker.init() (pid=6470, ip=172.17.0.4, repr=<ray.rllib.evaluation.rollout_worker.RolloutWorker object at 0x7fd4d84d2f70>) (RolloutWorker pid=6470) File "/root/miniconda3/lib/python3.8/site-packages/ray/rllib/evaluation/rollout_worker.py", line 507, in init (RolloutWorker pid=6470) check_env(self.env) (RolloutWorker pid=6470) File "/root/miniconda3/lib/python3.8/site-packages/ray/rllib/utils/pre_checks/env.py", line 65, in check_env (RolloutWorker pid=6470) check_gym_environments(env) (RolloutWorker pid=6470) File "/root/miniconda3/lib/python3.8/site-packages/ray/rllib/utils/pre_checks/env.py", line 178, in check_gym_environments (RolloutWorker pid=6470) _check_done(done) (RolloutWorker pid=6470) File "/root/miniconda3/lib/python3.8/site-packages/ray/rllib/utils/pre_checks/env.py", line 375, in _checkdone (RolloutWorker pid=6470) elif not isinstance(done, (bool, np.bool, np.bool)): (RolloutWorker pid=6470) File "/root/miniconda3/lib/python3.8/site-packages/numpy/init.py", line 284, in getattr (RolloutWorker pid=6470) raise AttributeError("module {!r} has no attribute " (RolloutWorker pid=6470) AttributeError: module 'numpy' has no attribute 'bool'

Thank you very much!

antoine-galataud commented 3 weeks ago

Hi @paradox-jiatong. Thanks for reporting this issue. Have you tried downgrading numpy to 1.23.1 (current version is 1.24.1 in requirements/ray.txt)?

paradox-ljt123 commented 3 weeks ago

Let me try! Thank you!

paradox-ljt123 commented 2 weeks ago

Hello, I have resolved the issue with the environment, but I am encountering a problem when trying to save the training data. The collected_data is [], and I’m not sure why. Could you please help me review the issue? I would greatly appreciate your assistance.

def custom_callback(lcl, _glb):
    global collected_data

    ob = lcl.get('ob', None)                    
    action = lcl.get('ac', None)                
    reward = lcl.get('rew', None)               
    done = lcl.get('done', None)                
    next_ob = lcl.get('next_ob', None)          

    if ob is not None and action is not None and reward is not None and next_ob is not None:
        collected_data.append({
            "observation": ob,
            "action": action,
            "reward": reward,
            "next_observation": next_ob,
            "done": done
        })

    if len(collected_data) % 1000 == 0:
        print(f"Saving collected data ({len(collected_data)} entries)...")
        save_data(collected_data, filename="collected_data.pkl")

    return True