GetPOMDPSolutionStatistics
PURPOSE 
Collects statistics with the outcome of an experiment.
SYNOPSIS 
function [tics aV aR nA nC]=GetPOMDPSolutionStatistics(POMDP,P,B,V,Alpha,time,maxTime,stTime)
DESCRIPTION 
CROSS-REFERENCE INFORMATION 
This function calls:
- MaxAlpha Returns the maximizing alpha-element for a belief.
- size Returns the size of a policy.
- get Get for GBeliefs.
- get Get function for the GMixture object.
- get Gaussian object get function.
- get Get function for CS_CO_CA_POMDPs.
- get Get function for CS_CO_DA_POMDPs.
- get Get function for CS_CO_POMDPs.
- get Get function for CS_DO_CA_POMDPs.
- get Get function for CS_DO_DA_POMDPs.
- get Get function for CS_POMDPs.
- get Get function for DS_CO_CA_POMDPs.
- get Get function for DS_CO_DA_POMDPs.
- get Get function for DS_DO_CA_POMDPs.
- get Get function for DS_DO_DA_POMDPs.
- POMDP POMDP constructor.
- SimulateFrom Simulates a POMDP from a given belief.
- get Get functio for POMDPs.
This function is called by:
- TestRep Executes many times of Perseus on a given problem.
SOURCE CODE 
0001 function [tics aV aR nA nC]=GetPOMDPSolutionStatistics(POMDP,P,B,V,Alpha,time,maxTime,stTime)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 nSteps=floor(maxTime/stTime);
0027 tics=(0:(nSteps-1))*stTime;
0028
0029 aV=zeros(1,nSteps);
0030 aR=zeros(1,nSteps);
0031 nA=zeros(1,nSteps);
0032 nC=zeros(1,nSteps);
0033
0034
0035
0036 h=ones(1,nSteps);
0037 j=1;
0038 for i=2:nSteps
0039 while time(j)<tics(i)
0040 j=j+1;
0041 end
0042 h(i)=j-1;
0043 end
0044
0045
0046 nb=size(B,2);
0047
0048 fprintf(' Computing average expected value :');
0049 for n=1:nSteps
0050 fprintf('.');
0051 if (n==1)||(h(n)~=h(n-1))
0052 [Aph Vl]=cellfun(@(b)(MaxAlpha(V{h(n)},b)),B);
0053 aV(n)=sum(Vl)/nb;
0054 else
0055 aV(n)=aV(n-1);
0056 end
0057 end
0058 fprintf('\n');
0059
0060 fprintf(' Computing average discounted reward:');
0061 for n=1:nSteps
0062 fprintf('.');
0063 if (n==1)||(h(n)~=h(n-1))
0064 r=0.0;
0065 for i=1:P.numTrials
0066 r1=SimulateFrom(POMDP,V{h(n)},P.start,P.stepsXtrial);
0067 r=r+r1;
0068 end
0069 aR(n)=r/P.numTrials;
0070 else
0071 aR(n)=aR(n-1);
0072 end
0073 end
0074 fprintf('\n');
0075
0076 fprintf(' Getting number of alpha elements:\n');
0077 for n=1:nSteps
0078 nA(n)=size(V{h(n)});
0079 end
0080
0081 fprintf(' Getting number of policy changes:\n');
0082 discreteA=isa(get(POMDP,'ActionSpace'),'DSpace');
0083 nC(1)=1;
0084 for n=2:nSteps
0085 l=h(n-1);
0086 s=h(n);
0087 for i=1:nb
0088 [e1 a1]=V{l}{Alpha{l}(i)};
0089 [e2 a2]=V{s}{Alpha{s}(i)};
0090 if discreteA
0091 nC(n)=nC(n)+(a1~=a2);
0092 else
0093 nC(n)=nC(n)+norm(a1-a2);
0094 end
0095 end
0096 nC(n)=nC(n)/nb;
0097 end
0098
0099
|