ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
testParaMonte_debug_mpi.m
Go to the documentation of this file.
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3%%%% %%%%
4%%%% ParaMonte: Parallel Monte Carlo and Machine Learning Library. %%%%
5%%%% %%%%
6%%%% Copyright (C) 2012-present, The Computational Data Science Lab %%%%
7%%%% %%%%
8%%%% This file is part of the ParaMonte library. %%%%
9%%%% %%%%
10%%%% LICENSE %%%%
11%%%% %%%%
12%%%% https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md %%%%
13%%%% %%%%
14%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16
17% clear MATLAB space
18
19clc;
20clear all;
21close all;
22clear classes;
23format compact; format long;
24
25% set path to the ParaMonte MATLAB library
26
27pmlibRootDir = './'; % set this path to the paramonte library root dir
28addpath(genpath(pmlibRootDir));
29
30% change MATLAB's working directory to the folder containing this script
31
32filePath = mfilename('fullpath');
33[currentDir,fileName,fileExt] = fileparts(filePath); cd(currentDir); % Change working directory to source code directory.
34cd(fileparts(mfilename('fullpath'))); % Change working directory to source code directory.
35
36% define the objective function
37
38NDIM = 4; % number of dimensions of the distribution
39
40% create a ParaMonte object
41
42pm = paramonte(); % use paramonte("matlab") to use the MATLAB kernel instead of interface
43
44% create a ParaDRAM simulation object
45
46pmpd = pm.ParaDRAM();
47
48% specifity path to the input specification file.
49% This is optional: all simulation specifications can be
50% also set as attributes of the pmpd.spec component of the object.
51% KEEP IN MIND: if you set pmpd.inputFile to any non-empty value, then
52% the inputFile will override any values specified via pmpd.spec properties.
53% pmpd.inputFile = fullfile( string(currentDir) , "paramonte.in" );
54
55pmpd.bldtype = "debug";
56pmpd.mpiEnabled = true;
57pmpd.spec.chainSize = 10000;
58pmpd.spec.randomSeed = 31731;
59
60pmpd.runSampler ( NDIM ... number of dimensions of the objective function
61 , @getLogFunc ... the objective function: multivariate normal distribution
62 );
63
64function logFunc = getLogFunc(point)
65 mean = [ 0.0;0.0;0.0;0.0 ]; % mean of the Multivariate Normal distribution
66 covmat = [ 1.0,0.5,0.5,0.5 ... covariance matrix of the Multivariate Normal distribution
67 ; 0.5,1.0,0.5,0.5 ...
68 ; 0.5,0.5,1.0,0.5 ...
69 ; 0.5,0.5,0.5,1.0 ];
70 logFunc = log(mvnpdf(point,mean,covmat));
71end
function root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.
function getLogFunc(in point)