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 properties(Access =
public)
30 %> ``count`` : The scalar MATLAB integer containing the number of
31 %> restart entries in the specified restart file.<br>
35 %> ``ndim`` : The scalar MATLAB integer containing the number of
36 %> dimensions of the domain of the objective function.<br>
40 %> ``domainAxisName`` : The vector of MATLAB strings of size ``ndim`` containing
41 %> the domain axes names of the density function explored.<br>
45 %> ``contents`` : The scalar MATLAB
string containing the entire
46 %> contents of the restart file with all Carriage Return
47 %> characters removed (relevant only to Windows OS).<br>
56 ilast = 0; %
index that is always set to the last line number read.
59 methods(Access =
public)
65 %> This is the constructor of the
class [pm.sampling.FileContentsRestart](@ref
FileContentsRestart).<br>
67 %> \param[in] file : The input scalar MATLAB
string containing the path to an external restart file.<br>
68 %> \param[in] silent : See the corresponding argument of [pm.io.FileContents](@ref
FileContents)
class.<br>
69 %> (**optional**. The
default is set by [pm.io.FileContents](@ref
FileContents).)
70 %> \param[in] method : The input scalar MATLAB
string containing the sampling method
name.<br>
71 %> The input value must be any of the following:<br>
73 %> <li> ``
"ParaDRAM"``
74 %> <li> ``
"ParaDISE"``
75 %> <li> ``
"ParaNest"``
77 %> (**optional**. If missing, some of the restart file contents will not be (properly) parsed.)
80 %> ``self`` : The output scalar
object of
class [pm.sampling.FileContentsRestart](@ref
FileContentsRestart).
86 %> contents = pm.sampling.FileContentsRestart(file, [])
87 %> contents = pm.sampling.FileContentsRestart(file, silent)
88 %> contents = pm.sampling.FileContentsRestart(file, [], [])
89 %> contents = pm.sampling.FileContentsRestart(file, silent, [])
90 %> contents = pm.sampling.FileContentsRestart(file, silent, method)
97 %> \JoshuaOsborne, May 21 2024, 3:25 AM, University of Texas at Arlington<br>
98 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
99 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
104 self = self@pm.io.FileContents(file, silent);
106 self.
method = convertStringsToChars(method);
110 %%%% remove any CARRIAGE RETURN.
113 self.contents = strrep(fileread(file),
char(13),
'');
114 self.lineList = strsplit(self.contents, newline);
115 self.lineListLen = length(self.lineList);
117 %
find the field names in the file.
119 %
for ilast = 1 : self.lineListLen
120 % line = self.lineList{ilast};
121 %
if isletter(line(1))
122 %
if ~any(contains(fields, line))
123 % fields = [fields, line];
131 %%%% Read restart meta data (ndim, domainAxisName).
134 %%%% This is the old DRAM-specific approach where we inferred the ndim value from the file contents.
138 %
while ~contains(self.lineList(rowOffset),
"proposalMean")
139 % rowOffset = rowOffset + 1;
140 %
if self.lineListLen < rowOffset
141 % error ( newline ...
142 % +
"Failed to detect any field named ""proposalMean""" + newline ...
143 % +
"in the specified restart file:" + newline ...
145 % + pm.io.tab + file + newline ...
147 % +
"The file structure may have been compromized." + newline ...
152 % rowOffset = rowOffset + 1; % the first numeric value of proposalMean.
153 %
while ~isnan(str2double(self.lineList{self.ndim + rowOffset}))
154 % self.ndim = self.ndim + 1;
157 % error ( newline ...
158 % +
"Failed to infer the value of ``ndim``." + newline ...
159 % +
"from the specified restart file:" + newline ...
161 % + pm.io.tab + file + newline ...
163 % +
"The file structure may have been compromized." + newline ...
168 %%%% This is the
new approach where the ndim value is explicitly written in the file along with domainAxisName.
170 if ~contains(self.lineList(1),
"ndim") || ~contains(self.lineList(3),
"domainAxisName")
172 + "The structure of the specified restart file appears to have been compromised:" + newline ...
174 + pm.io.
tab + file + newline ...
176 + "The first line of the restart file must match ""ndim""." + newline ...
177 + "The third line of the restart file must match ""domainAxisName""." + newline ...
181 self.ndim = str2double(self.lineList(2));
182 self.domainAxisName = strings(self.ndim, 1);
183 for idim = 1 : self.ndim
184 self.domainAxisName(idim) =
string(self.lineList(3 + idim));
188 self.ilast = 3 + self.ndim;
192 end % methods(Access = public)
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared libraries.
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.