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