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``
38 %> The real-valued MATLAB array of rank ``1`` of
39 %> shape ``(1:self.count)`` containing the set of
40 %> average MCMC acceptance rates of the sampler proposal
41 %> distribution over the course of the simulation.<br>
43 meanAcceptanceRateSinceStart = [];
45 %> ``proposalAdaptiveScaleSq``
47 %> The real-valued MATLAB array of rank ``1`` of
48 %> shape ``(1:self.count)`` containing the set of
49 %> adaptive squared scale factors of the sampler proposal
50 %> distribution over the course of the simulation.<br>
52 proposalAdaptiveScaleSq = [];
56 %> The real-valued MATLAB array of rank ``3`` of
57 %> shape ``(self.ndim, self.ndim, self.count)`` containing
58 %> the set of correlation matrices of the proposal distribution
59 %> of the sampler, representing the evolution of the proposal
60 %> correlation matrix over the course of the simulation.<br>
66 %> The real-valued MATLAB array of rank ``3`` of
67 %> shape ``(1:self.ndim, 1:self.ndim, 1:self.count)`` containing
68 %> the set of covariance matrices of the proposal distribution
69 %> of the sampler, representing the evolution of the proposal
70 %> covariance matrix over the course of the simulation.<br>
74 %> ``proposalCovLogVol``
76 %> The real-valued MATLAB array of rank ``1`` of
77 %> shape ``(1:self.count)`` containing the set of
78 %> ``log(determinant(covmat))`` of the proposal distribution
79 %> representing the evolution of mean of proposal distribution
80 %> over the course of the simulation.<br>
82 proposalCovLogVol = [];
86 %> The real-valued MATLAB array of rank ``2`` of
87 %> shape ``(1:self.ndim, 1:self.count)`` containing
88 %> the set of mean vectors of the proposal distribution
89 %> of the sampler, representing the evolution of the proposal
90 %> mean over the course of the simulation.<br>
94 %> ``uniqueStateVisitCount``
96 %> The scalar MATLAB integer containing the number of
97 %> states uniquely visited within the domain of the
98 %> objective function up to the stage specified
99 %> within the specified restart file.<br>
101 uniqueStateVisitCount = [];
105 %> The scalar MATLAB ``
struct`` containing the set of
106 %> predefined visualizations
for the restart data.<br>
111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
113 methods(Access =
public)
119 %> This is the constructor of the
class [pm.sampling.FileContentsRestartDRAM](@ref
FileContentsRestartDRAM).<br>
121 %> \param[in] file : The input scalar MATLAB
string containing the path to an external report file.<br>
122 %> \param[in] silent : See the corresponding argument of [pm.sampling.FileContentsRestart](@ref
FileContentsRestart)
class.<br>
123 %> (**optional**. The
default is set by [pm.sampling.FileContentsRestart](@ref
FileContentsRestart).)
126 %> ``self`` : The output scalar
object of
class [pm.sampling.FileContentsRestartDRAM](@ref
FileContentsRestartDRAM).<br>
132 %> contents = pm.sampling.FileContentsRestartDRAM(file, [])
133 %> contents = pm.sampling.FileContentsRestartDRAM(file, silent)
156 %> \JoshuaOsborne, May 21 2024, 3:31 AM, University of Texas at Arlington<br>
157 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
158 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
165 self = self@pm.sampling.FileContentsRestart(file, silent,
"ParaDRAM");
168 %%%% Find the update count in the file.
171 self.count = count(self.contents,
'uniqueStateVisitCount');
174 %%%% Parse the restart file contents.
177 cholupp = zeros(self.ndim, self.ndim);
178 self.meanAcceptanceRateSinceStart = zeros(self.count, 1);
179 self.proposalAdaptiveScaleSq = zeros(self.count, 1);
180 self.proposalCovLogVol = zeros(self.count, 1);
181 self.proposalMean = zeros(self.ndim, self.count);
182 self.proposalCov = zeros(self.ndim, self.ndim, self.count);
183 self.proposalCor = zeros(self.ndim, self.ndim, self.count);
184 self.uniqueStateVisitCount = zeros(self.count, 1);
185 skip = 10 + self.ndim * (self.ndim + 3) / 2;
189 while istart < length(self.lineList) - skip
191 if ~strcmp(self.lineList{self.ilast + istart}, self.lineList{self.ilast + istart + 2})
193 if ~self.silent && mod(icount, 10) == 0
194 self.spinner.spin(icount / self.count);
196 self.meanAcceptanceRateSinceStart (icount) = str2double(self.lineList(self.ilast + istart + 1));
197 self.uniqueStateVisitCount (icount) = str2double(self.lineList(self.ilast + istart + 3));
198 self.proposalAdaptiveScaleSq (icount) = str2double(self.lineList(self.ilast + istart + 5));
199 self.proposalCovLogVol (icount) = str2double(self.lineList(self.ilast + istart + 7));
201 iend = istart + self.ndim;
202 self.proposalMean(1 : self.ndim, icount) = str2double(self.lineList(self.ilast + istart : self.ilast + iend - 1));
203 for idim = 1 : self.ndim % covmat
206 cholupp(1 : idim, idim) = str2double(self.lineList(self.ilast + istart : self.ilast + iend)); % This is the upper Cholesky.
208 self.proposalCov(:, :, icount) = cholupp' * cholupp;
217 %%%% Ensure the intrinsic ``corrcov`` is installed.
222 for icount = 1 : size(self.proposalCov, 3)
223 self.proposalCor(:, :, icount) = corrcov(squeeze(self.proposalCov(:, :, icount)));
228 self.proposalCor = self.proposalCov;
229 warning ( newline ...
230 +
string(me.identifier) + " : " +
string(me.message) + newline ...
231 + "The component ``proposalCor`` will be set to the same values as the component ``proposalCov``." + newline ...
238 self.spinner.spin(1);
243 %%%% Add the restart visualizations.
249 self.vis.cascade = struct();
250 silent_kws = {
"silent", self.silent};
252 self.checkpoint(
"adding restart data visualization tools for proposal evolution...");
254 dims = self.ndim * (self.ndim - 1) / 2;
255 dimx = zeros(dims, 1);
256 dimy = zeros(dims, 1);
258 for ix = 1 : self.ndim - 1
259 for iy = 2 : self.ndim
262 counter = counter + 1;
266 for field = [
"proposalCor",
"proposalCov"]
267 self.vis.(field) =
struct();
268 self.vis.(field).cascade =
struct();
269 self.vis.(field).cascade.ellipse = pm.vis.CascadeEllipse( @()self.(field) ...
270 , @()self.proposalMean ...
272 , "dimx", dimx, "dimy", dimy ...
273 , "names", self.domainAxisName ...
276 self.vis.(field).cascade.ellipse3 = pm.vis.CascadeEllipse3 ( @()self.(field) ...
277 , @()self.proposalMean ...
278 , @()transpose(self.uniqueStateVisitCount) ...
280 , "axes", {
"zscale",
"log"} ...
281 ,
"dimx", dimx,
"dimy", dimy ...
282 ,
"names", self.domainAxisName ...
283 ,
"zlabel", {
"txt",
"Unique State Visit Count"} ...
288 self.checkpoint(
"adding restart data visualization tools for other proposal properties...");
290 colnames = [
"uniqueStateVisitCount" ...
291 ,
"meanAcceptanceRateSinceStart" ...
292 ,
"proposalAdaptiveScaleSq" ...
293 ,
"proposalCovLogVol" ...
295 %fullnames = [
"Unique State Visit Count" ...
296 % ,
"Mean Acceptance Rate Since Start" ...
297 % ,
"Proposal Adaptive Scale-Squared" ...
298 % ,
"Proposal Covriance Log-Volume" ...
300 cdf = array2table( [ self.(colnames(1))(:) ...
301 , self.(colnames(2))(:) ...
302 , self.(colnames(3))(:) ...
303 , self.(colnames(4))(:) ...
305 cdf.Properties.VariableNames = colnames;
306 self.vis.cascade.line = pm.vis.CascadeLine ( cdf ...
307 ,
"colx", colnames(1) ...
308 ,
"coly", colnames(2 : end) ...
309 ,
"axes", {
"xscale",
"log"} ...
310 ,
"colormap", {
"enabled",
false} ...
311 ...,
"xlabel", {
"txt", fullnames(1)} ...
312 ...,
"ylabel", {
"txt", fullnames(2 : end)} ...
313 ,
"plot", {
"linewidth", 3} ...
321 warning ( newline ...
322 +
"Failed to create the visualizations for the restart data." + newline ...
323 +
"Here is the error message:" + newline ...
325 +
string(me.identifier) + newline +
string(me.message) + newline ...
333 end % methods(Access =
public)
335 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
337 methods(Access =
public, Hidden)
341 warning ( newline ...
342 +
"The structure of the file:" + newline ...
344 + pm.io.tab() + self.file + newline ...
346 +
"does not match a DRAM-class restart file." + newline ...
347 +
"The contents of the file may have been compromised." + newline ...
348 +
"Verify the integrity of the file contents before attempting a reread." + newline ...
353 end % methods(Access = Hidden)
355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This is the base class for generating objects that contain the contents of a restart file generated b...
Property proposalCovLogVol
function FileContentsRestartDRAM(in file, in silent)
Return a scalar object of class pm.sampling.FileContentsRestartDRAM.
Property proposalAdaptiveScaleSq
Property uniqueStateVisitCount
Property meanAcceptanceRateSinceStart
This is the base class for generating objects that contain the contents of a restart file generated b...