ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
testParaMonte_Rosenbrock.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 = 2; % 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
48pmpd.mpiEnabled = false;
49pmpd.bldtype = "release";
50pmpd.spec.randomSeed = 31731;
51pmpd.spec.outputFileName = "./RosenBrock/";
52pmpd.spec.sampleRefinementCount = 1;
53pmpd.spec.outputSeparator = ",";
54pmpd.spec.chainSize = 15000;
55pmpd.spec.sampleSize = -100;
56pmpd.spec.targetAcceptanceRate = [0.01,0.3];
57pmpd.spec.proposalStd = [2,2];
58
59getNegLogRosen = @(point) -log( 100.0 * (point(2)-point(1)^2)^2 + (point(1)-1.0)^2 );
60
61pmpd.runSampler ( NDIM ... number of dimensions of the objective function
62 , getNegLogRosen ... the objective function
63 );
64
65function logFunc = getLogFunc(point)
66 logFunc = -log( 100.0 * (point(2)-point(1)^2)^2 + (point(1)-1.0)^2 );
67end
function root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.
function getLogFunc(in point)