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>
11%> The attributes of
this class are considered
12%> internal implementation of the ParaMonte library.<br>
13%> As such, the
interface of this class may change over time.<br>
16%> See the documentation of the
class constructor.<br>
19%> See below
for information on the attributes (properties).<br>
22%> See below
for information on the methods.<br>
27%> \JoshuaOsborne, May 21 2024, 3:26 AM, University of Texas at Arlington<br>
28%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
29%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 properties(Access =
public)
36 %> ``meanAcceptanceRateSinceStart`` : The real-valued MATLAB array of rank ``1`` of
37 %> shape ``(1:self.count)`` containing the set of
38 %> average MCMC acceptance rates of the sampler proposal
39 %> distribution over the course of the simulation.<br>
41 meanAcceptanceRateSinceStart = [];
43 % ``proposalAdaptiveScaleSq`` : The real-valued MATLAB array of rank ``1`` of
44 % shape ``(1:self.count)`` containing the set of
45 % adaptive squared scale factors of the sampler proposal
46 % distribution over the course of the simulation.<br>
48 proposalAdaptiveScaleSq = [];
50 % ``proposalCor`` : The real-valued MATLAB array of rank ``3`` of
51 % shape ``(self.ndim, self.ndim, self.count)`` containing
52 % the set of correlation matrices of the proposal distribution
53 % of the sampler, representing the evolution of the proposal
54 % correlation matrix over the course of the simulation.<br>
58 % ``proposalCov`` : The real-valued MATLAB array of rank ``3`` of
59 % shape ``(1:self.ndim, 1:self.ndim, 1:self.count)`` containing
60 % the set of covariance matrices of the proposal distribution
61 % of the sampler, representing the evolution of the proposal
62 % covariance matrix over the course of the simulation.<br>
66 % ``proposalLogVolume`` : The real-valued MATLAB array of rank ``1`` of
67 % shape ``(1:self.count)`` containing the set of
68 % ``log(determinant(covmat))`` of the proposal distribution
69 % representing the evolution of mean of proposal distribution
70 % over the course of the simulation.<br>
72 proposalLogVolume = [];
74 % ``proposalMean`` : The real-valued MATLAB array of rank ``2`` of
75 % shape ``(1:self.ndim, 1:self.count)`` containing
76 % the set of mean vectors of the proposal distribution
77 % of the sampler, representing the evolution of the proposal
78 % mean over the course of the simulation.<br>
82 % ``uniqueStateVisitCount`` : The scalar MATLAB integer containing the number of
83 % states uniquely visited within the domain of the
84 % objective function up to the stage specified
85 % within the specified restart file.<br>
87 uniqueStateVisitCount = [];
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 methods(Access =
public)
98 %> This is the constructor of the
class [pm.sampling.FileContentsRestartDRAM](@ref
FileContentsRestartDRAM).<br>
100 %> \param[in] file : The input scalar MATLAB
string containing the path to an external report file.<br>
101 %> \param[in] silent : See the corresponding argument of [pm.sampling.FileContentsRestart](@ref
FileContentsRestart)
class.<br>
102 %> (**optional**. The
default is set by [pm.sampling.FileContentsRestart](@ref
FileContentsRestart).)
105 %> ``self`` : The output scalar
object of
class [pm.sampling.FileContentsRestartDRAM](@ref
FileContentsRestartDRAM).<br>
111 %> contents = pm.sampling.FileContentsRestartDRAM(file, [])
112 %> contents = pm.sampling.FileContentsRestartDRAM(file, silent)
113 %> contents = pm.sampling.FileContentsRestartDRAM(file, [], [])
114 %> contents = pm.sampling.FileContentsRestartDRAM(file, silent, [])
115 %> contents = pm.sampling.FileContentsRestartDRAM(file, silent, method)
122 %> \JoshuaOsborne, May 21 2024, 3:31 AM, University of Texas at Arlington<br>
123 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
124 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
129 self = self@pm.sampling.FileContentsRestart(file, silent,
"ParaDRAM");
132 %%%%
find the update count in the file.
135 self.count = count(self.contents,
'uniqueStateVisitCount');
138 %%%% Parse the restart file contents.
141 cholupp = zeros(self.ndim, self.ndim);
142 self.meanAcceptanceRateSinceStart = zeros(self.count, 1);
143 self.proposalAdaptiveScaleSq = zeros(self.count, 1);
144 self.proposalLogVolume = zeros(self.count, 1);
145 self.proposalMean = zeros(self.ndim, self.count);
146 self.proposalCov = zeros(self.ndim, self.ndim, self.count);
147 self.proposalCor = zeros(self.ndim, self.ndim, self.count);
148 self.uniqueStateVisitCount = zeros(self.count, 1);
149 skip = 10 + self.ndim * (self.ndim + 3) / 2;
153 while istart < length(self.lineList) - skip
155 if ~strcmp(self.lineList{self.ilast + istart}, self.lineList{self.ilast + istart + 2})
157 if ~self.silent && mod(icount, 10) == 0
158 self.spinner.spin(icount / self.count);
160 self.meanAcceptanceRateSinceStart (icount) = str2double(self.lineList(self.ilast + istart + 1));
161 self.uniqueStateVisitCount (icount) = str2double(self.lineList(self.ilast + istart + 3));
162 self.proposalAdaptiveScaleSq (icount) = str2double(self.lineList(self.ilast + istart + 5));
163 self.proposalLogVolume (icount) = str2double(self.lineList(self.ilast + istart + 7));
165 iend = istart + self.ndim;
166 self.proposalMean(1 : self.ndim, icount) = str2double(self.lineList(self.ilast + istart : self.ilast + iend - 1));
167 for idim = 1 : self.ndim % covmat
170 cholupp(1 : idim, idim) = str2double(self.lineList(self.ilast + istart : self.ilast + iend)); % This is the upper Cholesky.
172 self.proposalCov(:, :, icount) = cholupp' * cholupp;
181 %%%% Ensure the instrinc ``corrcov`` is installed.
186 for icount = 1 : size(self.proposalCov, 3)
187 self.proposalCor(:, :, icount) = corrcov(squeeze(self.proposalCov(:, :, icount)));
192 self.proposalCor = self.proposalCov;
193 warning ( newline ...
194 +
string(me.identifier) + " : " +
string(me.message) + newline ...
195 + "The component ``proposalCor`` will be set to the same values as the component ``proposalCov``." + newline ...
202 self.spinner.spin(1);
208 end % methods(Access = public)
210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
212 methods(Access = public, Hidden)
216 warning ( newline ...
217 + "The structure of the file:" + newline ...
219 + pm.io.
tab + self.file + newline ...
221 + "does not match a DRAM-class restart file." + newline ...
222 + "The contents of the file may have been compromised." + newline ...
223 + "Verify the integrity of the file contents before attempting a reread." + newline ...
228 end % methods(Access = Hidden)
230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This is the base class for generating objects that contain the contents of a restart file generated b...
function FileContentsRestartDRAM(in file, in silent)
Return a scalar object of class pm.sampling.FileContentsRestartDRAM.
Property proposalAdaptiveScaleSq
Property uniqueStateVisitCount
Property proposalLogVolume
Property meanAcceptanceRateSinceStart
This is the base class for generating objects that contain the contents of a restart file generated b...
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.