ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
testParaMonte.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%C:\Users\<username>\AppData\Roaming\MathWorks\MATLAB
18%cd D:\Dropbox\Projects\20180101_ParaMonte\git\src\interface\MATLAB\bin
19%mex -nojvm CC=icl paramonte.c libparamonte_dynamic_heap_testing_intel_c_windows_x64_mt.lib -output libparamonte_dynamic_heap_testing_intel_windows_x64_mt
20%[status,cmdout] = system('matlab -nosplash -nojvm -r "testParaMonte,exit"','-echo');
21%clc;
22clear all;
23close all;
24fclose('all');
25clear classes;
26format compact; format long;
27pmlibRootDir = './'; % set this path to the paramonte library root dir
28addpath( genpath(pmlibRootDir) )
29filePath = mfilename('fullpath');
30[scriptPath,fileName,fileExt] = fileparts(filePath); cd(scriptPath); % Change working directory to source code directory.
31cd(fileparts(mfilename('fullpath'))); % Change working directory to source code directory.
32
33%-----------------------------------------------------------------------------------------------------------------------------------------------------------
34%pm = paramonte("matlab");
35pm = paramonte(); % "matlab"
36pmpd = pm.ParaDRAM();
37%pmpd = ParaDRAM_class();
38%-----------------------------------------------------------------------------------------------------------------------------------------------------------
39% return
40% %pmpd.inputFile = './paramonte.in';
41
42% pmpd.spec.chainSize = 20000;
43% %pmpd.spec.adaptiveUpdateCount = 2100000000;
44% %pmpd.spec.adaptiveUpdatePeriod = 3000;
45% %pmpd.spec.startPointVec = -10;
46% pmpd.spec.randomSeed = 35671;
47% pmpd.spec.proposalModel = "normal";
48% pmpd.spec.targetAcceptanceRate = 0.2;
49% pmpd.runSampler(2,@getLogFunc); %@(point)-0.5*sum(point.^2)); %
50% %pmpd.spec.outputFileName = "D:\Dropbox\Projects\20180101_ParaMonte\git\src\interface\MATLAB\test\ParaDRAM_run_300420_012424_780";
51% %pmpd.readChainMarkov();
52% pmpd.readChain(); %"ParaDRAM_run_180420_151344_607";%"D:\Dropbox\Projects\20180101_ParaMonte\git\src\interface\MATLAB\test\ParaDRAM_run_160420_023054_530");
53% %pmpd.readSample();
54% return
55%-----------------------------------------------------------------------------------------------------------------------------------------------------------
56 ...ParaMonte variables...
57%pmpd.spec.sampleSize = 100; % Works
58%pmpd.spec.randomSeed = 7; % Works
59pmpd.spec.description = "Hi there"; % Works
60%-----------------------------------------------------------------------------------------------------------------------------------------------------------
61flag = 0;
62flag = 1;
63if flag
64 file = "./out/temp/A_A_A_A";
65 if exist(file + "_process_1_chain.txt"), delete(file + "_process_1_chain.txt"); end
66 if exist(file + "_process_1_progress.txt"), delete(file + "_process_1_progress.txt"); end
67 if exist(file + "_process_1_report.txt"), delete(file + "_process_1_report.txt"); end
68 if exist(file + "_process_1_restart.txt"), delete(file + "_process_1_restart.txt"); end
69 if exist(file + "_process_1_sample.txt"), delete(file + "_process_1_sample.txt"); end
70 pmpd.spec.outputFileName = file;
71else
72 pmpd.spec.outputFileName = "./out/temp/";
73end
74%-----------------------------------------------------------------------------------------------------------------------------------------------------------
75%pmpd.spec.outputSeparator = "|"; % Works
76%pmpd.spec.chainFileFormat = "compact"; % Works
77%pmpd.spec.variableNameList = ["Variable-X", "Variable-Y"]; % Works
78%pmpd.spec.restartFileFormat = "ASCII"; % Works
79%pmpd.spec.outputColumnWidth = 25; % Works
80%pmpd.spec.outputRealPrecision = 17; % Works
81%pmpd.spec.silentModeRequested = 0; % Works
82%pmpd.spec.domainLowerLimitVec = -1.e300 * ones(5,1);%[-4,-4]; % Works
83%pmpd.spec.domainUpperLimitVec = +1.e300 * ones(5,1);%[+4,+4]; % Works
84%pmpd.spec.progressReportPeriod = 100; % Works
85%pmpd.spec.targetAcceptanceRate = 0.5; % Works
86% pmpd.spec.maxNumDomainCheckToWarn = [];
87% pmpd.spec.maxNumDomainCheckToStop = [];
88%-----------------------------------------------------------------------------------------------------------------------------------------------------------
89 ...ParaMCMC variables...
90pmpd.spec.chainSize = 1000; % Works
91%pmpd.spec.startPointVec = [0.6,1.2]; % Works
92%pmpd.spec.sampleRefinementCount = 1; % Works
93%pmpd.spec.sampleRefinementMethod = "someRandomName"; % Works
94%pmpd.spec.randomStartPointRequested = 1; % Works
95%pmpd.spec.randomStartPointDomainLowerLimitVec = [0.5, 1.0]; % Works
96%pmpd.spec.randomStartPointDomainUpperLimitVec = [1.0, 1.5]; % Works
97%-----------------------------------------------------------------------------------------------------------------------------------------------------------
98 ...ParaDRAM variables...
99%pmpd.spec.scaleFactor = "1.2 * gelman"; % Works
100%pmpd.spec.proposalModel = "normal"; % Works
101%pmpd.spec.proposalCor = [0.4, 0.1; 0.2, 0.3]; % Works
102%pmpd.spec.proposalCov = [0.5, 0.2; 0.1, 0.3]; % Works
103%pmpd.spec.proposalStd = [1, 1]; % Works
104%pmpd.spec.adaptiveUpdateCount = 2; % Works
105%pmpd.spec.adaptiveUpdatePeriod = 25; % Works
106%pmpd.spec.greedyAdaptationCount = 2; % Works
107%pmpd.spec.proposalAdaptationBurnin = 0.5; % Works
108%pmpd.spec.delayedRejectionCount = 2; % Works
109%pmpd.spec.delayedRejectionScaleFactorVec = [3, 4]; % Works
110%pmpd.spec.delayedRejectionCount = 10;
111%pmpd.spec.delayedRejectionScaleFactorVec = [1.1,2,3,1.5,2.1,3,2,1.1,1.2,1.3];
112%-----------------------------------------------------------------------------------------------------------------------------------------------------------
113
114%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
115 ndim = 2;
116%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117%return
118pmpd.runSampler(ndim, @getLogFunc);
119fclose('all');
120
121% scatter(pmpd.Chain.State(1,:),pmpd.Chain.State(2,:));
122% plot3(pmpd.Chain.State(1,:),pmpd.Chain.State(2,:),pmpd.Chain.LogFunc);
123
124% for i = 1 : ndim
125%
126% figure("color", "white");
127% histfit(pmpd.Chain.State(i,:));
128%
129% figure("color", "white");
130% plot(pmpd.Chain.State(i,:));
131% set(gca,'xscale','log')
132%
133% end
134
135%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136
137%system(pmpd.LogFile.Path.modified);
138%system(pmpd.TimeFile.Path.modified);
139%system(pmpd.ChainFile.Path.modified);
140%system(pmpd.SampleFile.Path.modified);
141%system(pmpd.RestartFile.Path.modified);
function getLogFunc(in point)
function mex(in mexname, in config)
Return the vector of MATLAB strings containing the path(s) to the ParaMonte library MEX shared files.
function root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.