ccl_data_save(filename,D) Function for saving data in human-readable format files for LSTD(0)-Q learning problems. in: filename - filename D - data struct, containing .T - time .X - states .U - actions .Y - observed states .Xn - states after one time step .Un - actions after one time step (following policy) .Yn - observed states after one time step .V - value function at X .Q - Q value function at X,U
0001 function ccl_data_save(filename,D) 0002 % ccl_data_save(filename,D) 0003 % 0004 % Function for saving data in human-readable format files for LSTD(0)-Q learning problems. 0005 % 0006 % in: 0007 % filename - filename 0008 % D - data struct, containing 0009 % .T - time 0010 % .X - states 0011 % .U - actions 0012 % .Y - observed states 0013 % .Xn - states after one time step 0014 % .Un - actions after one time step (following policy) 0015 % .Yn - observed states after one time step 0016 % .V - value function at X 0017 % .Q - Q value function at X,U 0018 0019 0020 0021 0022 % CCL: A MATLAB library for Constraint Consistent Learning 0023 % Copyright (C) 2007 Matthew Howard 0024 % Contact: matthew.j.howard@kcl.ac.uk 0025 % 0026 % This library is free software; you can redistribute it and/or 0027 % modify it under the terms of the GNU Lesser General Public 0028 % License as published by the Free Software Foundation; either 0029 % version 2.1 of the License, or (at your option) any later version. 0030 % 0031 % This library is distributed in the hope that it will be useful, 0032 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0033 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0034 % Lesser General Public License for more details. 0035 % 0036 % You should have received a copy of the GNU Library General Public 0037 % License along with this library; if not, write to the Free 0038 % Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 0039 0040 fid = fopen([filename,'.dat'],'wt'); 0041 fprintf(fid,'N = %d\n',D.N); 0042 fprintf(fid,'dimX = %d\n',size(D.X,1)); 0043 fprintf(fid,'dimY = %d\n',size(D.Y,1)); 0044 fprintf(fid,'dimA1= %d\n',size(D.A,1)); 0045 for i=1:size(D.X,1),fprintf(fid,'X%d\t' ,i);end 0046 for i=1:size(D.Y,1),fprintf(fid,'Y%d\t' ,i);end 0047 for i=1:size(D.F,1),fprintf(fid,'F%d\t',i);end 0048 for i=1:size(D.A,1),for j=1:size(D.A,2),fprintf(fid,'A%d%d\t',i,j);end;end 0049 for i=1:size(D.P,1),for j=1:size(D.P,2),fprintf(fid,'P%d%d\t',i,j);end;end 0050 fprintf(fid,'\n'); 0051 fclose(fid); 0052 dlmwrite([filename,'.dat'],[D.X',D.Y',D.F',reshape(D.A,size(D.A,1)*size(D.A,2),size(D.A,3))',reshape(D.P,size(D.P,1)*size(D.P,2),size(D.P,3))'],'delimiter','\t','-append'); 0053