2%> This is the base
class for generating objects
3%> that contain the contents of a restart file
4%> generated by a ParaMonte sampler.<br>
7%> This
class is meant to be primarily internally
8%> used by the ParaMonte MATLAB library samplers.<br>
9%> See the documentation of the
class constructor.<br>
12%> See below
for information on the attributes (properties).<br>
15%> See below
for information on the methods.<br>
23%> \JoshuaOsborne, May 21 2024, 3:19 AM, University of Texas at Arlington<br>
24%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
25%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 properties(Access =
public)
34 %> The scalar MATLAB integer containing the number of
35 %> restart entries in the specified restart file.<br>
41 %> The scalar MATLAB integer containing the number of
42 %> dimensions of the domain of the objective function.<br>
48 %> The vector of MATLAB strings of size ``ndim`` containing
49 %> the domain axes names of the density function explored.<br>
55 %> The scalar MATLAB
string containing the entire
56 %> contents of the restart file with all Carriage Return
57 %> characters removed (relevant only to Windows OS).<br>
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 %> The ``Hidden`` scalar MATLAB
string component
69 %> containing the sampling method
name.<br>
72 %> This is an internal
class attribute that
73 %> is inaccessible to the end users.<br>
79 %> The ``Hidden`` scalar MATLAB
string array
80 %> containing the
list of all restart file lines.<br>
83 %> This is an internal
class attribute that
84 %> is inaccessible to the end users.<br>
90 %> The ``Hidden`` scalar MATLAB whole-number containing
91 %> the length of the
class component ``lineList``.<br>
94 %> This is an internal
class attribute that
95 %> is inaccessible to the end users.<br>
101 %> The ``Hidden`` scalar MATLAB whole-number component
102 %> containing the number of the lines parsed up a given
103 %> point in the internals of the
class methods.<br>
106 %> This is an internal
class attribute that
107 %> is inaccessible to the end users.<br>
109 ilast = 0; %
index that is always set to the last line number read.
112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 methods(Access =
public)
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 %> This is the constructor of the
class [pm.sampling.FileContentsRestart](@ref
FileContentsRestart).<br>
124 %> \param[in] file : The input scalar MATLAB
string containing the path to an external restart file.<br>
125 %> \param[in] silent : See the corresponding argument of [pm.io.FileContents](@ref
FileContents)
class.<br>
126 %> (**optional**. The
default is set by [pm.io.FileContents](@ref
FileContents).)
127 %> \param[in] method : The input scalar MATLAB
string containing the sampling method
name.<br>
128 %> The input value must be any of the following:<br>
130 %> <li> ``
"ParaDRAM"``
131 %> <li> ``
"ParaDISE"``
132 %> <li> ``
"ParaNest"``
134 %> (**optional**. If missing, some of the restart file contents will not be (properly) parsed.)
137 %> ``self`` : The output scalar
object of
class [pm.sampling.FileContentsRestart](@ref
FileContentsRestart).
143 %> contents = pm.sampling.FileContentsRestart(file, [])
144 %> contents = pm.sampling.FileContentsRestart(file, silent)
145 %> contents = pm.sampling.FileContentsRestart(file, [], [])
146 %> contents = pm.sampling.FileContentsRestart(file, silent, [])
147 %> contents = pm.sampling.FileContentsRestart(file, silent, method)
154 %> \JoshuaOsborne, May 21 2024, 3:25 AM, University of Texas at Arlington<br>
155 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
156 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
161 self = self@pm.io.FileContents(file, silent);
163 self.
method = convertStringsToChars(method);
167 %%%% remove any CARRIAGE RETURN.
170 self.contents = strrep(fileread(file),
char(13),
'');
171 self.lineList = strsplit(self.contents, newline);
172 self.lineListLen = length(self.lineList);
174 %
find the field names in the file.
176 %
for ilast = 1 : self.lineListLen
177 % line = self.lineList{ilast};
178 %
if isletter(line(1))
179 %
if ~any(contains(fields, line))
180 % fields = [fields, line];
188 %%%% Read restart meta data (ndim, domainAxisName).
191 %%%% This is the old DRAM-specific approach where we inferred the ndim value from the file contents.
195 %
while ~contains(self.lineList(rowOffset),
"proposalMean")
196 % rowOffset = rowOffset + 1;
197 %
if self.lineListLen < rowOffset
198 % error ( newline ...
199 % +
"Failed to detect any field named ""proposalMean""" + newline ...
200 % +
"in the specified restart file:" + newline ...
202 % + pm.io.tab + file + newline ...
204 % +
"The file structure may have been compromized." + newline ...
209 % rowOffset = rowOffset + 1; % the first numeric value of proposalMean.
210 %
while ~isnan(str2double(self.lineList{self.ndim + rowOffset}))
211 % self.ndim = self.ndim + 1;
214 % error ( newline ...
215 % +
"Failed to infer the value of ``ndim``." + newline ...
216 % +
"from the specified restart file:" + newline ...
218 % + pm.io.tab + file + newline ...
220 % +
"The file structure may have been compromized." + newline ...
225 %%%% This is the
new approach where the ndim value is explicitly written in the file along with domainAxisName.
227 if ~contains(self.lineList(1),
"ndim") || ~contains(self.lineList(3),
"domainAxisName")
229 + "The structure of the specified restart file appears to have been compromised:" + newline ...
231 + pm.io.
tab + file + newline ...
233 + "The first line of the restart file must match ""ndim""." + newline ...
234 + "The third line of the restart file must match ""domainAxisName""." + newline ...
238 self.ndim = str2double(self.lineList(2));
239 self.domainAxisName = strings(self.ndim, 1);
240 for idim = 1 : self.ndim
241 self.domainAxisName(idim) =
string(self.lineList(3 + idim));
245 self.ilast = 3 + self.ndim;
249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251 end % methods(Access = public)
253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared library directories.
function list()
Return a list of MATLAB strings containing the names of OS platforms supported by the ParaMonte MATLA...
function index(in array)
Given array(1 : n), return the array index indx(1 : n) such that array(indx) is in ascending order.
This is the base class for generating objects that contain the contents of a restart file generated b...
function FileContentsRestart(in file, in silent, in method)
Return a scalar object of class pm.sampling.FileContentsRestart.
This is the base class for generating objects that contain the contents of a given file.
function find(in vendor)
Return a list of scalar MATLAB strings containing the paths to all detected mpiexec binaries installe...
function tab()
Return a scalar MATLAB string containing 4 blank characters equivalent to a tab character.