Skip to content

Commit 907cf9d

Browse files
Full compile of some minimizers (#161)
* Some initial corrections to DREAM for compile * Most 'screener' identified problems with DREAM resolved * All issues found via 'coder.screener('RATMain')' now cleared * Fixed assignment problem in Gelman * Most compile issues now cleared * Fixed pre-allocation issue in refPrcentileconfInts * Full compile working with Bayes commented out. Most Bayes issues theared though... * Half way through re-configuring 'bayesOutputs' to be more sensible * Cleared up to output structs. Now rationalising 'bayesOutputs' * Almost compiles. A slight problem with assignment size of 'sldXdata' when assigning outputs in 'runDREAM' * Fixes so the code compiles * Dream now runs to completion, but this has messed up the outputs (ref_yVals{n}) * Full compile now working correctly * Fixes unit test and removes unneeded files * Addresses review comments * Fixes kmeans --------- Co-authored-by: arwelHughes <[email protected]>
1 parent 328e024 commit 907cf9d

File tree

99 files changed

+1305
-633
lines changed

Some content is hidden

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

99 files changed

+1305
-633
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ __pycache__/
4141
*.dll
4242
*.lib
4343
*.dylib
44+
*.prj

3rdParty/paramonte/pmLogFunction.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
problem = unpackparams(problem,control);
3232

33-
[outProblem,results] = reflectivityCalculationWrapper(problem,cells,limits,control);
33+
[outProblem,results] = reflectivityCalculation(problem,cells,limits,control);
3434
chi = outProblem.calculations.sum_chi;
3535
logFuncVal = -chi/2;
3636

3rdParty/paramonte/processParamonteRuns.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
bayesOutputs.data = problemDefCells{2};
4848
bayesOutputs.results.mean = mean(unscaledChain);
4949

50-
[problemDef,outProblemStruct,result,bayesResults] = processBayes_newMethod(bayesOutputs,allProblem);
50+
[problemDef,outProblemStruct,result,bayesResults] = processBayes(bayesOutputs,allProblem);
5151

5252

5353
result = parseResultToStruct(outProblemStruct,result);

3rdParty/paramonte/runParamonte.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
% output.bestPars = mean(unscaledChain);
131131
% output.data = data;
132132
%
133-
% [problemDef,outProblem,result,bayesResults] = processBayes_newMethod(output,outProblem);
133+
% [problemDef,outProblem,result,bayesResults] = processBayes(output,outProblem);
134134

135135
% pmpdOut = pmpd;
136136

API/RAT.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
end
8080

8181
tic
82-
[outProblemStruct,problem,result,bayesResults] = RATMain(problemDef,problemDefCells,problemDefLimits,controls,priors);
82+
[outProblemStruct,problem,result,bayesResults] = RATMain_mex(problemDef,problemDefCells,problemDefLimits,controls,priors);
8383
sendTextOutput(sprintf('\n'));
8484

8585
if ~strcmpi(controls.display,'off')
@@ -92,7 +92,7 @@
9292
originalProc = controls.proc;
9393
controls.calcSld = 1;
9494
controls.proc = 'calculate';
95-
[outProblemStruct,problem,result,~] = RATMain(outProblemStruct,problemDefCells,problemDefLimits,controls,priors);
95+
[outProblemStruct,problem,result,~] = RATMain_mex(outProblemStruct,problemDefCells,problemDefLimits,controls,priors);
9696
controls.proc = originalProc;
9797
end
9898

API/RATMain.m

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
function [outProblemDef,problem,results,bayesResults] = RATMain(problemDef,problemDefCells,problemDefLimits,controls,priors)
22

33

4-
result = cell(6,1);
4+
result = cell(1,1);
5+
result{1} = {1};
6+
results = repmat(result,1,6);
7+
58
numberOfContrasts = problemDef.numberOfContrasts;
69
preAlloc = zeros(numberOfContrasts,1);
710

@@ -13,22 +16,31 @@
1316
'nbsubs',preAlloc,...
1417
'resolutions',preAlloc,...
1518
'calculations',struct('all_chis',preAlloc,'sum_chi',0),...
16-
'allSubRough',preAlloc);
19+
'allSubRough',preAlloc,...
20+
'resample',preAlloc);
1721

18-
% Make empty bayes results even though we may not fill it (for output purposes)
19-
bayesResults.res = [];
20-
bayesResults.chain = [];
21-
bayesResults.s2chain = [];
22-
bayesResults.ssChain = [];
23-
bayesResults.bestPars = [];
22+
if strcmpi(problemDef.TF,'domains')
23+
domains = true;
24+
else
25+
domains = false;
26+
end
27+
bayesResults = makeEmptyBayesResultsStruct(1e3, problemDef.numberOfContrasts, domains, controls.nChains);
28+
% bayesResults = struct('bayesRes',[],...
29+
% 'chain',[],...
30+
% 's2chain',[],...
31+
% 'ssChain',[],...
32+
% 'bestPars_Mean',[],...
33+
% 'bestFitsMean',[],...
34+
% 'predLims',[],...
35+
% 'parConfInts',[]);
2436

2537
outProblemDef = problemDef;
2638

2739
%Decide what we are doing....
2840
action = controls.proc;
2941
switch lower(action)
3042
case 'calculate' %Just a single reflectivity calculation
31-
[problem,results] = reflectivityCalculationWrapper(problemDef,problemDefCells,problemDefLimits,controls);
43+
[problem,results] = reflectivityCalculation(problemDef,problemDefCells,problemDefLimits,controls);
3244
outProblemDef = problemDef;
3345
case 'simplex'
3446
if ~strcmpi(controls.display,'off')
@@ -40,11 +52,11 @@
4052
sendTextOutput(sprintf('\nRunning Differential Evolution\n\n'));
4153
end
4254
[outProblemDef,problem,results] = runDE(problemDef,problemDefCells,problemDefLimits,controls);
43-
case 'ns'
44-
if ~strcmpi(controls.display,'off')
45-
sendTextOutput(sprintf('\nRunning Nested Sampler\n\n'));
46-
end
47-
[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);
4860
case 'dream'
4961
if ~strcmpi(controls.display,'off')
5062
sendTextOutput(sprintf('\nRunning DREAM\n\n'));

API/parseClassToStructs.m

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,27 @@
202202
currentPrior = priorFields{i};
203203
for j = 1:size(priors.(currentPrior), 1)
204204
allPriors{cellCount,1} = priors.(currentPrior){j}{1};
205-
allPriors{cellCount,2} = priors.(currentPrior){j}{2};
206-
allPriors{cellCount,3} = num2str(priors.(currentPrior){j}{3});
207-
allPriors{cellCount,4} = num2str(priors.(currentPrior){j}{4});
205+
206+
% Check prior type.....
207+
thisType = priors.(currentPrior){j}{2};
208+
209+
if strcmpi(thisType,'uniform')
210+
priorType = 1;
211+
elseif strcmpi(thisType,'gaussian')
212+
priorType = 2;
213+
else
214+
priorType = 3;
215+
end
216+
allPriors{cellCount,2} = priorType;
217+
218+
allPriors{cellCount,3} = priors.(currentPrior){j}{3};
219+
allPriors{cellCount,4} = priors.(currentPrior){j}{4};
208220
cellCount = cellCount + 1;
209221
end
210222
end
211223

212224
priors.priorNames = allPriors(:, 1);
213-
priors.priorVals = allPriors(:, 2:end);
225+
priors.priorVals = cell2mat(allPriors(:, 2:end)); % Note move to double now for this...
214226

215227

216228
%% Split up the contrastBacks array

API/parseResultToStruct.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
result.allLayers = results{6}; % Resampled layers
99

1010
result.calculationResults = problem.calculations;
11-
problem = rmfield(problem,'calculations');
11+
12+
% For compile, we can't remove a field, so just clear it for now...
13+
%problem = rmfield(problem,'calculations');
1214
result.contrastParams = problem;
1315

14-
end
16+
end

API/textProgressBar.m

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ function textProgressBar(curm,pct)
22

33
persistent lastNchar
44

5+
strDotsMax = 40;
6+
57
if strcmpi(curm,'init')
68
%fprintf('\n');
79
lastNchar = 0;
@@ -18,12 +20,16 @@ function textProgressBar(curm,pct)
1820
end
1921

2022
%curm = 'progress';
21-
progressmsg=[183-uint8((1:40)<=(pct*40)).*(183-'*') ''];
22-
%curmtxt=sprintf('% 9.3g\n',curm(1:min(end,20),1));
23-
progressmsg=sprintf('\n %s %5.1f%% [%s]',curm,(pct*100),progressmsg);
24-
fprintf('%s%s',repmat(char(8),1,lastNchar),progressmsg);
23+
24+
nDots = floor(pct * strDotsMax);
25+
progressmsg = ['[' repmat('*',1,nDots) repmat('.',1,strDotsMax-nDots) ']'];
26+
27+
% progressmsg=[183-uint16((1:40)<=(pct*40)).*(183-'*') ''];
28+
% %curmtxt=sprintf('% 9.3g\n',curm(1:min(end,20),1));
29+
progressmsg=sprintf('\n %s %5.1f%% %s',curm,(pct*100),progressmsg);
30+
31+
fprintf('%s%s',repmat(sprintf('\b'),1,lastNchar),progressmsg);
2532
drawnow
2633
lastNchar=length(progressmsg);
2734

2835
end
29-

addPaths.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
eventCompilePath;
2828
fullfile(root,'compile','customWrapper');
2929
fullfile(root,'compile','reflectivityCalculation');
30+
fullfile(root,'compile','fullCompile');
3031
fullfile(root,'compile','simplex');
3132
fullfile(root,'compile');
3233

0 commit comments

Comments
 (0)