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 %> pmpd.spec.doc() % return help for all specifications.
201 %> pmpd.spec.doc("outputFileName") % return help for the specification ``outputFileName``.
202 %>
203 %> \endcode
204 %>
205 %> \final{doc}
206 %>
207 %> \author
208 %> \JoshuaOsborne, May 21 2024, 3:42 AM, University of Texas at Arlington<br>
209 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
210 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
211 function weblink = doc(self, specification)
212
213 if nargin < 2
214 weblink = pm.web.href(self.url);
215 else
216 if isstring(specification) || ischar(specification)
217 specList = properties(self);
218 specListLen = length(specList);
219 for i = 1 : specListLen
220 if strcmpi(specList{i}, specification)
221 specLower = "#" + lower(specification);
222 weblink = pm.web.href(self.url + specLower);
223 return;
224 end
225 end
226 error ( newline ...
227 + "The input specification must be a string or char vector " + newline ...
228 + "whose value is the name of one of the specification properties" + newline ...
229 + "of the sampler as specified in the ``spec`` component." + newline ...
230 + "Example usage:" + newline ...
231 + newline ...
232 + pm.io.tab + "doc()" + newline ...
233 + pm.io.tab + "doc(""chainSize"")" + newline ...
234 + newline ...
235 );
236 end
237 end
238 end
239
240 end
241
242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243
244 methods(Hidden)
246 %> \brief
247 %> Ensure all specification properties of the parent object are sensible.<br>
248 %> This is a dynamic method of the class [pm.sampling.SpecBase](@ref SpecBase).<br>
249 %>
250 %> \param[inout] self : The input/output parent object of class [pm.sampling.SpecBase](@ref SpecBase)
251 %> which is **implicitly** passed to this dynamic method (not by the user).<br>
252 %> \param[in] ndim : The input scalar MATLAB integer containing
253 %> the number of dimensions of the domain of the
254 %> object function that is to be explored.<br>
255 %>
256 %> \return
257 %> ``entries`` : The output scalar MATLAB string containing
258 %> the simulation specifications converted to
259 %> a Fortran-namelist-compatible entry.<br>
260 %>
261 %> \interface{getEntriesNML}
262 %> \code{.m}
263 %>
264 %> entries = self.getEntriesNML(ndim)
265 %>
266 %> \endcode
267 %>
268 %> \final{getEntriesNML}
269 %>
270 %> \author
271 %> \JoshuaOsborne, May 21 2024, 3:43 AM, University of Texas at Arlington<br>
272 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
273 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
274 function entries = getEntriesNML(self, ndim)
275 if isempty(self.outputFileName)
276 % First define ``outputFileName`` if it is empty.
277 self.outputFileName = fullfile(string(pwd), pm.io.getFileName(self.method));
278 elseif pm.introspection.istype(self.outputFileName, "string", 1)
279 if ~self.silent && contains(self.outputFileName, " ")
280 warning ( newline ...
281 + "The specified simulation specification ``outputFileName`` contains whitespace characters(s)." + newline ...
282 + "Blanks are infamous for causing software crashes and failures." + newline ...
283 + "Best is to blanks and special characters in paths." + newline ...
284 + newline ...
285 );
286 end
287 if endsWith(self.outputFileName, "\") || endsWith(self.outputFileName, "/")
288 self.outputFileName = fullfile(string(pm.sys.path.abs(self.outputFileName, "lean")), pm.io.getFileName(self.method));
289 end
290 end
291 entries = "";
292 if ~isempty(self.description ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("description ", self.description , "string" , 1); end
293 if ~isempty(self.domain ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("domain ", self.domain , "string" , 1); end
294 if ~isempty(self.domainAxisName ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("domainAxisName ", self.domainAxisName , "string" , ndim); end
295 if ~isempty(self.domainBallAvg ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("domainBallAvg ", self.domainBallAvg , "real" , ndim); end
296 if ~isempty(self.domainBallCor ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("domainBallCor ", self.domainBallCor , "real" , ndim^2); end
297 if ~isempty(self.domainBallCov ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("domainBallCov ", self.domainBallCov , "real" , ndim^2); end
298 if ~isempty(self.domainBallStd ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("domainBallStd ", self.domainBallStd , "real" , ndim); end
299 if ~isempty(self.domainCubeLimitLower ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("domainCubeLimitLower ", self.domainCubeLimitLower , "real" , ndim); end
300 if ~isempty(self.domainCubeLimitUpper ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("domainCubeLimitUpper ", self.domainCubeLimitUpper , "real" , ndim); end
301 if ~isempty(self.domainErrCount ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("domainErrCount ", self.domainErrCount , "integer", 1); end
302 if ~isempty(self.domainErrCountMax ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("domainErrCountMax ", self.domainErrCountMax , "integer", 1); end
303 if ~isempty(self.outputChainFileFormat ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("outputChainFileFormat ", self.outputChainFileFormat , "string" , 1); end
304 if ~isempty(self.outputColumnWidth ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("outputColumnWidth ", self.outputColumnWidth , "integer", 1); end
305 if ~isempty(self.outputFileName ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("outputFileName ", self.outputFileName , "string" , 1); end
306 if ~isempty(self.outputStatus ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("outputStatus ", self.outputStatus , "string" , 1); end
307 if ~isempty(self.outputPrecision ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("outputPrecision ", self.outputPrecision , "integer", 1); end
308 if ~isempty(self.outputReportPeriod ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("outputReportPeriod ", self.outputReportPeriod , "integer", 1); end
309 if ~isempty(self.outputRestartFileFormat ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("outputRestartFileFormat ", self.outputRestartFileFormat , "string" , 1); end
310 if ~isempty(self.outputSampleSize ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("outputSampleSize ", self.outputSampleSize , "integer", 1); end
311 if ~isempty(self.outputSeparator ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("outputSeparator ", self.outputSeparator , "string" , 1); end
312 if ~isempty(self.outputSplashMode ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("outputSplashMode ", self.outputSplashMode , "string" , 1); end
313 if ~isempty(self.parallelism ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("parallelism ", self.parallelism , "string" , 1); end
314 if ~isempty(self.parallelismMpiFinalizeEnabled ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("parallelismMpiFinalizeEnabled", self.parallelismMpiFinalizeEnabled , "logical", 1); end
315 if ~isempty(self.parallelismNumThread ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("parallelismNumThread ", self.parallelismNumThread , "integer", 1); end
316 if ~isempty(self.randomSeed ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("randomSeed ", self.randomSeed , "integer", 1); end
317 if ~isempty(self.targetAcceptanceRate ); entries = entries + self.nmlsep + pm.introspection.getEntryNML("targetAcceptanceRate ", self.targetAcceptanceRate , "real" , 2); end
318 end
319 % % These methods have been implemented to override the default 'handle' class methods,
320 % % so that they will not pop-up after pressing 'Tab' button.
321 % function addlistener (self) end
322 % function delete (self) end
323 % function findobj (self) end
324 % function findprop (self) end
325 % function valid (self) end
326 % function listener (self) end
327 % function notify (self) end
328 end
329
330end
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared library directories.
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 varsize)
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...