ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
SpecBase.m
Go to the documentation of this file.
1%> \brief
2%> This is the base class for the ParaMonte sampler basic specifications.<br>
3%>
4%> \details
5%> This is a low-level class that is not meant to be used by the user.<br>
6%>
7%> \note
8%> See the documentation of the class constructor.<br>
9%>
10%> \note
11%> All class attributes can be set after constructing an instance of this class.<br>
12%>
13%> \note
14%> See below for information on the methods.<br>
15%>
16%> \see
17%> [ParaDRAM simulation specifications listing](\pmdoc_usage_sampling/paradram/specifications/)<br>
18%>
19%> \final{SpecBase}
20%>
21%> \author
22%> \JoshuaOsborne, May 21 2024, 3:38 AM, University of Texas at Arlington<br>
23%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
24%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
25classdef SpecBase < pm.matlab.Handle
26
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28
29 properties
30 %> \specdram{description}
31 description = [];
32 %> \specdram{domain}
33 domain = [];
34 %> \specdram{domainaxisname}
35 domainAxisName = [];
36 %> \specdram{domainballavg}
37 domainBallAvg = [];
38 %> \specdram{domainballcor}
39 domainBallCor = [];
40 %> \specdram{domainballcov}
41 domainBallCov = [];
42 %> \specdram{domainballstd}
43 domainBallStd = [];
44 %> \specdram{domaincubelimitlower}
45 domainCubeLimitLower = [];
46 %> \specdram{domaincubelimitupper}
47 domainCubeLimitUpper = [];
48 %> \specdram{domainerrcount}
49 domainErrCount = [];
50 %> \specdram{domainerrcountmax}
51 domainErrCountMax = [];
52 %> \specdram{outputchainfileformat}
53 outputChainFileFormat = [];
54 %> \specdram{outputcolumnwidth}
55 outputColumnWidth = [];
56 %> \specdram{outputfilename}
57 outputFileName = [];
58 %> \specdram{outputstatus}
59 outputStatus = [];
60 %> \specdram{outputprecision}
61 outputPrecision = [];
62 %> \specdram{outputreportperiod}
63 outputReportPeriod = [];
64 %> \specdram{outputrestartfileformat}
65 outputRestartFileFormat = [];
66 %> \specdram{outputsamplesize}
67 outputSampleSize = [];
68 %> \specdram{outputseparator}
69 outputSeparator = [];
70 %> \specdram{outputsplashmode}
71 outputSplashMode = [];
72 %> \specdram{parallelism}
73 parallelism = [];
74 %> \specdram{parallelismmpifinalizeenabled}
75 parallelismMpiFinalizeEnabled = [];
76 %> \specdram{parallelismnumthread}
77 parallelismNumThread = [];
78 %> \specdram{randomseed}
79 randomSeed = [];
80 %> \specdram{targetacceptancerate}
81 targetAcceptanceRate = [];
82 end
83
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 properties(Hidden, Access = protected)
87 url = "https://www.cdslab.org/paramonte/generic/" + pm.lib.version("generic", "major") + "/usage/sampling/paradram/specifications/";
88 method = "sampler";
89 silent = false;
90 nmlsep = " ";
91 end
92
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 methods(Access = public)
96
97 %> \brief
98 %> Construct and return an object of class [pm.sampling.SpecBase](@ref SpecBase).
99 %>
100 %> \param[in] method : The input scalar MATLAB string containing
101 %> the name of the specific ParaMonte sampler
102 %> whose simulation specifications are to be
103 %> stored in the output of this constructor.<br>
104 %> \param[in] silent : The input scalar MATLAB logical.<br>
105 %> If ``true``, all descriptive messages on
106 %> the MATLAB command line will be suppressed.<br>
107 %> (**optional**, default = ``false``)
108 %>
109 %> \return
110 %> The output scalar object of class [pm.sampling.SpecBase](@ref SpecBase).<br>
111 %>
112 %> \see
113 %> [ParaDRAM simulation specifications listing](\pmdoc_usage_sampling/paradram/specifications/)<br>
114 %>
115 %> \interface{SpecBase}
116 %> \code{.m}
117 %>
118 %> spec = pm.sampling.SpecBase()
119 %> spec = pm.sampling.SpecBase([])
120 %> spec = pm.sampling.SpecBase([], [])
121 %> spec = pm.sampling.SpecBase(method)
122 %> spec = pm.sampling.SpecBase(method, [])
123 %> spec = pm.sampling.SpecBase([], silent)
124 %> spec = pm.sampling.SpecBase(method, silent)
125 %>
126 %> \endcode
127 %>
128 %> \final{SpecBase}
129 %>
130 %> \author
131 %> \JoshuaOsborne, May 21 2024, 3:40 AM, University of Texas at Arlington<br>
132 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
133 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
134 function self = SpecBase(method, silent)
135 if nargin < 2
136 silent = [];
137 end
138 if nargin < 1
139 method = [];
140 end
141 if ~isempty(silent)
142 self.silent = silent;
143 end
144 if ~isempty(method)
145 self.method = method;
146 end
147 %self.ndim = ndim;
148 %valid = false;
149 %if isa(ndim, "real") || isa(ndim, "int32")
150 % if rem(ndim, 1) == 0
151 % self.ndim = ndim;
152 % valid = true;
153 % end
154 %end
155 %if ~valid
156 % disp("ndim = ");
157 % disp(ndim);
158 % error ( newline ...
159 % + "The specified input value for ``ndim`` (" + string(ndim) + ") must be a whole number (integer)." + newline ...
160 % + "The variable ``ndim`` represents the number of dimensions of the domain" + newline ...
161 % + "of the object function that is to be explored." + newline ...
162 % + newline ...
163 % );
164 %end
165 end
166
167 %> \brief
168 %> Return documentation help for the input simulation specification name.<br>
169 %>
170 %> \details
171 %> Otherwise, return documentation help for all simulation specifications
172 %> if the input ``specification`` argument is missing.<br>
173 %>
174 %> \devnote
175 %> The underlying reason for unifying documentation of object attributes
176 %> within a single online page is to significantly reduce duplication and
177 %> work required for generating and maintaining such documentation across
178 %> all supported programming language environments.<br>
179 %>
180 %> \param[in] self : The input parent object of class [pm.sampling.SpecBase](@ref SpecBase)
181 %> which is **implicitly** passed to this dynamic method (not by the user).<br>
182 %> \param[in] specification : The input scalar MATLAB string containing the
183 %> name of a simulation specification corresponding
184 %> an attribute of the parent object.<br>
185 %>
186 %> \return
187 %> ``weblink`` : The output scalar MATLAB string containing the web address
188 %> for the documentation of the requested simulation specification.<br>
189 %>
190 %> \interface{doc}
191 %> \code{.m}
192 %>
193 %> weblink = self.doc()
194 %> weblink = self.doc(specification)
195 %>
196 %> \endcode
197 %> \example{doc}
198 %> \code{.m}
199 %>
200 %> spec = pm.sampling.SpecBase();
201 %>
202 %> spec.doc() % return help for all specifications.
203 %> spec.doc("outputFileName") % return help for the specification ``outputFileName``.
204 %>
205 %> \endcode
206 %>
207 %> \final{doc}
208 %>
209 %> \author
210 %> \JoshuaOsborne, May 21 2024, 3:42 AM, University of Texas at Arlington<br>
211 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
212 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
213 function weblink = doc(self, specification)
214
215 if nargin < 2
216 weblink = pm.web.href(self.url);
217 else
218 if isstring(specification) || ischar(specification)
219 specList = properties(self);
220 specListLen = length(specList);
221 for i = 1 : specListLen
222 if strcmpi(specList{i}, specification)
223 specLower = "#" + lower(specification);
224 weblink = pm.web.href(self.url + specLower);
225 return;
226 end
227 end
228 error ( newline ...
229 + "The input specification must be a string or char vector " + newline ...
230 + "whose value is the name of one of the specification properties" + newline ...
231 + "of the sampler as specified in the ``spec`` component." + newline ...
232 + "Example usage:" + newline ...
233 + newline ...
234 + pm.io.tab() + "doc()" + newline ...
235 + pm.io.tab() + "doc(""chainSize"")" + newline ...
236 + newline ...
237 );
238 end
239 end
240 end
241
242 end
243
244 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
245
246 methods(Hidden)
248 %> \brief
249 %> Ensure all specification properties of the parent object are sensible.<br>
250 %> This is a dynamic method of the class [pm.sampling.SpecBase](@ref SpecBase).<br>
251 %>
252 %> \param[inout] self : The input/output parent object of class [pm.sampling.SpecBase](@ref SpecBase)
253 %> which is **implicitly** passed to this dynamic method (not by the user).<br>
254 %> \param[in] ndim : The input scalar MATLAB integer containing
255 %> the number of dimensions of the domain of the
256 %> object function that is to be explored.<br>
257 %>
258 %> \return
259 %> ``entries`` : The output scalar MATLAB string containing
260 %> the simulation specifications converted to
261 %> a Fortran-namelist-compatible entry.<br>
262 %>
263 %> \interface{getEntriesNML}
264 %> \code{.m}
265 %>
266 %> entries = self.getEntriesNML(ndim)
267 %>
268 %> \endcode
269 %>
270 %> \final{getEntriesNML}
271 %>
272 %> \author
273 %> \JoshuaOsborne, May 21 2024, 3:43 AM, University of Texas at Arlington<br>
274 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
275 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
276 function entries = getEntriesNML(self, ndim)
277 if isempty(self.outputFileName)
278 % First define ``outputFileName`` if it is empty.
279 self.outputFileName = fullfile(string(pwd), pm.io.getFileName(self.method));
280 elseif pm.introspection.verified(self.outputFileName, "string", 1)
281 if ~self.silent && contains(self.outputFileName, " ")
282 warning ( newline ...
283 + "The specified simulation specification ``outputFileName`` contains whitespace characters(s)." + newline ...
284 + "Blanks are infamous for causing software crashes and failures." + newline ...
285 + "Best is to blanks and special characters in paths." + newline ...
286 + newline ...
287 );
288 end
289 if endsWith(self.outputFileName, "\") || endsWith(self.outputFileName, "/")
290 self.outputFileName = fullfile(string(pm.sys.path.abs(self.outputFileName, "lean")), pm.io.getFileName(self.method));
291 end
292 end
293 entries = "plang=""Version " + string(version()) + """";
294 if ~isempty(self.description ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("description ", self.description , "string" , 1); end
295 if ~isempty(self.domain ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("domain ", self.domain , "string" , 1); end
296 if ~isempty(self.domainAxisName ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("domainAxisName ", self.domainAxisName , "string" , ndim); end
297 if ~isempty(self.domainBallAvg ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("domainBallAvg ", self.domainBallAvg , "real" , ndim); end
298 if ~isempty(self.domainBallCor ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("domainBallCor ", self.domainBallCor , "real" , ndim^2); end
299 if ~isempty(self.domainBallCov ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("domainBallCov ", self.domainBallCov , "real" , ndim^2); end
300 if ~isempty(self.domainBallStd ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("domainBallStd ", self.domainBallStd , "real" , ndim); end
301 if ~isempty(self.domainCubeLimitLower ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("domainCubeLimitLower ", self.domainCubeLimitLower , "real" , ndim); end
302 if ~isempty(self.domainCubeLimitUpper ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("domainCubeLimitUpper ", self.domainCubeLimitUpper , "real" , ndim); end
303 if ~isempty(self.domainErrCount ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("domainErrCount ", self.domainErrCount , "integer", 1); end
304 if ~isempty(self.domainErrCountMax ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("domainErrCountMax ", self.domainErrCountMax , "integer", 1); end
305 if ~isempty(self.outputChainFileFormat ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("outputChainFileFormat ", self.outputChainFileFormat , "string" , 1); end
306 if ~isempty(self.outputColumnWidth ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("outputColumnWidth ", self.outputColumnWidth , "integer", 1); end
307 if ~isempty(self.outputFileName ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("outputFileName ", self.outputFileName , "string" , 1); end
308 if ~isempty(self.outputStatus ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("outputStatus ", self.outputStatus , "string" , 1); end
309 if ~isempty(self.outputPrecision ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("outputPrecision ", self.outputPrecision , "integer", 1); end
310 if ~isempty(self.outputReportPeriod ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("outputReportPeriod ", self.outputReportPeriod , "integer", 1); end
311 if ~isempty(self.outputRestartFileFormat ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("outputRestartFileFormat ", self.outputRestartFileFormat , "string" , 1); end
312 if ~isempty(self.outputSampleSize ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("outputSampleSize ", self.outputSampleSize , "integer", 1); end
313 if ~isempty(self.outputSeparator ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("outputSeparator ", self.outputSeparator , "string" , 1); end
314 if ~isempty(self.outputSplashMode ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("outputSplashMode ", self.outputSplashMode , "string" , 1); end
315 if ~isempty(self.parallelism ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("parallelism ", self.parallelism , "string" , 1); end
316 if ~isempty(self.parallelismMpiFinalizeEnabled ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("parallelismMpiFinalizeEnabled", self.parallelismMpiFinalizeEnabled , "logical", 1); end
317 if ~isempty(self.parallelismNumThread ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("parallelismNumThread ", self.parallelismNumThread , "integer", 1); end
318 if ~isempty(self.randomSeed ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("randomSeed ", self.randomSeed , "integer", 1); end
319 if ~isempty(self.targetAcceptanceRate ); entries = entries + self.nmlsep + pm.fortran.getEntryNML("targetAcceptanceRate ", self.targetAcceptanceRate , "real" , 2); end
320 end
321 % % These methods have been implemented to override the default 'handle' class methods,
322 % % so that they will not pop-up after pressing 'Tab' button.
323 % function addlistener (self) end
324 % function delete (self) end
325 % function findobj (self) end
326 % function findprop (self) end
327 % function valid (self) end
328 % function listener (self) end
329 % function notify (self) end
330 end
331
332end
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared library directories.
function version(in silent)
Return a scalar MATLAB string containing the latest available ParaMonte MATLAB version newer than the...
function abs(in path, in style)
Return the Get absolute canonical path of a file or folder.
This is the base class for generating subclass of MATLAB handle superclass whose annoying methods are...
Definition: Handle.m:24
This is the base class for the ParaMonte sampler basic specifications.
Definition: SpecBase.m:26
Property outputReportPeriod
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:82
Property description
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:34
Property silent
Definition: SpecBase.m:120
Property domainBallCor
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:46
function getEntriesNML(in self, in ndim)
Ensure all specification properties of the parent object are sensible. This is a dynamic method of t...
Property outputSeparator
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:91
Property outputColumnWidth
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:70
Property outputChainFileFormat
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:67
function SpecBase(in method, in silent)
Construct and return an object of class pm.sampling.SpecBase.
Property domainErrCount
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:61
Property parallelismMpiFinalizeEnabled
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:100
Property domainBallCov
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:49
function doc(in self, in specification)
Return documentation help for the input simulation specification name.
Property outputFileName
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:73
Property domainCubeLimitLower
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:55
Property parallelismNumThread
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:103
Property nmlsep
Definition: SpecBase.m:122
Property domainBallAvg
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:43
Property targetAcceptanceRate
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:109
Property parallelism
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:97
Property domainCubeLimitUpper
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:58
Property domainBallStd
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:52
Property domainAxisName
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:40
Property outputSampleSize
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:88
Property method
Definition: SpecBase.m:118
Property outputStatus
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:76
Property outputSplashMode
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:94
Property url
Definition: SpecBase.m:116
Property outputPrecision
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:79
Property outputRestartFileFormat
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:85
Property domainErrCountMax
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:64
Property domain
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:37
Property randomSeed
See the generic documentation at: https://www.cdslab.org/paramonte/generic/2/usage/sampling/paradram/...
Definition: SpecBase.m:106
function getEntryNML(in varname, in varval, in vartype, in maxlen)
Return a Fortran-namelist-compatible conversion of the input varval.
function getFileName(in prefix)
Return a scalar MATLAB string containing a file name based on the current date and time.
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...