0001 function MakeFigure3(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 if nargin==0
0026 n=15;
0027 else
0028 n=varargin{1};
0029 end
0030
0031 fprintf('Loading/Generating the simulation results\n');
0032
0033 GenData=@()(TestRep('Test1','Figure2',1));
0034 Results=GetData('Results/Test1-Figure2-1.mat',GenData);
0035
0036
0037 P=Results.P;
0038
0039
0040 POMDP=Results.POMDP;
0041
0042
0043 Policy=Results.V{end};
0044
0045
0046 b=P.start;
0047
0048
0049 s=rand(b);
0050
0051 fprintf('SIMULATING\n');
0052 fprintf('INITIAL STATE %f\n',s);
0053
0054 h=clf;
0055 set(h,'name','C-POMDP Figure 3','numbertitle','off');
0056
0057 h=plot(b);
0058 xlabel('s');
0059 ylabel('p(s)')
0060 axis([-20 20 0 1]);
0061 hold on;
0062 rAll=0;
0063 gamma=get(POMDP,'gamma');
0064 g=1;
0065 for i=1:n
0066 fprintf('\nSTEP %u: ',i);
0067 a=OptimalAction(Policy,b);
0068 fprintf(' action: %u (',a);
0069 switch a
0070 case 1
0071 fprintf('Move-Left');
0072 case 2
0073 fprintf('Move-Right');
0074 case 3
0075 fprintf('Enter-Door');
0076 end
0077 [s b o r]=SimulationStep(POMDP,b,s,a);
0078 rAll=rAll+g*r;
0079 g=g*gamma;
0080 fprintf(') state:%f reward: %f ',s,r);
0081 delete(h);
0082 h=plot(b);
0083 fprintf('<press a key>');
0084 pause;
0085 end
0086 hold off
0087 fprintf('\n\nDiscounted reward: %f\n',rAll);
0088
0089
0090