SampleBeliefsPURPOSESamples a set of beliefs from a POMDP.
SYNOPSISfunction SB=SampleBeliefs(P,start,nBeliefs,minBeliefDist,stepsXtrial,minR,maxR)
DESCRIPTIONSamples a set of beliefs from a POMDP. Defines a set of 'nBeliefs' beliefs randomly simulating a POMDP. This function corresponds to that in line 2 of Table 2 in section 6 of the paper. The sampling of beliefs is organized in trials. Each trial starts from the given 'start' belief and evolves selecting actions and observations at radom. Actions are selected with uniform probability and observations from the corresponding observation model. Each trial is stopped after executing 'stepsXtrial' steps of when the received reward is outside the interval [minR, maxR]. Only beliefs that are further away more than 'minBelifDist' from any other already stored beliefs are considered. The sampling of beliefs can be quite slow and some information is printed while it proceeds. '.' Means a new belief has been added to the output. '*' Means a trial has ended. See also SimulationStep, @DBelief/distance, @GMixture/Distance, @PBelief/Distance. CROSS-REFERENCE INFORMATIONThis function calls:
SOURCE CODE0001 function SB=SampleBeliefs(P,start,nBeliefs,minBeliefDist,stepsXtrial,minR,maxR) 0002 % Samples a set of beliefs from a POMDP. 0003 % 0004 % Defines a set of 'nBeliefs' beliefs randomly simulating a POMDP. 0005 % This function corresponds to that in line 2 of Table 2 in section 6 of 0006 % the paper. 0007 % 0008 % The sampling of beliefs is organized in trials. Each trial starts from 0009 % the given 'start' belief and evolves selecting actions and observations 0010 % at radom. Actions are selected with uniform probability and 0011 % observations from the corresponding observation model. 0012 % Each trial is stopped after executing 'stepsXtrial' steps of when the 0013 % received reward is outside the interval [minR, maxR]. 0014 % 0015 % Only beliefs that are further away more than 'minBelifDist' from any 0016 % other already stored beliefs are considered. 0017 % 0018 % The sampling of beliefs can be quite slow and some information is 0019 % printed while it proceeds. 0020 % '.' Means a new belief has been added to the output. 0021 % '*' Means a trial has ended. 0022 % 0023 % See also SimulationStep, @DBelief/distance, @GMixture/Distance, 0024 % @PBelief/Distance. 0025 0026 rand('state',sum(100*clock)); 0027 0028 A=get(P,'ActionSpace'); 0029 S=get(P,'StateSpace'); 0030 0031 md=minBeliefDist+1; 0032 SB=cell(1,nBeliefs); 0033 k=0; 0034 r=maxR-1; 0035 while k<nBeliefs 0036 if (mod(k,stepsXtrial)==0) || (r>maxR) || (r<minR) 0037 b=start; 0038 s=Crop(S,rand(b)); 0039 0040 fprintf('*\n'); 0041 end 0042 a=rand(A); 0043 [s b o r]=SimulationStep(P,b,s,a); 0044 0045 if (k>1) && (minBeliefDist>0) 0046 md=min(cellfun(@(b1)(Distance(b,b1)),SB(1,k))); 0047 end 0048 if md>minBeliefDist 0049 k=k+1; 0050 SB{k}=b; 0051 0052 fprintf('.'); 0053 if mod(k,80)==0 0054 fprintf('\n'); 0055 end 0056 end 0057 end 0058 fprintf('\n'); 0059 |