Problems with reward generation in reinforcement learning simulation
조회 수: 11 (최근 30일)
이전 댓글 표시
Hi everyone,
I am currently running a reinforcement learning model, integrated with simevents blocks in simulink. I have both a reinforcement learning script and the RL agent present in the simulink. Currently my reward function works based on a matlab function block that is connected to the reward input of RL agent block. I am facing an issue of constant reward generated throughout the entire episodes of RL iteration. Any ideas why? Because I try to assign the reward function (code below) as simple as possible, extract values from the entities of simevents, to generate values that are supposed to be different with each iteration.
function r = w(u1, u2, u3) %#codegen
% Extract Entities
FH = u1 + 1;
Cost = u2 + 1;
Downtime = u3 + 1;
% Reward calculation based on values
r = (Downtime/Cost) * FH;
end
There seems to be a problem as well because this reward area is red, eventhough the simulation runs normally.
I uploaded my model and a screenshot of the RL training result of the reward. If you are interested to replicate my results here are the steps:
- Run script A.mlx to generate random number set A
- Run script B.mlx to generate random number set B
- Run MainScript.mlx to run the simulation
Thank you so much in advance! Let me know should you require any further information.
Best,
Aaron.
댓글 수: 0
답변 (1개)
Subhajyoti
2024년 9월 13일
It is my understanding that you are trying to train RL model, but the reward function is not updating as expected.
This is happening because the values of ‘FH’, ‘Cost’, and ‘Downtime’ are not being updated for the following iterations. For every episode, when the model is calling these values, it is taking the initial default value, generating the constant reward value.
To address this issue, you can either save the values to Workspace after each update or add a feedback loop to pass the updated values to the next iteration.
Refer to the following link for more information on ‘To Workspace’ block in Simulink:
Additionally, you can refer to the following resource to know more about ‘Reward and Observation Signals in Custom Environments’ in MATLAB:
참고 항목
카테고리
Help Center 및 File Exchange에서 Environments에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!