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