強化学習にて、学習中​のリワード以外の値の​推移をプロットする方​法

2 次查看(过去 30 天)
SHromaneko
SHromaneko 2023-8-30
回答: Shivansh 2023-9-7
強化学習の環境を製作しています。
強化学習マネージャでリワードの値の推移はエピソード毎に表示されますが、リワードにはシステムを安定に動かすための報酬をたくさん含めており、このシステムの純粋なパフォーマンスではありません。
このシステムの純粋なパフォーマンスをエピソード毎に、リワードとは別にプロットさせたいと思っています。
Bは計算時間
maxStepsはシミュレーションの終了時間
dataはシステムのパフォーマンス
xは前回値からエピソードの値を引き継いでいます。
MatlabFunctionにて、エピソードが完走する1STEP前にエピソードNodataの値をプロットし、一回目以降にhold onで重ねてプロットしようとしています。
MatlabFunctionでは2回目以降のプロットが重ねられずに最初の一回しか表示されません。
なにかいい方法ありますでしょうか?
function y = fcn(t,maxSteps,data,x)
t = round(t)
j = t == maxSteps-1;
if j
if x == 1
plot(x,data,"kx")
xlim([0 x+1])
ylim([0 2])
x = x + 1
else
hold on
plot(x,data,"kx")
xlim([0 x+1])
ylim([0 2])
hold off
x = x + 1
end
end
y = x

回答(1 个)

Shivansh
Shivansh 2023-9-7
Hi Shromaneko,
迅速に対応できるよう、この返信は英語で行われます。
I understand that you want to plot the values of episode number and data one step before the episode finishes. Currently, you can plot the first one without overlapping the second and subsequent plots. You can modify your current code by creating a new figure for the first episode and then using the hold on to plot the subsequent plots.
function y = fcn(t, maxSteps, data, x)
t = round(t);
j = t == maxSteps - 1;
if j
if x == 1
figure; % Create a new figure for the first episode
end
plot(x, data, 'kx');
xlim([0 x+1]);
ylim([0 2]);
hold on; % Enable hold on for subsequent plots
x = x + 1;
end
y = x;
end
By using the above code, you will be able to visualize the overlaid plots.
To learn more about 'figure', please refer to the following documentation Create figure window - MATLAB figure - MathWorks India.

类别

Help CenterFile Exchange 中查找有关 Training and Simulation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!