Problems with reward generation in reinforcement learning simulation
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Subhajyoti
le 13 Sep 2024
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:
Voir également
Catégories
En savoir plus sur Environments dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!