-
Notifications
You must be signed in to change notification settings - Fork 1
/
pltConvergence.m
64 lines (57 loc) · 1.95 KB
/
pltConvergence.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function pltConvergence(HA,nr,nc,S,nW,gamma,alpha,epsilon,lambda,tlp,sFile)
% Convergence plot
% -------------------------------------------------------------------------
%
% Function :
% pltConvergence(HA)
%
% Inputs :
% HA - Agent action log
%
% -------------------------------------------------------------------------
% Author : P.C. Luteijn
% email : [email protected]
% Date : July 2017
% Comment : Plots the agent convergence to the optimal policy in terms of
% number of episodes and iteration steps.
% -------------------------------------------------------------------------
% Itterations & minumum itteration per episode progression
for i = 1:length(HA)
T(i) = HA(i).T;
minT(i) = HA(i).minT;
end
% Maximum iterations
maxT = max(T);
% Process information
strMaze = sprintf('%ix%i',nr,nc);
strProcess = sprintf([ ...
'Maze : %10s\n', ...
'Seed : %10i\n', ...
'Wall : %10i\n', ...
'gamma : %10.2f\n', ...
'alpha : %10.2f\n', ...
'epsilon : %10.2f\n', ...
'lambda : %10.2f\n', ...
'tlp : %10i\n', ...
'MaxItt : %10i'], ...
strMaze,S,nW,gamma,alpha,epsilon,lambda,tlp,maxT);
% Plot figure
figure('Name','Convergence')
plot(1:length(T),T,1:length(minT),minT,'r--'), grid on
xlabel('episodes [-]'), ylabel('iterations [-]')
ylim([0,1.05*max(T)])
% Add textbox
axPos = get(gca,'Position');
xx = 1.5*axPos(1) + axPos(3);
yy = 1.5*axPos(2) + axPos(4);
text(xx,yy,strProcess, ...
'Units', 'Normalized', ...
'HorizontalAlignment', 'Right', ...
'VerticalAlignment', 'Top', ...
'FontName','FixedWidth')
% Save file
if exist('sFile','var')
strSave = [ '../Report/figures/' sFile '.png' ];
saveas(gcf,strSave)
end
end