Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 3rdParty/mcmcstat/runDram.m
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
% predIntRef = predIntRef.predictionIntervals;
%
% % Make sure the calc SLD flag is set in controls...
% problem{2}.calcSldDuringFit = true;
% problem{2}.calcSLD = true;
% predIntSld = mcmcpred_compile_sld(output.results,output.chain,[],output.data,problem,500);
% predIntSld = predIntSld.predictionIntervals;
%
Expand Down
2 changes: 1 addition & 1 deletion 3rdParty/mcmcstat/sldModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

problemStruct = problem{1};
controls = problem{2};
controls.calcSldDuringFit = true;
controls.calcSLD = true;

problemStruct.fitParams = pars;
problemStruct = unpackParams(problemStruct);
Expand Down
7 changes: 1 addition & 6 deletions API/RATMain.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,10 @@
results = makeEmptyResultStruct(problemStruct.numberOfContrasts, length(problemStruct.fitParams), domains);
bayesResults = makeEmptyBayesResultsStruct(problemStruct.numberOfContrasts, domains, controls.nChains);

% Set controls.calcSLD to 1 if we are doing customXY
if strcmpi(problemStruct.modelType, coderEnums.modelTypes.CustomXY)
controls.calcSldDuringFit = true;
end

if problemStruct.numberOfContrasts > 0
switch controls.procedure
case coderEnums.procedures.Calculate % Just a single reflectivity calculation
controls.calcSldDuringFit = true;
controls.calcSLD = true;
results = reflectivityCalculation(problemStruct,controls);
case coderEnums.procedures.Simplex
if ~strcmpi(controls.display, coderEnums.displayOptions.Off)
Expand Down
83 changes: 27 additions & 56 deletions API/controlsClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
% How the calculation should be parallelised (This uses the Parallel Computing Toolbox). Can be 'single', 'contrasts' or 'points'.
% procedure : procedures, default: procedures.Calculate
% Which procedure RAT should execute. Can be 'calculate', 'simplex', 'de', 'ns', or 'dream'.
% calcSldDuringFit : logical, default: false
% Whether SLD will be calculated during fit (for live plotting etc.)
% numSimulationPoints : whole number, default: 500
% The number of points used for a reflectivity simulation where no data is present.
% resampleMinAngle : float, default: 0.9
Expand Down Expand Up @@ -94,7 +92,6 @@

procedure = procedures.Calculate.value
parallel = parallelOptions.Single.value
calcSldDuringFit = false
numSimulationPoints = 500
resampleMinAngle = 0.9
resampleNPoints = 50
Expand Down Expand Up @@ -147,11 +144,6 @@
obj.procedure = validateOption(val, 'procedures', message).value;
end

function set.calcSldDuringFit(obj,val)
validateLogical(val, 'calcSldDuringFit must be logical ''true'' or ''false''');
obj.calcSldDuringFit = val;
end

function set.display(obj,val)
message = sprintf('display must be a displayOptions enum or one of the following strings (%s)', ...
strjoin(displayOptions.values(), ', '));
Expand Down Expand Up @@ -455,7 +447,6 @@
function groups = getPropertyGroups(obj)
masterPropList = struct('parallel', {obj.parallel},...
'procedure', {obj.procedure},...
'calcSldDuringFit', {obj.calcSldDuringFit},...
'display', {obj.display},...
'xTolerance', {obj.xTolerance},...
'funcTolerance', {obj.funcTolerance},...
Expand Down Expand Up @@ -539,15 +530,13 @@
%
% The parameters that can be set when using calculate procedure are
% 1) parallel
% 2) calcSldDuringFit
% 3) numSimulationPoints
% 4) resampleMinAngle
% 5) resampleNPoints
% 6) display
% 2) numSimulationPoints
% 3) resampleMinAngle
% 4) resampleNPoints
% 5) display

% The default values for Calculate
defaultParallel = parallelOptions.Single.value;
defaultCalcSldDuringFit = false;
defaultNumSimulationPoints = 500;
defaultResampleMinAngle = 0.9;
defaultResampleNPoints = 50;
Expand All @@ -557,20 +546,18 @@
p = inputParser;
p.PartialMatching = false;
addParameter(p,'parallel', defaultParallel, @(x) isText(x) || isenum(x));
addParameter(p,'calcSldDuringFit', defaultCalcSldDuringFit, @islogical);
addParameter(p,'numSimulationPoints', defaultNumSimulationPoints, @isnumeric);
addParameter(p,'resampleMinAngle', defaultResampleMinAngle, @isnumeric);
addParameter(p,'resampleNPoints', defaultResampleNPoints, @isnumeric);
addParameter(p,'display', defaultDisplay, @(x) isText(x) || isenum(x));
properties = varargin{:};

% Parses the input or raises invalidOption error
errorMsg = 'Only parallel, calcSldDuringFit, numSimulationPoints, resampleMinAngle, resampleNPoints and display can be set while using the Calculate procedure';
errorMsg = 'Only parallel, numSimulationPoints, resampleMinAngle, resampleNPoints and display can be set while using the Calculate procedure';
inputBlock = obj.parseInputs(p, properties, errorMsg);

% Sets the values the for Calculate parameters
obj.parallel = inputBlock.parallel;
obj.calcSldDuringFit = inputBlock.calcSldDuringFit;
obj.numSimulationPoints = inputBlock.numSimulationPoints;
obj.resampleMinAngle = inputBlock.resampleMinAngle;
obj.resampleNPoints = inputBlock.resampleNPoints;
Expand All @@ -590,11 +577,10 @@
% 5) updateFreq
% 6) updatePlotFreq
% 7) parallel
% 8) calcSldDuringFit
% 9) numSimulationPoints
% 10) resampleMinAngle
% 11) resampleNPoints
% 12) display
% 8) numSimulationPoints
% 9) resampleMinAngle
% 10) resampleNPoints
% 11) display

% The simplex default values
defaultXTolerance = 1e-6;
Expand All @@ -604,7 +590,6 @@
defaultUpdateFreq = 1;
defaultUpdatePlotFreq = 20;
defaultParallel = parallelOptions.Single.value;
defaultCalcSldDuringFit = false;
defaultNumSimulationPoints = 500;
defaultResampleMinAngle = 0.9;
defaultResampleNPoints = 50;
Expand All @@ -620,15 +605,14 @@
addParameter(p,'updateFreq', defaultUpdateFreq, @isnumeric);
addParameter(p,'updatePlotFreq', defaultUpdatePlotFreq, @isnumeric);
addParameter(p,'parallel', defaultParallel, @(x) isText(x) || isenum(x));
addParameter(p,'calcSldDuringFit', defaultCalcSldDuringFit, @islogical);
addParameter(p,'numSimulationPoints', defaultNumSimulationPoints, @isnumeric);
addParameter(p,'resampleMinAngle', defaultResampleMinAngle, @isnumeric);
addParameter(p,'resampleNPoints', defaultResampleNPoints, @isnumeric);
addParameter(p,'display', defaultDisplay, @(x) isText(x) || isenum(x));
properties = varargin{:};

% Parses the input or raises invalidOption error
errorMsg = 'Only xTolerance, funcTolerance, maxFuncEvals, maxIterations, updateFreq, updatePlotFreq, parallel, calcSldDuringFit, numSimulationPoints, resampleMinAngle, resampleNPoints and display can be set while using the Simplex procedure.';
errorMsg = 'Only xTolerance, funcTolerance, maxFuncEvals, maxIterations, updateFreq, updatePlotFreq, parallel, numSimulationPoints, resampleMinAngle, resampleNPoints and display can be set while using the Simplex procedure.';
inputBlock = obj.parseInputs(p, properties, errorMsg);

% Sets the values the for simplex parameters
Expand All @@ -639,7 +623,6 @@
obj.updateFreq = inputBlock.updateFreq;
obj.updatePlotFreq = inputBlock.updatePlotFreq;
obj.parallel = inputBlock.parallel;
obj.calcSldDuringFit = inputBlock.calcSldDuringFit;
obj.numSimulationPoints = inputBlock.numSimulationPoints;
obj.resampleMinAngle = inputBlock.resampleMinAngle;
obj.resampleNPoints = inputBlock.resampleNPoints;
Expand All @@ -659,13 +642,12 @@
% 5) targetValue
% 6) numGenerations
% 7) parallel
% 8) calcSldDuringFit
% 9) numSimulationPoints
% 10) resampleMinAngle
% 11) resampleNPoints
% 12) display
% 13) updateFreq
% 14) updatePlotFreq
% 8) numSimulationPoints
% 9) resampleMinAngle
% 10) resampleNPoints
% 11) display
% 12) updateFreq
% 13) updatePlotFreq

% The default values for DE
defaultPopulationSize = 20;
Expand All @@ -675,7 +657,6 @@
defaultTargetValue = 1;
defaultNumGenerations = 500;
defaultParallel = parallelOptions.Single.value;
defaultCalcSldDuringFit = false;
defaultNumSimulationPoints = 500;
defaultResampleMinAngle = 0.9;
defaultResampleNPoints = 50;
Expand All @@ -693,7 +674,6 @@
addParameter(p,'targetValue', defaultTargetValue, @isnumeric);
addParameter(p,'numGenerations', defaultNumGenerations, @isnumeric);
addParameter(p,'parallel', defaultParallel, @(x) isText(x) || isenum(x));
addParameter(p,'calcSldDuringFit', defaultCalcSldDuringFit, @islogical);
addParameter(p,'numSimulationPoints', defaultNumSimulationPoints, @isnumeric);
addParameter(p,'resampleMinAngle', defaultResampleMinAngle, @isnumeric);
addParameter(p,'resampleNPoints', defaultResampleNPoints, @isnumeric);
Expand All @@ -703,7 +683,7 @@
properties = varargin{:};

% Parses the input or raises invalidOption error
errorMsg = 'Only populationSize, fWeight, crossoverProbability, strategy, targetValue, numGenerations, parallel, calcSldDuringFit, numSimulationPoints, resampleMinAngle, resampleNPoints, display, updateFreq, and updatePlotFreq can be set while using the Differential Evolution procedure';
errorMsg = 'Only populationSize, fWeight, crossoverProbability, strategy, targetValue, numGenerations, parallel, numSimulationPoints, resampleMinAngle, resampleNPoints, display, updateFreq, and updatePlotFreq can be set while using the Differential Evolution procedure';
inputBlock = obj.parseInputs(p, properties, errorMsg);

% Sets the values the for DE parameters
Expand All @@ -714,7 +694,6 @@
obj.targetValue = inputBlock.targetValue;
obj.numGenerations = inputBlock.numGenerations;
obj.parallel = inputBlock.parallel;
obj.calcSldDuringFit = inputBlock.calcSldDuringFit;
obj.numSimulationPoints = inputBlock.numSimulationPoints;
obj.resampleMinAngle = inputBlock.resampleMinAngle;
obj.resampleNPoints = inputBlock.resampleNPoints;
Expand All @@ -734,19 +713,17 @@
% 3) propScale
% 4) nsTolerance
% 5) parallel
% 6) calcSldDuringFit
% 7) numSimulationPoints
% 8) resampleMinAngle
% 9) resampleNPoints
% 10) display
% 6) numSimulationPoints
% 7) resampleMinAngle
% 8) resampleNPoints
% 9) display

% The default values for NS
defaultnLive = 150;
defaultnMCMC = 0;
defaultPropScale = 0.1;
defaultNsTolerance = 0.1;
defaultParallel = parallelOptions.Single.value;
defaultCalcSldDuringFit = false;
defaultNumSimulationPoints = 500;
defaultResampleMinAngle = 0.9;
defaultResampleNPoints = 50;
Expand All @@ -760,15 +737,14 @@
addParameter(p,'propScale', defaultPropScale, @isnumeric);
addParameter(p,'nsTolerance', defaultNsTolerance, @isnumeric);
addParameter(p,'parallel', defaultParallel, @(x) isText(x) || isenum(x));
addParameter(p,'calcSldDuringFit', defaultCalcSldDuringFit, @islogical);
addParameter(p,'numSimulationPoints', defaultNumSimulationPoints, @isnumeric);
addParameter(p,'resampleMinAngle', defaultResampleMinAngle, @isnumeric);
addParameter(p,'resampleNPoints', defaultResampleNPoints, @isnumeric);
addParameter(p,'display', defaultDisplay, @(x) isText(x) || isenum(x));
properties = varargin{:};

% Parses the input or raises invalidOption error
errorMsg = 'Only nLive, nMCMC, propScale, nsTolerance, parallel, calcSldDuringFit, numSimulationPoints, resampleMinAngle, resampleNPoints and display can be set while using the Nested Sampler procedure';
errorMsg = 'Only nLive, nMCMC, propScale, nsTolerance, parallel, numSimulationPoints, resampleMinAngle, resampleNPoints and display can be set while using the Nested Sampler procedure';
inputBlock = obj.parseInputs(p, properties, errorMsg);

% Sets the values the for NS parameters
Expand All @@ -777,7 +753,6 @@
obj.propScale = inputBlock.propScale;
obj.nsTolerance = inputBlock.nsTolerance;
obj.parallel = inputBlock.parallel;
obj.calcSldDuringFit = inputBlock.calcSldDuringFit;
obj.numSimulationPoints = inputBlock.numSimulationPoints;
obj.resampleMinAngle = inputBlock.resampleMinAngle;
obj.resampleNPoints = inputBlock.resampleNPoints;
Expand All @@ -797,11 +772,10 @@
% 5) boundHandling
% 6) adaptPCR
% 7) parallel
% 8) calcSldDuringFit
% 9) numSimulationPoints
% 10) resampleMinAngle
% 11) resampleNPoints
% 12) display
% 8) numSimulationPoints
% 9) resampleMinAngle
% 10) resampleNPoints
% 11) display

% The default values for Dream
defaultNSamples = 50000;
Expand All @@ -811,7 +785,6 @@
defaultBoundHandling = boundHandlingOptions.Fold.value;
defaultAdaptPCR = false;
defaultParallel = parallelOptions.Single.value;
defaultCalcSldDuringFit = false;
defaultNumSimulationPoints = 500;
defaultResampleMinAngle = 0.9;
defaultResampleNPoints = 50;
Expand All @@ -827,15 +800,14 @@
addParameter(p,'boundHandling', defaultBoundHandling, @(x) isText(x) || isenum(x));
addParameter(p,'adaptPCR', defaultAdaptPCR, @islogical);
addParameter(p,'parallel', defaultParallel, @(x) isText(x) || isenum(x));
addParameter(p,'calcSldDuringFit', defaultCalcSldDuringFit, @islogical);
addParameter(p,'numSimulationPoints', defaultNumSimulationPoints, @isnumeric);
addParameter(p,'resampleMinAngle', defaultResampleMinAngle, @isnumeric);
addParameter(p,'resampleNPoints', defaultResampleNPoints, @isnumeric);
addParameter(p,'display', defaultDisplay, @(x) isText(x) || isenum(x));
properties = varargin{:};

% Parses the input or raises invalidOption error
errorMsg = 'Only nSamples, nChains, jumpProbability, pUnitGamma, boundHandling, adaptPCR, parallel, calcSldDuringFit, numSimulationPoints, resampleMinAngle, resampleNPoints and display can be set while using the DREAM procedure';
errorMsg = 'Only nSamples, nChains, jumpProbability, pUnitGamma, boundHandling, adaptPCR, parallel, numSimulationPoints, resampleMinAngle, resampleNPoints and display can be set while using the DREAM procedure';
inputBlock = obj.parseInputs(p, properties, errorMsg);

% Sets the values the for Dream parameters
Expand All @@ -846,7 +818,6 @@
obj.boundHandling = inputBlock.boundHandling;
obj.adaptPCR = inputBlock.adaptPCR;
obj.parallel = inputBlock.parallel;
obj.calcSldDuringFit = inputBlock.calcSldDuringFit;
obj.numSimulationPoints = inputBlock.numSimulationPoints;
obj.resampleMinAngle = inputBlock.resampleMinAngle;
obj.resampleNPoints = inputBlock.resampleNPoints;
Expand Down
1 change: 1 addition & 0 deletions API/parseClassToStructs.m
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@
controls.(controlsFields{i}) = inputControls.(controlsFields{i});
end

controls.calcSLD = false;
controls.IPCFilePath = inputControls.getIPCFilePath();

%% Finally, populate the fitParams and fitLimits arrays
Expand Down
2 changes: 1 addition & 1 deletion compile/fullCompile/makeCompileArgsFull.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
ARGS_1_2 = struct;
ARGS_1_2.procedure = coder.typeof('X',[1 maxArraySize],[0 1]);
ARGS_1_2.parallel = coder.typeof('X',[1 maxArraySize],[0 1]);
ARGS_1_2.calcSldDuringFit = coder.typeof(true);
ARGS_1_2.numSimulationPoints = coder.typeof(0);
ARGS_1_2.resampleMinAngle = coder.typeof(0);
ARGS_1_2.resampleNPoints = coder.typeof(0);
Expand All @@ -111,6 +110,7 @@
ARGS_1_2.pUnitGamma = coder.typeof(0);
ARGS_1_2.boundHandling = coder.typeof('X',[1 maxArraySize],[0 1]);
ARGS_1_2.adaptPCR = coder.typeof(true);
ARGS_1_2.calcSLD = coder.typeof(true);
ARGS_1_2.IPCFilePath = coder.typeof('X',[1 maxArraySize],[0 1]);
ARGS{1}{2} = coder.typeof(ARGS_1_2);

Expand Down
2 changes: 1 addition & 1 deletion compile/reflectivityCalculation/makeCompileArgs.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
ARGS_1_2 = struct;
ARGS_1_2.procedure = coder.typeof('X',[1 maxArraySize],[0 1]);
ARGS_1_2.parallel = coder.typeof('X',[1 maxArraySize],[0 1]);
ARGS_1_2.calcSldDuringFit = coder.typeof(true);
ARGS_1_2.numSimulationPoints = coder.typeof(0);
ARGS_1_2.resampleMinAngle = coder.typeof(0);
ARGS_1_2.resampleNPoints = coder.typeof(0);
Expand All @@ -111,6 +110,7 @@
ARGS_1_2.pUnitGamma = coder.typeof(0);
ARGS_1_2.boundHandling = coder.typeof('X',[1 maxArraySize],[0 1]);
ARGS_1_2.adaptPCR = coder.typeof(true);
ARGS_1_2.calcSLD = coder.typeof(true);
ARGS_1_2.IPCFilePath = coder.typeof('X',[1 maxArraySize],[0 1]);
ARGS{1}{2} = coder.typeof(ARGS_1_2);

Expand Down
1 change: 0 additions & 1 deletion examples/miscellaneous/bayesBenchmark/directCompare2D.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
d2oproblem = r1ToProjectClass(fullfile(root, 'utilities', 'misc', 'defaultR1ProjectTemplate.mat'));

controls = controlsClass();
controls.calcSldDuringFit = true;
controls.nsTolerance = 1;
controls.nLive = 500;
d2oproblem.setScalefactor(1,'fit',false);
Expand Down
1 change: 0 additions & 1 deletion examples/miscellaneous/bayesBenchmark/directCompare3D.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
d2oproblem = r1ToProjectClass(fullfile(root, 'utilities', 'misc', 'defaultR1ProjectTemplate.mat'));

controls = controlsClass();
controls.calcSldDuringFit = true;
controls.nsTolerance = 1;
controls.nLive = 500;

Expand Down
4 changes: 2 additions & 2 deletions minimisers/DE/runDE.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
S_struct.FVr_lim_lo = FVr_lim_lo;

S_struct.I_NP = I_NP;
S_struct.fWeight = fWeight;
S_struct.fWeight = fWeight;
S_struct.F_CR = F_CR;
S_struct.I_D = I_D;
S_struct.FVr_minbound = FVr_minbound;
Expand All @@ -97,7 +97,7 @@
problemStruct.fitParams = res;
problemStruct = unpackParams(problemStruct);
% Ensure SLD is calculated for final result
controls.calcSldDuringFit = true;
controls.calcSLD = true;
result = reflectivityCalculation(problemStruct,controls);

if ~strcmpi(controls.display, coderEnums.displayOptions.Off)
Expand Down
2 changes: 1 addition & 1 deletion minimisers/generalUtils/bayesStats/processBayes.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
% The Bayesian-specific results from the optimisation.

% Need to impose that we calculate the SLD
controls.calcSldDuringFit = true;
controls.calcSLD = true;

% ... and use the Bayes best params
problemStruct.fitParams = bayesOutputs.bestParams;
Expand Down
Loading