Skip to content

Commit afe8252

Browse files
Full compile of NS minimizer (#163)
Co-authored-by: Stephen Nneji <[email protected]>
1 parent 907cf9d commit afe8252

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+842
-2471
lines changed

API/RATMain.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@
5252
sendTextOutput(sprintf('\nRunning Differential Evolution\n\n'));
5353
end
5454
[outProblemDef,problem,results] = runDE(problemDef,problemDefCells,problemDefLimits,controls);
55-
% case 'ns'
56-
% if ~strcmpi(controls.display,'off')
57-
% sendTextOutput(sprintf('\nRunning Nested Sampler\n\n'));
58-
% end
59-
% [outProblemDef,problem,results,bayesResults] = runNestedSampler(problemDef,problemDefCells,problemDefLimits,controls);
55+
case 'ns'
56+
if ~strcmpi(controls.display,'off')
57+
sendTextOutput(sprintf('\nRunning Nested Sampler\n\n'));
58+
end
59+
[outProblemDef,problem,results,bayesResults] = runNestedSampler(problemDef,problemDefCells,problemDefLimits,controls,priors);
6060
case 'dream'
6161
if ~strcmpi(controls.display,'off')
6262
sendTextOutput(sprintf('\nRunning DREAM\n\n'));

compile/fullCompile/ratMainCompileScript.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
%
55
% See also CODER, CODER.CONFIG, CODER.TYPEOF, CODEGEN.
66

7+
%% Deal with globals
8+
global verbose DEBUG
9+
DEBUG = 0;
10+
verbose = 1;
11+
712
%% Create configuration object of class 'coder.MexCodeConfig'.
813
cfg = coder.config('mex');
914
cfg.GenerateReport = true;
@@ -12,10 +17,10 @@
1217
cfg.TargetLang = 'C++';
1318
% cfg.TargetLangStandard = 'C++11 (ISO)';
1419

15-
16-
% Define the input argument types..
20+
%% Define the input argument types..
1721
ARGS = makeCompileArgsFull();
1822

23+
%% Run the compile
1924
includeDirs = getappdata(0,'includeDirs');
2025
includes = cell(length(includeDirs)*2, 1);
2126
includes(1:2:end) = {'-I'};

examples/D2O/d2o_2contrast.mat

9 KB
Binary file not shown.
17.1 KB
Binary file not shown.

minimisers/DREAM/functions/makeEmptyBayesResultsStruct.m

Lines changed: 0 additions & 201 deletions
This file was deleted.

minimisers/NSMain/NSIntraFun.m

Lines changed: 0 additions & 22 deletions
This file was deleted.

minimisers/NSMain/calc_ellipsoid.m renamed to minimisers/NSMain/calcEllipsoid.m

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [B, mu, VE, flag] = calc_ellipsoid(u, VS)
1+
function [B, mu, VE, flag] = calcEllipsoid(u, VS)
22
%
33
% calculate properties of ellipsoid given a set of points u
44
%
@@ -51,10 +51,11 @@
5151

5252
% find scale factor for bounding ellipsoid E
5353
fB = 0;
54+
%coder.varsize('fB');
5455
for i=1:N
5556
f = ( (u(i,:)-mu) / C ) * (u(i,:)-mu)';
5657
if f > fB
57-
fB = f;
58+
fB = f(1);
5859
end
5960
end
6061

@@ -69,6 +70,21 @@
6970
end
7071

7172
% scale C to get bounding matrix B
72-
B = fV * fB * C;
73+
74+
% Again emphasise the scalar for the inner mutiplication
75+
% matlab error in compiled code.....
76+
%
77+
% Error using eml_mtimes_helper>dynamic_size_checks
78+
% Inner dimensions must agree. Generated code for a general matrix multiplication at this call site. If this should have been a scalar times a variable-size matrix, the
79+
% scalar input must be fixed-size.
80+
%
81+
% Error in eml_mtimes_helper (line 69)
82+
% dynamic_size_checks(a, b, innerDimA, innerDimB);
83+
%
84+
% Error in calcEllipsoid (line 73)
85+
% B = fV * fB * C;
86+
87+
% B = fV * fB * C;
88+
B = fV(1) * fB(1) * C;
7389

7490
return

minimisers/NSMain/draw_from_ellipsoid.m renamed to minimisers/NSMain/drawEllipsoidPoints.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
function pnts = draw_from_ellipsoid(B, mu, N )
1+
function pnts = drawEllipsoidPoints(B, mu, N )
22

3-
% function pnts = draw_from_ellipsoid(B, mu, N )
3+
% function pnts = drawEllipsoidPoints(B, mu, N )
44
%
55
% This function draws points uniformly from an ndims-dimensional ellipsoid
66
% with edges and orientation defined by the the bounding matrix B and
@@ -41,7 +41,8 @@
4141
pnts(i,:) = fac(i)*pt(i,:);
4242

4343
% scale and rotate to ellipsoid
44-
pnts(i,:) = (pnts(i,:) .* D' * V') + mu;
44+
% ('real' needed for compile....)
45+
pnts(i,:) = real((pnts(i,:) .* D' * V') + mu);
4546
end
4647

4748
return

0 commit comments

Comments
 (0)