Using time as a negative reward in RL toolbox
1 view (last 30 days)
Show older comments
I want to use RL toolbox to train a DQN agent. Right now, i'm using the related step_function to implement the reward function. The problem is I don't know how to punish the agent for taking too long to do the objective. How should I add time to my reward function in this toolbox? Your help is appreciated.
function [NextObs,Reward,IsDone,LoggedSignals] = WW6_StepFunction_genloss(Action,LoggedSignals)
a = Action;
obj=4;
d=[1 2];
state = LoggedSignals.State;
[next_state, ~, genloss]=attack_eff_WW6(state, a, d);
LoggedSignals.State = next_state;
NextObs = LoggedSignals.State;
Down=nnz(~next_state);
IsDone = Down==11;
Reward=genloss;
end
0 Comments
Answers (1)
Kartik Saxena
on 30 Nov 2023
Hi,
I understand that you want to add time penalty in the reward function to punish it for taking too long.
The example given below in the MathWorks documentation would be useful for this purpose:
You can refer to it and introduce penalty in your reward function by deducting from the reward as per your requirements, instead of adding '1'.
I hope this resolves your issue.
0 Comments
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!