PlumeAndrew / MADDPG-LSTM-in-EV-charge-scheduling

This is a repo for my Bachelor's dissertation, a topic about using Reinforcement Learning to solve EV charge Scheduling question.
13 stars 3 forks source link

reward function problem #2

Open oracleqwe opened 5 months ago

oracleqwe commented 5 months ago

Hello, when I run your code. but there are some prolem. First. Could you please your requirements.txt 1 SourceChangeWarning: source code of class 'torch.nn.modules.linear.Linear' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning)

Second. "MADDPG\buffer.py", line 57, in store_transition self.reward_memory[index] = reward ValueError: setting an array element with a sequence. The requested array would exceed the maximum number of dimension of 1." I tried many methods but didn't solve this problem.

Thanks for your help.

samohammadi commented 4 months ago

Hello Were you able to solve the dimension problem? Thank you for helping me.

springjunhe commented 1 week ago
    converted_reward = []
    for item in reward:
        if isinstance(item, np.ndarray):
            converted_reward.append(item.item())  
        else:
            converted_reward.append(item)
    # self.reward_memory[index] = reward
    self.reward_memory[index] = converted_reward 

After fixed, meet the problem as follow: line 744, in _engine_run_backward return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: Found dtype Float but expected Double