diff --git a/API/controlsClass.m b/API/controlsClass.m index df2ed10a8..a8a96d8cb 100644 --- a/API/controlsClass.m +++ b/API/controlsClass.m @@ -1,5 +1,5 @@ classdef controlsClass < handle & matlab.mixin.CustomDisplay - + properties % Parallelisation Option (Default: parallelOptions.Single) parallel = parallelOptions.Single.value @@ -7,14 +7,17 @@ procedure = procedures.Calculate.value % Indicates if SLD should be calculated (Default: false) calcSldDuringFit = false - resampleParams = [0.9 50] + % minimum angle for resampling (Default: 0.9) + resampleMinAngle = 0.9 + % number of points for resampling (Default: 50) + resampleNPoints = 50 % Display Option (Default: displayOptions.Iter) display = displayOptions.Iter.value updateFreq = 1 updatePlotFreq = 20 - + % optimization tolerance for simplex (Default: 1e-6) - xTolerance = 1e-6 + xTolerance = 1e-6 funcTolerance = 1e-6 % Maximum number of function evaluations for simplex (Default: 10000) maxFuncEvals = 10000 @@ -33,31 +36,31 @@ targetValue = 1 % Maximum number of generations (Default: 500) numGenerations = 500 - + % Number of live points for Nested Sampler (Default: 150) nLive = 150 nMCMC = 0 propScale = 0.1 % Used if MCMC is used % Target stopping tolerance for Nested Sampler (Default: 0.1) - nsTolerance = 0.1 - + nsTolerance = 0.1 + % Total number of samples for DREAM (Default: 20000) nSamples = 20000; - % Number of MCMC chains (Default: 10) + % Number of MCMC chains (Default: 10) nChains = 10 - % Jump probabilities (Default: 0.5) - jumpProbability = 0.5 + % Jump probabilities (Default: 0.5) + jumpProbability = 0.5 pUnitGamma = 0.2 % Boundary handling - boundHandling = boundHandlingOptions.Reflect.value + boundHandling = boundHandlingOptions.Reflect.value adaptPCR = true; end - - + + properties (SetAccess = private, Hidden = true) IPCFilePath = '' end - + %------------------------- Set and Get ------------------------------ methods function set.parallel(obj,val) @@ -65,24 +68,24 @@ strjoin(parallelOptions.values(), ', ')); obj.parallel = validateOption(val, 'parallelOptions', message).value; end - + function set.procedure(obj,val) message = sprintf('procedure must be a procedures enum or one of the following strings (%s)', ... strjoin(procedures.values(), ', ')); 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(), ', ')); obj.display = validateOption(val, 'displayOptions', message).value; end - + function set.updatePlotFreq(obj, val) validateNumber(val, 'updatePlotFreq must be a whole number', true); if val < 1 @@ -90,40 +93,40 @@ end obj.updatePlotFreq = val; end - - function set.resampleParams(obj,val) - if length(val) ~= 2 - throw(exceptions.invalidValue('resampleParams must have length of 2')); - end - - validateNumber(val, 'resampleParams must be a number array'); - - if (val(1) < 0 || val(1) > 1) - throw(exceptions.invalidValue('resampleParams(0) must be between 0 and 1')); + + function set.resampleMinAngle(obj,val) + validateNumber(val, 'resampleMinAngle must be a number'); + if (val <= 0 || val > 1) + throw(exceptions.invalidValue('resampleMinAngle must be between 0 and 1')); end - if val(2) <= 0 - throw(exceptions.invalidValue('resampleParams(1) must be greater than 0')); + obj.resampleMinAngle = val; + end + + function set.resampleNPoints(obj,val) + validateNumber(val, 'resampleNPoints must be a whole number', true); + if (val <= 0) + throw(exceptions.invalidValue('resampleNPoints must be greater than 0')); end - obj.resampleParams = val; + obj.resampleNPoints = val; end - + % Simplex control methods function set.xTolerance(obj, val) obj.xTolerance = validateNumber(val, 'xTolerance must be a number'); end - + function set.funcTolerance(obj, val) obj.funcTolerance = validateNumber(val, 'funcTolerance must be a number'); end - + function set.maxFuncEvals(obj, val) obj.maxFuncEvals = validateNumber(val, 'maxFuncEvals must be a whole number', true); end - + function set.maxIterations(obj, val) obj.maxIterations = validateNumber(val, 'maxIterations must be a whole number', true); end - + % DE controls methods function set.populationSize(obj, val) validateNumber(val, 'populationSize must be a whole number', true); @@ -132,11 +135,11 @@ end obj.populationSize = val; end - + function set.fWeight(obj,val) obj.fWeight = validateNumber(val,'fWeight must be a number'); end - + function set.crossoverProbability(obj,val) validateNumber(val, 'crossoverProbability must be a number'); if (val < 0 || val > 1) @@ -144,14 +147,14 @@ end obj.crossoverProbability = val; end - + function set.strategy(obj,val) message = sprintf('strategy must be a searchStrategy enum or one of the following integers (%s)', ... strjoin(string(searchStrategy.values()), ', ')); - + obj.strategy = validateOption(val, 'searchStrategy', message).value; end - + function set.targetValue(obj,val) validateNumber(val, 'targetValue must be a number'); if val < 1 @@ -159,7 +162,7 @@ end obj.targetValue = val; end - + function set.numGenerations(obj, val) validateNumber(val, 'numGenerations value must be a whole number', true); if val < 1 @@ -167,7 +170,7 @@ end obj.numGenerations = val; end - + % NS control methods function set.nLive(obj, val) validateNumber(val, 'nLive must be a whole number', true); @@ -176,7 +179,7 @@ end obj.nLive = val; end - + function set.nMCMC(obj, val) validateNumber(val, 'nMCMC must be a whole number', true); if val < 0 @@ -184,7 +187,7 @@ end obj.nMCMC = val; end - + function set.propScale(obj, val) validateNumber(val, 'propScale must be a number'); if (val < 0 || val > 1) @@ -192,7 +195,7 @@ end obj.propScale = val; end - + function set.nsTolerance(obj,val) validateNumber(val, 'nsTolerance must be a number '); if val < 0 @@ -200,7 +203,7 @@ end obj.nsTolerance = val; end - + % DREAM methods function set.nSamples(obj,val) validateNumber(val, 'nSamples must be a whole number', true); @@ -209,7 +212,7 @@ end obj.nSamples = val; end - + function set.nChains(obj,val) validateNumber(val, 'nChains must be a whole number', true); if val <= 0 @@ -217,7 +220,7 @@ end obj.nChains = val; end - + function set.jumpProbability(obj,val) validateNumber(val, 'jumpProbability must be a number'); if (val < 0 || val > 1) @@ -225,7 +228,7 @@ end obj.jumpProbability = val; end - + function set.pUnitGamma(obj,val) validateNumber(val, 'pUnitGamma must be a number'); if (val < 0 || val > 1) @@ -233,35 +236,35 @@ end obj.pUnitGamma = val; end - + function set.boundHandling(obj,val) message = sprintf('boundHandling must be a boundHandlingOptions enum or one of the following strings (%s)', ... strjoin(boundHandlingOptions.values(), ', ')); obj.boundHandling = validateOption(val, 'boundHandlingOptions', message).value; end - + function set.adaptPCR(obj,val) validateLogical(val, 'adaptPCR must be logical ''true'' or ''false'''); obj.adaptPCR = val; end - - + + function obj = setProcedure(obj, procedure, varargin) % Method sets the properties of the class based on the selected procedures. % - % USAGE: + % USAGE: % obj.setProcedure(procedure, varargin) % - % EXAMPLE: + % EXAMPLE: % * obj.setProcedure('simplex', {'xTolerance', 1e-6, 'funcTolerance', 1e-6,'maxFuncEvals', 1000}) % * obj.setProcedure('dream') % * obj.setProcedure('ns', {'nLive', 150,'nMCMC', 0, 'propScale', 0.1, 'nsTolerance', 0.1}) message = sprintf(['%s is not a supported procedure. The procedure must be a procedures enum or one of ' ... - 'the following strings (%s)'], procedure, strjoin(procedures.values(), ', ')); + 'the following strings (%s)'], procedure, strjoin(procedures.values(), ', ')); procedure = validateOption(procedure, 'procedures', message).value; switch procedure - + case procedures.Calculate.value % Parses the inputs and sets the object properties of % the Calculate procedure @@ -269,7 +272,7 @@ obj = obj.processCalculateInput(varargin{:}); end obj.procedure = procedures.Calculate.value; - + case procedures.Simplex.value % Parses the inputs and sets the object properties of % the Simplex procedure @@ -277,7 +280,7 @@ obj = obj.processSimplexInput(varargin{:}); end obj.procedure = procedures.Simplex.value; - + case procedures.DE.value % Parses the inputs and sets the object properties of % the Differential Evolution procedure @@ -285,7 +288,7 @@ obj = obj.processDEInput(varargin{:}); end obj.procedure = procedures.DE.value; - + case procedures.NS.value % Parses the inputs and sets the object properties of % the Nested Sampler procedure @@ -293,7 +296,7 @@ obj = obj.processNSInput(varargin{:}); end obj.procedure = procedures.NS.value; - + case procedures.Dream.value % Parses the inputs and sets the object properties of % the DREAM procedure @@ -302,7 +305,7 @@ end obj.procedure = procedures.Dream.value; end - + end function obj = initialiseIPC(obj) @@ -315,7 +318,7 @@ fwrite(fileID, false, 'uchar'); fclose(fileID); end - + function path = getIPCFilePath(obj) % Returns the path of the IPC file. % @@ -337,7 +340,7 @@ fclose(fileID); end end - + %------------------------- Display Methods -------------------------- methods (Access = protected) function groups = getPropertyGroups(obj) @@ -361,39 +364,40 @@ 'nMCMC', {obj.nMCMC},... 'propScale', {obj.propScale},... 'nsTolerance', {obj.nsTolerance},... - 'resampleParams', {obj.resampleParams},... + 'resampleMinAngle', {obj.resampleMinAngle},... + 'resampleNPoints', {obj.resampleNPoints},... 'nSamples', {obj.nSamples},... 'nChains', {obj.nChains},... 'jumpProbability', {obj.jumpProbability},... 'pUnitGamma', {obj.pUnitGamma},... 'boundHandling', {obj.boundHandling},... 'adaptPCR', {obj.adaptPCR}); - + simplexCell = {'xTolerance',... 'funcTolerance',... 'maxFuncEvals',... 'maxIterations',... }; - + deCell = {'populationSize',... 'fWeight',... 'crossoverProbability',... 'strategy',... 'targetValue',... 'numGenerations'}; - + nsCell = {'nLive',... 'nMCMC',... 'propScale',... 'nsTolerance'}; - + dreamCell = {'nSamples',... 'nChains',... 'jumpProbability',... 'pUnitGamma',... 'boundHandling',... 'adaptPCR'}; - + if isscalar(obj) dispPropList = masterPropList; if strcmpi(obj.procedure, 'calculate') @@ -414,10 +418,10 @@ end end end - + %------------------------- Parsing Methods -------------------------- methods (Access = private) - + function obj = processCalculateInput(obj, varargin) % Parses calculate keyword/value pairs and sets the properties of the class. % @@ -426,34 +430,38 @@ % The parameters that can be set when using calculate procedure are % 1) parallel % 2) calcSldDuringFit - % 3) resampleParams - % 4) display - + % 3) resampleMinAngle + % 4) resampleNPoints + % 5) display + % The default values for Calculate defaultParallel = parallelOptions.Single.value; defaultCalcSldDuringFit = false; - defaultResampleParams = [0.9 50]; + defaultMinAngle = 0.9; + defaultNPoints = 50; defaultDisplay = displayOptions.Iter.value; - + % Creates the input parser for the calculate parameters p = inputParser; addParameter(p,'parallel', defaultParallel, @(x) isText(x) || isenum(x)); addParameter(p,'calcSldDuringFit', defaultCalcSldDuringFit, @islogical); - addParameter(p,'resampleParams', defaultResampleParams, @isnumeric); + addParameter(p,'resampleMinAngle', defaultMinAngle, @isnumeric); + addParameter(p,'resampleNPoints', defaultNPoints, @isnumeric); addParameter(p,'display', defaultDisplay, @(x) isText(x) || isenum(x)); properties = varargin{:}; - + % Parses the input or raises invalidOption error - errorMsg = 'Only parallel, calcSldDuringFit, resampleParams and display can be set while using the Calculate procedure'; + errorMsg = 'Only parallel, calcSldDuringFit, 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.resampleParams = inputBlock.resampleParams; + obj.resampleMinAngle = inputBlock.resampleMinAngle; + obj.resampleNPoints = inputBlock.resampleNPoints; obj.display = inputBlock.display; end - + function obj = processSimplexInput(obj, varargin) % Parses simplex keyword/value pairs and sets the properties of the class. % @@ -468,9 +476,10 @@ % 6) updatePlotFreq % 7) parallel % 8) calcSldDuringFit - % 9) resampleParams - % 10) display - + % 9) resampleMinAngle + % 10) resampleNPoints + % 11) display + % The simplex default values defaultXTolerance = 1e-6; defaultFuncTolerance = 1e-6; @@ -480,9 +489,10 @@ defaultUpdatePlotFreq = 20; defaultParallel = parallelOptions.Single.value; defaultCalcSldDuringFit = false; - defaultResampleParams = [0.9 50]; + defaultMinAngle = 0.9; + defaultNPoints = 50; defaultDisplay = displayOptions.Iter.value; - + % Parses the input for simplex parameters p = inputParser; addParameter(p,'xTolerance', defaultXTolerance, @isnumeric); @@ -493,14 +503,15 @@ addParameter(p,'updatePlotFreq', defaultUpdatePlotFreq, @isnumeric); addParameter(p,'parallel', defaultParallel, @(x) isText(x) || isenum(x)); addParameter(p,'calcSldDuringFit', defaultCalcSldDuringFit, @islogical); - addParameter(p,'resampleParams', defaultResampleParams, @isnumeric); + addParameter(p,'resampleMinAngle', defaultMinAngle, @isnumeric); + addParameter(p,'resampleNPoints', defaultNPoints, @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, resampleParams and display can be set while using the Simplex procedure.'; + errorMsg = 'Only xTolerance, funcTolerance, maxFuncEvals, maxIterations, updateFreq, updatePlotFreq, parallel, calcSldDuringFit, 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 obj.xTolerance = inputBlock.xTolerance; obj.funcTolerance = inputBlock.funcTolerance; @@ -510,10 +521,11 @@ obj.updatePlotFreq = inputBlock.updatePlotFreq; obj.parallel = inputBlock.parallel; obj.calcSldDuringFit = inputBlock.calcSldDuringFit; - obj.resampleParams = inputBlock.resampleParams; + obj.resampleMinAngle = inputBlock.resampleMinAngle; + obj.resampleNPoints = inputBlock.resampleNPoints; obj.display = inputBlock.display; end - + function obj = processDEInput(obj, varargin) % Parses differential evolution keyword/value pairs and sets the properties of the class. % @@ -528,11 +540,12 @@ % 6) numGenerations % 7) parallel % 8) calcSldDuringFit - % 9) resampleParams - % 10) display - % 11) updateFreq - % 12) updatePlotFreq - + % 9) resampleMinAngle + % 10) resampleNPoints + % 11) display + % 12) updateFreq + % 13) updatePlotFreq + % The default values for DE defaultPopulationSize = 20; defaultFWeight = 0.5; @@ -542,11 +555,12 @@ defaultNumGenerations = 500; defaultParallel = parallelOptions.Single.value; defaultCalcSldDuringFit = false; - defaultResampleParams = [0.9 50]; + defaultMinAngle = 0.9; + defaultNPoints = 50; defaultDisplay = displayOptions.Iter.value; defaultUpdateFreq = 1; defaultUpdatePlotFreq = 20; - + % Creates the input parser for the DE parameters p = inputParser; addParameter(p,'populationSize', defaultPopulationSize, @isnumeric); @@ -557,16 +571,17 @@ addParameter(p,'numGenerations', defaultNumGenerations, @isnumeric); addParameter(p,'parallel', defaultParallel, @(x) isText(x) || isenum(x)); addParameter(p,'calcSldDuringFit', defaultCalcSldDuringFit, @islogical); - addParameter(p,'resampleParams', defaultResampleParams, @isnumeric); + addParameter(p,'resampleMinAngle', defaultMinAngle, @isnumeric); + addParameter(p,'resampleNPoints', defaultNPoints, @isnumeric); addParameter(p,'display', defaultDisplay, @(x) isText(x) || isenum(x)); addParameter(p,'updateFreq', defaultUpdateFreq, @isnumeric); addParameter(p,'updatePlotFreq', defaultUpdatePlotFreq, @isnumeric); properties = varargin{:}; - + % Parses the input or raises invalidOption error - errorMsg = 'Only populationSize, fWeight, crossoverProbability, strategy, targetValue, numGenerations, parallel, calcSldDuringFit, resampleParams, display, updateFreq, and updatePlotFreq can be set while using the Differential Evolution procedure'; + errorMsg = 'Only populationSize, fWeight, crossoverProbability, strategy, targetValue, numGenerations, parallel, calcSldDuringFit, 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 obj.populationSize = inputBlock.populationSize; obj.fWeight = inputBlock.fWeight; @@ -576,12 +591,13 @@ obj.numGenerations = inputBlock.numGenerations; obj.parallel = inputBlock.parallel; obj.calcSldDuringFit = inputBlock.calcSldDuringFit; - obj.resampleParams = inputBlock.resampleParams; + obj.resampleMinAngle = inputBlock.resampleMinAngle; + obj.resampleNPoints = inputBlock.resampleNPoints; obj.display = inputBlock.display; obj.updateFreq = inputBlock.updateFreq; obj.updatePlotFreq = inputBlock.updatePlotFreq; end - + function obj = processNSInput(obj, varargin) % Parses nested sampler keyword/value pairs and sets the properties of the class. % @@ -594,9 +610,10 @@ % 4) nsTolerance % 5) parallel % 6) calcSldDuringFit - % 7) resampleParams - % 8) display - + % 7) resampleMinAngle + % 8) resampleNPoints + % 9) display + % The default values for NS defaultnLive = 150; defaultnMCMC = 0; @@ -604,9 +621,10 @@ defaultNsTolerance = 0.1; defaultParallel = parallelOptions.Single.value; defaultCalcSldDuringFit = false; - defaultResampleParams = [0.9 50]; + defaultMinAngle = 0.9; + defaultNPoints = 50; defaultDisplay = displayOptions.Iter.value; - + % Creates the input parser for the NS parameters p = inputParser; addParameter(p,'nLive', defaultnLive, @isnumeric); @@ -615,14 +633,15 @@ addParameter(p,'nsTolerance', defaultNsTolerance, @isnumeric); addParameter(p,'parallel', defaultParallel, @(x) isText(x) || isenum(x)); addParameter(p,'calcSldDuringFit', defaultCalcSldDuringFit, @islogical); - addParameter(p,'resampleParams', defaultResampleParams, @isnumeric); + addParameter(p,'resampleMinAngle', defaultMinAngle, @isnumeric); + addParameter(p,'resampleNPoints', defaultNPoints, @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, resampleParams and display can be set while using the Nested Sampler procedure'; + errorMsg = 'Only nLive, nMCMC, propScale, nsTolerance, parallel, calcSldDuringFit, 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 obj.nLive = inputBlock.nLive; obj.nMCMC = inputBlock.nMCMC; @@ -630,10 +649,11 @@ obj.nsTolerance = inputBlock.nsTolerance; obj.parallel = inputBlock.parallel; obj.calcSldDuringFit = inputBlock.calcSldDuringFit; - obj.resampleParams = inputBlock.resampleParams; + obj.resampleMinAngle = inputBlock.resampleMinAngle; + obj.resampleNPoints = inputBlock.resampleNPoints; obj.display = inputBlock.display; end - + function obj = processDreamInput(obj, varargin) % Parses Dream keyword/value pairs and sets the properties of the class. % @@ -648,9 +668,10 @@ % 6) adaptPCR % 7) parallel % 8) calcSldDuringFit - % 9) resampleParams - % 10) display - + % 9) resampleMinAngle + % 10) resampleNPoints + % 11) display + % The default values for Dream defaultNSamples = 50000; defaultNChains = 10; @@ -660,9 +681,10 @@ defaultAdaptPCR = false; defaultParallel = parallelOptions.Single.value; defaultCalcSldDuringFit = false; - defaultResampleParams = [0.9 50]; + defaultMinAngle = 0.9; + defaultNPoints = 50; defaultDisplay = displayOptions.Iter.value; - + % Creates the input parser for the Dream parameters p = inputParser; addParameter(p,'nSamples', defaultNSamples, @isnumeric); @@ -673,14 +695,15 @@ addParameter(p,'adaptPCR', defaultAdaptPCR, @islogical); addParameter(p,'parallel', defaultParallel, @(x) isText(x) || isenum(x)); addParameter(p,'calcSldDuringFit', defaultCalcSldDuringFit, @islogical); - addParameter(p,'resampleParams', defaultResampleParams, @isnumeric); + addParameter(p,'resampleMinAngle', defaultMinAngle, @isnumeric); + addParameter(p,'resampleNPoints', defaultNPoints, @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, resampleParams and display can be set while using the DREAM procedure'; + errorMsg = 'Only nSamples, nChains, jumpProbability, pUnitGamma, boundHandling, adaptPCR, parallel, calcSldDuringFit, 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 obj.nSamples = inputBlock.nSamples; obj.nChains = inputBlock.nChains; @@ -690,10 +713,11 @@ obj.adaptPCR = inputBlock.adaptPCR; obj.parallel = inputBlock.parallel; obj.calcSldDuringFit = inputBlock.calcSldDuringFit; - obj.resampleParams = inputBlock.resampleParams; + obj.resampleMinAngle = inputBlock.resampleMinAngle; + obj.resampleNPoints = inputBlock.resampleNPoints; obj.display = inputBlock.display; end - + function inputBlock = parseInputs(~, p, properties, errorMsg) % Parses the input or raises invalidOption error try @@ -707,6 +731,6 @@ end end end - + end end diff --git a/API/parseClassToStructs.m b/API/parseClassToStructs.m index fe73c0eb7..4d8386272 100644 --- a/API/parseClassToStructs.m +++ b/API/parseClassToStructs.m @@ -393,7 +393,8 @@ %% Now deal with the controls class controls.procedure = inputControls.procedure; controls.parallel = inputControls.parallel; -controls.resampleParams = inputControls.resampleParams; +controls.resampleMinAngle = inputControls.resampleMinAngle; +controls.resampleNPoints = inputControls.resampleNPoints; controls.calcSldDuringFit = inputControls.calcSldDuringFit; controls.display = inputControls.display; controls.xTolerance = inputControls.xTolerance; diff --git a/compile/fullCompile/makeCompileArgsFull.m b/compile/fullCompile/makeCompileArgsFull.m index 1a890da87..07a8e13b4 100644 --- a/compile/fullCompile/makeCompileArgsFull.m +++ b/compile/fullCompile/makeCompileArgsFull.m @@ -100,7 +100,8 @@ ARGS_1_4 = struct; ARGS_1_4.procedure = coder.typeof('X',[1 maxArraySize],[0 1]); ARGS_1_4.parallel = coder.typeof('X',[1 maxArraySize],[0 1]); -ARGS_1_4.resampleParams = coder.typeof(0,[1 2]); +ARGS_1_4.resampleMinAngle = coder.typeof(0); +ARGS_1_4.resampleNPoints = coder.typeof(0); ARGS_1_4.calcSldDuringFit = coder.typeof(true); ARGS_1_4.display = coder.typeof('X',[1 maxArraySize],[0 1]); ARGS_1_4.xTolerance = coder.typeof(0); diff --git a/compile/reflectivityCalculation/makeCompileArgs.m b/compile/reflectivityCalculation/makeCompileArgs.m index 6dc8b9f98..1709d3d7f 100644 --- a/compile/reflectivityCalculation/makeCompileArgs.m +++ b/compile/reflectivityCalculation/makeCompileArgs.m @@ -100,7 +100,8 @@ ARGS_1_4 = struct; ARGS_1_4.procedure = coder.typeof('X',[1 maxArraySize],[0 1]); ARGS_1_4.parallel = coder.typeof('X',[1 maxArraySize],[0 1]); -ARGS_1_4.resampleParams = coder.typeof(0,[1 2]); +ARGS_1_4.resampleMinAngle = coder.typeof(0); +ARGS_1_4.resampleNPoints = coder.typeof(0); ARGS_1_4.calcSldDuringFit = coder.typeof(true); ARGS_1_4.display = coder.typeof('X',[1 maxArraySize],[0 1]); ARGS_1_4.xTolerance = coder.typeof(0); diff --git a/examples/miscellaneous/absorption/absorptionDPPC50.m b/examples/miscellaneous/absorption/absorptionDPPC50.m index 8853bb5ff..f0a3ec491 100644 --- a/examples/miscellaneous/absorption/absorptionDPPC50.m +++ b/examples/miscellaneous/absorption/absorptionDPPC50.m @@ -127,7 +127,7 @@ % Now make a controls block.... controls = controlsClass(); -controls.resampleParams(2) = 150; +controls.resampleNPoints = 150; controls.parallel = 'contrasts'; [problem,results] = RAT(problem,controls); diff --git a/targetFunctions/+domainsTF/customLayers.m b/targetFunctions/+domainsTF/customLayers.m index 4db6f11da..a2dd9eb15 100644 --- a/targetFunctions/+domainsTF/customLayers.m +++ b/targetFunctions/+domainsTF/customLayers.m @@ -24,7 +24,8 @@ calcSld = controls.calcSldDuringFit; parallel = controls.parallel; - resampleParams = controls.resampleParams; + resampleMinAngle = controls.resampleMinAngle; + resampleNPoints = controls.resampleNPoints; % Pre-Allocation of output arrays... backgroundParams = zeros(numberOfContrasts,1); @@ -111,7 +112,7 @@ backgroundParamArray,qzshiftArray,scalefactorArray,bulkInArray,... bulkOutArray,resolutionParamArray,domainRatioArray,dataPresent(i),... data{i},dataLimits{i},simLimits{i},repeatLayers{i},... - contrastBackgroundActions(i),nParams,parallel,resampleParams,... + contrastBackgroundActions(i),nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,resample(i),geometry,subRoughs(i),calcSld,... calcAllLayers1{i},calcAllLayers2{i}); @@ -132,7 +133,7 @@ backgroundParamArray,qzshiftArray,scalefactorArray,bulkInArray,... bulkOutArray,resolutionParamArray,domainRatioArray,dataPresent(i),... data{i},dataLimits{i},simLimits{i},repeatLayers{i},... - contrastBackgroundActions(i),nParams,parallel,resampleParams,... + contrastBackgroundActions(i),nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,resample(i),geometry,subRoughs(i),calcSld,... calcAllLayers1{i},calcAllLayers2{i}); @@ -165,7 +166,7 @@ qzshiftIndex,scalefactorIndex,bulkInIndex,bulkOutIndex,resolutionParamIndex,... domainRatioIndex,backgroundParams,qzshifts,scalefactors,bulkIns,bulkOuts,... resolutionParams,domainRatios,dataPresent,data,dataLimits,simLimits,... - repeatLayers,contrastBackgroundActions,nParams,parallel,resampleParams,... + repeatLayers,contrastBackgroundActions,nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,resample,geometry,roughness,calcSld,calcAllLayers1,calcAllLayers2) % Get the domain ratio for this contrast @@ -188,12 +189,12 @@ [sldProfile1,reflect1,simul1,shiftedData,layerSld1,resampledLayer1,~] = nonPolarisedTF.coreLayersCalculation(calcAllLayers1,roughness,... geometry,bulkInValue,bulkOutValue,resample,calcSld,scalefactorValue,qzshiftValue,... dataPresent,data,dataLimits,simLimits,repeatLayers,backgroundParamValue,... - resolutionParamValue,contrastBackgroundActions,nParams,parallel,resampleParams,useImaginary); + resolutionParamValue,contrastBackgroundActions,nParams,parallel,resampleMinAngle,resampleNPoints,useImaginary); [sldProfile2,reflect2,simul2,~,layerSld2,resampledLayer2,~] = nonPolarisedTF.coreLayersCalculation(calcAllLayers2,roughness,... geometry,bulkInValue,bulkOutValue,resample,calcSld,scalefactorValue,qzshiftValue,... dataPresent,data,dataLimits,simLimits,repeatLayers,backgroundParamValue,... - resolutionParamValue,contrastBackgroundActions,nParams,parallel,resampleParams,useImaginary); + resolutionParamValue,contrastBackgroundActions,nParams,parallel,resampleMinAngle,resampleNPoints,useImaginary); % Calculate the average reflectivities.... [reflectivity,simulation] = domainsTF.averageReflectivity(reflect1,reflect2,simul1,simul2,domainRatio); diff --git a/targetFunctions/+domainsTF/customXY.m b/targetFunctions/+domainsTF/customXY.m index 2c666a02e..1f1e34e34 100644 --- a/targetFunctions/+domainsTF/customXY.m +++ b/targetFunctions/+domainsTF/customXY.m @@ -19,7 +19,8 @@ cCustFiles, useImaginary] = extractProblemParams(problemStruct); parallel = controls.parallel; - resampleParams = controls.resampleParams; + resampleMinAngle = controls.resampleMinAngle; + resampleNPoints = controls.resampleNPoints; %Pre-Allocation... backgroundParams = zeros(numberOfContrasts,1); @@ -103,7 +104,7 @@ backgroundParamArray,qzshiftArray,scalefactorArray,bulkInArray,... bulkOutArray,resolutionParamArray,domainRatioArray,dataPresent(i),... data{i},dataLimits{i},simLimits{i},repeatLayers{i},... - contrastBackgroundActions(i),nParams,parallel,resampleParams,... + contrastBackgroundActions(i),nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,subRoughs(i),inputSldProfiles1{i},inputSldProfiles2{i}); end @@ -123,7 +124,7 @@ backgroundParamArray,qzshiftArray,scalefactorArray,bulkInArray,... bulkOutArray,resolutionParamArray,domainRatioArray,dataPresent(i),... data{i},dataLimits{i},simLimits{i},repeatLayers{i},... - contrastBackgroundActions(i),nParams,parallel,resampleParams,... + contrastBackgroundActions(i),nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,subRoughs(i),inputSldProfiles1{i},inputSldProfiles2{i}); end @@ -155,7 +156,7 @@ qzshiftIndex,scalefactorIndex,bulkInIndex,bulkOutIndex,resolutionParamIndex,... domainRatioIndex,backgroundParams,qzshifts,scalefactors,bulkIns,bulkOuts,... resolutionParams,domainRatios,dataPresent,data,dataLimits,simLimits,... - repeatLayers,contrastBackgroundActions,nParams,parallel,resampleParams,... + repeatLayers,contrastBackgroundActions,nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,roughness,sldProfile1,sldProfile2) % Get the domain ratio for this contrast @@ -175,8 +176,8 @@ % Resample the sld profiles if ~useImaginary - layerSld1 = resampleLayers(sldProfile1,resampleParams); - layerSld2 = resampleLayers(sldProfile2,resampleParams); + layerSld1 = resampleLayers(sldProfile1,resampleMinAngle,resampleNPoints); + layerSld2 = resampleLayers(sldProfile2,resampleMinAngle,resampleNPoints); else reSLD1 = sldProfile1(:,1:2); imSLD1 = [sldProfile1(:,1),sldProfile1(:,3)]; @@ -184,8 +185,8 @@ reSLD2 = sldProfile2(:,1:2); imSLD2 = [sldProfile2(:,1),sldProfile2(:,3)]; - layerSld1 = resampleLayersReIm(reSLD1,imSLD1,resampleParams); - layerSld2 = resampleLayersReIm(reSLD2,imSLD2,resampleParams); + layerSld1 = resampleLayersReIm(reSLD1,imSLD1,resampleMinAngle,resampleNPoints); + layerSld2 = resampleLayersReIm(reSLD2,imSLD2,resampleMinAngle,resampleNPoints); end layerSld = {layerSld1, layerSld2}; diff --git a/targetFunctions/+domainsTF/standardLayers.m b/targetFunctions/+domainsTF/standardLayers.m index 4d7cfd06d..4d7eeb470 100644 --- a/targetFunctions/+domainsTF/standardLayers.m +++ b/targetFunctions/+domainsTF/standardLayers.m @@ -27,7 +27,8 @@ calcSld = controls.calcSldDuringFit; parallel = controls.parallel; - resampleParams = controls.resampleParams; + resampleMinAngle = controls.resampleMinAngle; + resampleNPoints = controls.resampleNPoints; % Allocate the memory for the output arrays before the main loop backgroundParams = zeros(numberOfContrasts,1); @@ -115,7 +116,7 @@ backgroundParamArray,qzshiftArray,scalefactorArray,bulkInArray,... bulkOutArray,resolutionParamArray,domainRatioArray,dataPresent(i),... data{i},dataLimits{i},simLimits{i},repeatLayers{i},... - contrastBackgroundActions(i),nParams,parallel,resampleParams,... + contrastBackgroundActions(i),nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,resample(i),geometry,subRoughs(i),calcSld,... domainContrastLayers1{i},domainContrastLayers2{i},outParameterisedLayers); @@ -137,7 +138,7 @@ backgroundParamArray,qzshiftArray,scalefactorArray,bulkInArray,... bulkOutArray,resolutionParamArray,domainRatioArray,dataPresent(i),... data{i},dataLimits{i},simLimits{i},repeatLayers{i},... - contrastBackgroundActions(i),nParams,parallel,resampleParams,... + contrastBackgroundActions(i),nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,resample(i),geometry,subRoughs(i),calcSld,... domainContrastLayers1{i},domainContrastLayers2{i},outParameterisedLayers); @@ -170,7 +171,7 @@ qzshiftIndex,scalefactorIndex,bulkInIndex,bulkOutIndex,resolutionParamIndex,... domainRatioIndex,backgroundParams,qzshifts,scalefactors,bulkIns,bulkOuts,... resolutionParams,domainRatios,dataPresent,data,dataLimits,simLimits,... - repeatLayers,contrastBackgroundActions,nParams,parallel,resampleParams,... + repeatLayers,contrastBackgroundActions,nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,resample,geometry,roughness,calcSld,domainContrastLayers1,... domainContrastLayers2,outParameterisedLayers) @@ -200,12 +201,12 @@ [sldProfile1,reflect1,simul1,shiftedData,layerSld1,resampledLayer1,~] = nonPolarisedTF.coreLayersCalculation(thisContrastLayers1,roughness,... geometry,bulkInValue,bulkOutValue,resample,calcSld,scalefactorValue,qzshiftValue,... dataPresent,data,dataLimits,simLimits,repeatLayers,backgroundParamValue,... - resolutionParamValue,contrastBackgroundActions,nParams,parallel,resampleParams,useImaginary); + resolutionParamValue,contrastBackgroundActions,nParams,parallel,resampleMinAngle,resampleNPoints,useImaginary); [sldProfile2,reflect2,simul2,~,layerSld2,resampledLayer2,~] = nonPolarisedTF.coreLayersCalculation(thisContrastLayers2,roughness,... geometry,bulkInValue,bulkOutValue,resample,calcSld,scalefactorValue,qzshiftValue,... dataPresent,data,dataLimits,simLimits,repeatLayers,backgroundParamValue,... - resolutionParamValue,contrastBackgroundActions,nParams,parallel,resampleParams,useImaginary); + resolutionParamValue,contrastBackgroundActions,nParams,parallel,resampleMinAngle,resampleNPoints,useImaginary); % Calculate the average reflectivities.... [reflectivity,simulation] = domainsTF.averageReflectivity(reflect1,reflect2,simul1,simul2,domainRatio); diff --git a/targetFunctions/+nonPolarisedTF/coreLayersCalculation.m b/targetFunctions/+nonPolarisedTF/coreLayersCalculation.m index db6446031..c8b21976e 100644 --- a/targetFunctions/+nonPolarisedTF/coreLayersCalculation.m +++ b/targetFunctions/+nonPolarisedTF/coreLayersCalculation.m @@ -2,7 +2,7 @@ coreLayersCalculation(contrastLayers, rough, ... geometry, bulkIn, bulkOut, resample, calcSld, scalefactor, qzshift,... dataPresent, data, dataLimits, simLimits, repeatLayers,... - background,resolution,contrastBackgroundActions,params,parallelPoints,resampleParams,useImaginary) + background,resolution,contrastBackgroundActions,params,parallelPoints,resampleMinAngle,resampleNPoints,useImaginary) % This is the main reflectivity calculation for all Layers models in the % non polarised target function. @@ -98,9 +98,9 @@ % If required, then resample the SLD if resample == 1 if ~useImaginary - layerSld = resampleLayers(sldProfile,resampleParams); + layerSld = resampleLayers(sldProfile,resampleMinAngle,resampleNPoints); else - layerSld = resampleLayersReIm(sldProfile,sldProfileIm,resampleParams); + layerSld = resampleLayersReIm(sldProfile,sldProfileIm,resampleMinAngle,resampleNPoints); end resamLayers = layerSld; else diff --git a/targetFunctions/+nonPolarisedTF/customLayers.m b/targetFunctions/+nonPolarisedTF/customLayers.m index 71052525f..e727e826c 100644 --- a/targetFunctions/+nonPolarisedTF/customLayers.m +++ b/targetFunctions/+nonPolarisedTF/customLayers.m @@ -24,7 +24,8 @@ calcSld = controls.calcSldDuringFit; parallel = controls.parallel; - resampleParams = controls.resampleParams; + resampleMinAngle = controls.resampleMinAngle; + resampleNPoints = controls.resampleNPoints; % Pre-Allocation of output arrays... backgroundParams = zeros(numberOfContrasts,1); @@ -75,7 +76,7 @@ contrastResolutionParamIndices(i),backgroundParamArray,qzshiftArray,... scalefactorArray,bulkInArray,bulkOutArray,resolutionParamArray,... dataPresent(i),data{i},dataLimits{i},simLimits{i},repeatLayers{i},... - contrastBackgroundActions(i),nParams,parallel,resampleParams,... + contrastBackgroundActions(i),nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,resample(i),geometry,subRoughs(i),calcSld,... resampledLayers{i}); @@ -96,7 +97,7 @@ contrastResolutionParamIndices(i),backgroundParamArray,qzshiftArray,... scalefactorArray,bulkInArray,bulkOutArray,resolutionParamArray,... dataPresent(i),data{i},dataLimits{i},simLimits{i},repeatLayers{i},... - contrastBackgroundActions(i),nParams,parallel,resampleParams,... + contrastBackgroundActions(i),nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,resample(i),geometry,subRoughs(i),calcSld,... resampledLayers{i}); @@ -113,7 +114,7 @@ qzshiftIndex,scalefactorIndex,bulkInIndex,bulkOutIndex,resolutionParamIndex,... backgroundParams,qzshifts,scalefactors,bulkIns,bulkOuts,resolutionParams,... dataPresent,data,dataLimits,simLimits,repeatLayers,contrastBackgroundActions,... - nParams,parallel,resampleParams,useImaginary,resample,geometry,roughness,... + nParams,parallel,resampleMinAngle,resampleNPoints,useImaginary,resample,geometry,roughness,... calcSld,layer) % Extract the relevant parameter values for this contrast @@ -130,6 +131,6 @@ chi] = nonPolarisedTF.coreLayersCalculation(layer,roughness,... geometry,bulkInValue,bulkOutValue,resample,calcSld,scalefactorValue,qzshiftValue,... dataPresent,data,dataLimits,simLimits,repeatLayers,backgroundParamValue,... - resolutionParamValue,contrastBackgroundActions,nParams,parallel,resampleParams,useImaginary); + resolutionParamValue,contrastBackgroundActions,nParams,parallel,resampleMinAngle,resampleNPoints,useImaginary); end diff --git a/targetFunctions/+nonPolarisedTF/customXY.m b/targetFunctions/+nonPolarisedTF/customXY.m index c8897ebbb..6fc210103 100644 --- a/targetFunctions/+nonPolarisedTF/customXY.m +++ b/targetFunctions/+nonPolarisedTF/customXY.m @@ -19,7 +19,8 @@ useImaginary] = extractProblemParams(problemStruct); parallel = controls.parallel; - resampleParams = controls.resampleParams; + resampleMinAngle = controls.resampleMinAngle; + resampleNPoints = controls.resampleNPoints; %Pre-Allocation... backgroundParams = zeros(numberOfContrasts,1); @@ -72,7 +73,7 @@ scalefactorArray,bulkInArray,bulkOutArray,resolutionParamArray,... dataPresent(i),data{i},dataLimits{i},simLimits{i},... repeatLayers{i},contrastBackgroundActions(i),nParams,parallel,... - resampleParams,useImaginary,subRoughs(i),sldProfiles{i}); + resampleMinAngle,resampleNPoints,useImaginary,subRoughs(i),sldProfiles{i}); end else @@ -90,7 +91,7 @@ scalefactorArray,bulkInArray,bulkOutArray,resolutionParamArray,... dataPresent(i),data{i},dataLimits{i},simLimits{i},... repeatLayers{i},contrastBackgroundActions(i),nParams,parallel,... - resampleParams,useImaginary,subRoughs(i),sldProfiles{i}); + resampleMinAngle,resampleNPoints,useImaginary,subRoughs(i),sldProfiles{i}); end @@ -105,7 +106,7 @@ qzshiftIndex,scalefactorIndex,bulkInIndex,bulkOutIndex,resolutionParamIndex,... backgroundParams,qzshifts,scalefactors,bulkIns,bulkOuts,resolutionParams,... dataPresent,data,dataLimits,simLimits,repeatLayers,contrastBackgroundActions,... - nParams,parallel,resampleParams,useImaginary,roughness,sldProfile) + nParams,parallel,resampleMinAngle,resampleNPoints,useImaginary,roughness,sldProfile) % Extract the relevant parameter values for this contrast % from the input arrays. @@ -118,11 +119,11 @@ % Resample the layers if ~useImaginary - layerSld = resampleLayers(sldProfile,resampleParams); + layerSld = resampleLayers(sldProfile,resampleMinAngle,resampleNPoints); else reSLD = sldProfile(:,1:2); imSLD = [sldProfile(:,1),sldProfile(:,3)]; - layerSld = resampleLayersReIm(reSLD,imSLD,resampleParams); + layerSld = resampleLayersReIm(reSLD,imSLD,resampleMinAngle,resampleNPoints); end resampledLayer = layerSld; diff --git a/targetFunctions/+nonPolarisedTF/standardLayers.m b/targetFunctions/+nonPolarisedTF/standardLayers.m index 50fbc48a5..e8abc56ca 100644 --- a/targetFunctions/+nonPolarisedTF/standardLayers.m +++ b/targetFunctions/+nonPolarisedTF/standardLayers.m @@ -25,7 +25,8 @@ calcSld = controls.calcSldDuringFit; parallel = controls.parallel; - resampleParams = controls.resampleParams; + resampleMinAngle = controls.resampleMinAngle; + resampleNPoints = controls.resampleNPoints; % Allocate the memory for the output arrays before the main loop backgroundParams = zeros(numberOfContrasts,1); @@ -81,7 +82,7 @@ contrastResolutionParamIndices(i),backgroundParamArray,qzshiftArray,... scalefactorArray,bulkInArray,bulkOutArray,resolutionParamArray,... dataPresent(i),data{i},dataLimits{i},simLimits{i},repeatLayers{i},... - contrastBackgroundActions(i),nParams,parallel,resampleParams,... + contrastBackgroundActions(i),nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,resample(i),geometry,subRoughs(i),calcSld,... contrastLayers{i},outParameterisedLayers); @@ -102,7 +103,7 @@ contrastResolutionParamIndices(i),backgroundParamArray,qzshiftArray,... scalefactorArray,bulkInArray,bulkOutArray,resolutionParamArray,... dataPresent(i),data{i},dataLimits{i},simLimits{i},repeatLayers{i},... - contrastBackgroundActions(i),nParams,parallel,resampleParams,... + contrastBackgroundActions(i),nParams,parallel,resampleMinAngle,resampleNPoints,... useImaginary,resample(i),geometry,subRoughs(i),calcSld,... contrastLayers{i},outParameterisedLayers); @@ -119,7 +120,7 @@ qzshiftIndex,scalefactorIndex,bulkInIndex,bulkOutIndex,resolutionParamIndex,... backgroundParams,qzshifts,scalefactors,bulkIns,bulkOuts,resolutionParams,... dataPresent,data,dataLimits,simLimits,repeatLayers,contrastBackgroundActions,... - nParams,parallel,resampleParams,useImaginary,resample,geometry,roughness,... + nParams,parallel,resampleMinAngle,resampleNPoints,useImaginary,resample,geometry,roughness,... calcSld,contrastLayers,outParameterisedLayers) % Extract the relevant parameter values for this contrast @@ -141,6 +142,6 @@ chi] = nonPolarisedTF.coreLayersCalculation(thisContrastLayers,roughness,... geometry,bulkInValue,bulkOutValue,resample,calcSld,scalefactorValue,qzshiftValue,... dataPresent,data,dataLimits,simLimits,repeatLayers,backgroundParamValue,... - resolutionParamValue,contrastBackgroundActions,nParams,parallel,resampleParams,useImaginary); + resolutionParamValue,contrastBackgroundActions,nParams,parallel,resampleMinAngle,resampleNPoints,useImaginary); end diff --git a/targetFunctions/common/resampleLayers/resampleLayers.m b/targetFunctions/common/resampleLayers/resampleLayers.m index 3fd8e3c0e..3e220e2a4 100644 --- a/targetFunctions/common/resampleLayers/resampleLayers.m +++ b/targetFunctions/common/resampleLayers/resampleLayers.m @@ -1,4 +1,4 @@ -function newSLD = resampleLayers(sldProfile,resampleParams) +function newSLD = resampleLayers(sldProfile,minAngle, nPoints) % Function handle for adaptive resampling @@ -10,11 +10,6 @@ xstart = x(1); xend = x(end); -% Keep points and minangle as constants for now -% will fix later -minAngle = resampleParams(1); -nPoints = resampleParams(2); - newX = linspace(xstart,xend,100); out = adaptive(sldProfile, [xstart xend], minAngle*pi, nPoints); yy = out{1}; diff --git a/targetFunctions/common/resampleLayers/resampleLayersReIm.m b/targetFunctions/common/resampleLayers/resampleLayersReIm.m index 3094e35ba..3d8edbef9 100644 --- a/targetFunctions/common/resampleLayers/resampleLayersReIm.m +++ b/targetFunctions/common/resampleLayers/resampleLayersReIm.m @@ -1,4 +1,4 @@ -function newSLD = resampleLayersReIm(sldProfile,sldProfileIm,resampleParams) +function newSLD = resampleLayersReIm(sldProfile,sldProfileIm,minAngle, nPoints) % Resample the SLD profile. In this case we have an imaginary SLD also, and % so we resample that onto the same points as the real one.. @@ -12,11 +12,6 @@ xstart = x(1); xend = x(end); -% Keep points and minangle as constants for now -% will fix later -minAngle = resampleParams(1); -nPoints = resampleParams(2); - %newX = linspace(xstart,xend,100); out = adaptive(sldProfile, [xstart xend], minAngle*pi, nPoints); yy = out{1}; diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomLayersInputs.mat b/tests/domainsTFReflectivityCalculation/domainsCustomLayersInputs.mat index cab2f77e7..237d41d14 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomLayersInputs.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomLayersInputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomLayersOutputs.mat b/tests/domainsTFReflectivityCalculation/domainsCustomLayersOutputs.mat index bf06c5de7..21bdc36b6 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomLayersOutputs.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomLayersOutputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomLayersTFParams.mat b/tests/domainsTFReflectivityCalculation/domainsCustomLayersTFParams.mat index ee5d9fc90..995faf462 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomLayersTFParams.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomLayersTFParams.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat b/tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat index aab087871..bad160d90 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat b/tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat index dd1caac83..499d72383 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomXYTFParams.mat b/tests/domainsTFReflectivityCalculation/domainsCustomXYTFParams.mat index 8f2d31f5c..11983e4c1 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomXYTFParams.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomXYTFParams.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsStandardLayersInputs.mat b/tests/domainsTFReflectivityCalculation/domainsStandardLayersInputs.mat index 32f01d43c..de4c117d8 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsStandardLayersInputs.mat and b/tests/domainsTFReflectivityCalculation/domainsStandardLayersInputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsStandardLayersOutputs.mat b/tests/domainsTFReflectivityCalculation/domainsStandardLayersOutputs.mat index bfd7b2288..20c9b79ad 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsStandardLayersOutputs.mat and b/tests/domainsTFReflectivityCalculation/domainsStandardLayersOutputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsStandardLayersTFParams.mat b/tests/domainsTFReflectivityCalculation/domainsStandardLayersTFParams.mat index 2bb753a23..c04167d33 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsStandardLayersTFParams.mat and b/tests/domainsTFReflectivityCalculation/domainsStandardLayersTFParams.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat b/tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat index 5ea2037b8..60a1fd61d 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customLayersOutputs.mat b/tests/nonPolarisedTFReflectivityCalculation/customLayersOutputs.mat index 5999faa44..ce5c0826a 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customLayersOutputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/customLayersOutputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customLayersTFParams.mat b/tests/nonPolarisedTFReflectivityCalculation/customLayersTFParams.mat index fe0d32997..682b6da3e 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customLayersTFParams.mat and b/tests/nonPolarisedTFReflectivityCalculation/customLayersTFParams.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat b/tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat index f79545cd5..8d17d80c2 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat b/tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat index 3ea012908..ac926f116 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat b/tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat index b41389949..9f28ce4d7 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat and b/tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/standardLayersInputs.mat b/tests/nonPolarisedTFReflectivityCalculation/standardLayersInputs.mat index 727dcb603..7ae3f374b 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/standardLayersInputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/standardLayersInputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/standardLayersOutputs.mat b/tests/nonPolarisedTFReflectivityCalculation/standardLayersOutputs.mat index 62712032f..8b0572b53 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/standardLayersOutputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/standardLayersOutputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/standardLayersTFParams.mat b/tests/nonPolarisedTFReflectivityCalculation/standardLayersTFParams.mat index 35cf18b6e..d8bd5d945 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/standardLayersTFParams.mat and b/tests/nonPolarisedTFReflectivityCalculation/standardLayersTFParams.mat differ diff --git a/tests/testCommonFunctions/resampleLayersInputs.mat b/tests/testCommonFunctions/resampleLayersInputs.mat index 5afbd9d4d..f721b4462 100644 Binary files a/tests/testCommonFunctions/resampleLayersInputs.mat and b/tests/testCommonFunctions/resampleLayersInputs.mat differ diff --git a/tests/testControlsClass.m b/tests/testControlsClass.m index c0ca2cfe4..8f754479d 100644 --- a/tests/testControlsClass.m +++ b/tests/testControlsClass.m @@ -1,15 +1,15 @@ -classdef testControlsClass < matlab.unittest.TestCase - +classdef testControlsClass < matlab.unittest.TestCase + properties controls end - + methods(TestMethodSetup) function createControlsClass(testCase) testCase.controls = controlsClass(); end end - + methods (Test) function testParallel(testCase) % Test if set.parallel method is working @@ -19,12 +19,12 @@ function testParallel(testCase) testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Contrasts.value, 'set.parallel method is not working') testCase.controls.parallel = upper(parallelOptions.Single.value); testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Single.value, 'set.parallel method is not working') - testCase.verifyError(@setParallel, exceptions.invalidOption.errorID); % bad parallel option + testCase.verifyError(@setParallel, exceptions.invalidOption.errorID); % bad parallel option function setParallel testCase.controls.parallel = 'random'; end end - + function testProcedure(testCase) % Test if set.procedure method is working testCase.controls.procedure = procedures.Simplex; @@ -37,58 +37,68 @@ function testProcedure(testCase) testCase.verifyEqual(testCase.controls.procedure, procedures.NS.value, 'set.procedure method is not working') testCase.controls.procedure = procedures.Calculate; testCase.verifyEqual(testCase.controls.procedure, procedures.Calculate.value, 'set.procedure method is not working') - testCase.verifyError(@setProcedure, exceptions.invalidOption.errorID); % bad procedure option + testCase.verifyError(@setProcedure, exceptions.invalidOption.errorID); % bad procedure option function setProcedure testCase.controls.procedure = 'random'; end end - + function testDisplay(testCase) % Test if set.display method is working testCase.controls.display = displayOptions.Final; - testCase.verifyEqual(testCase.controls.display, displayOptions.Final.value, 'set.display method is not working') + testCase.verifyEqual(testCase.controls.display, displayOptions.Final.value, 'set.display method is not working') testCase.controls.display = upper(displayOptions.Off.value); testCase.verifyEqual(testCase.controls.display, displayOptions.Off.value, 'set.display method is not working') testCase.controls.display = displayOptions.Iter.value; testCase.verifyEqual(testCase.controls.display, displayOptions.Iter.value, 'set.display method is not working') testCase.controls.display = displayOptions.Notify; testCase.verifyEqual(testCase.controls.display, displayOptions.Notify.value, 'set.display method is not working') - testCase.verifyError(@setDisplay, exceptions.invalidOption.errorID); % bad display option + testCase.verifyError(@setDisplay, exceptions.invalidOption.errorID); % bad display option function setDisplay testCase.controls.display = 'any'; end end - - function testResampleParams(testCase) - % Test if set.resampleParams method is working - testCase.controls.resampleParams = [0, 100]; - testCase.verifyEqual(testCase.controls.resampleParams, [0, 100], 'set.resampleParams method is not working') - testCase.controls.resampleParams = [0.9, 10.2]; - testCase.verifyEqual(testCase.controls.resampleParams, [0.9, 10.2], 'set.resampleParams method is not working') - % bad resampleParams option - testCase.verifyError(@() setResampleParams('ab'), exceptions.invalidType.errorID); - testCase.verifyError(@() setResampleParams([0.5, 6, 7]), exceptions.invalidValue.errorID); - testCase.verifyError(@() setResampleParams([-1, 4]), exceptions.invalidValue.errorID); - testCase.verifyError(@() setResampleParams([0, 0]), exceptions.invalidValue.errorID); - testCase.verifyError(@() setResampleParams([12, 13]), exceptions.invalidValue.errorID); - function setResampleParams(value) - testCase.controls.resampleParams = value; + + function testResampleMinAngle(testCase) + % Test if set.resampleMinAngle method is working + testCase.controls.resampleMinAngle = 0.8; + testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.8, 'set.resampleMinAngle method is not working') + % bad resampleMinAngle option + testCase.verifyError(@() setResampleMinAngle('ab'), exceptions.invalidType.errorID); + testCase.verifyError(@() setResampleMinAngle(-1), exceptions.invalidValue.errorID); + testCase.verifyError(@() setResampleMinAngle(0), exceptions.invalidValue.errorID); + testCase.verifyError(@() setResampleMinAngle(12.3), exceptions.invalidValue.errorID); + function setResampleMinAngle(value) + testCase.controls.resampleMinAngle = value; + end + end + + function testResampleNPoints(testCase) + % test if set.resampleNPoints is working + testCase.controls.resampleNPoints = 10; + testCase.verifyEqual(testCase.controls.resampleNPoints, 10, 'set.resampleNPoints method is not working') + % bad option + testCase.verifyError(@() setResampleNPoints('ab'), exceptions.invalidType.errorID); + testCase.verifyError(@() setResampleNPoints(0.5), exceptions.invalidValue.errorID); + testCase.verifyError(@() setResampleNPoints(-1), exceptions.invalidValue.errorID); + function setResampleNPoints(value) + testCase.controls.resampleNPoints = value; end end - + function testCalcSldDuringFit(testCase) % Test if set.calcSldDuringFit method is working testCase.controls.calcSldDuringFit = true; testCase.verifyTrue(testCase.controls.calcSldDuringFit, 'set.calcSldDuringFit method is not working') testCase.controls.calcSldDuringFit = false; testCase.verifyFalse(testCase.controls.calcSldDuringFit, 'set.calcSldDuringFit method is not working') - testCase.verifyError(@setCalcSldDuringFit, exceptions.invalidType.errorID); % bad calcSldDuringFit option + testCase.verifyError(@setCalcSldDuringFit, exceptions.invalidType.errorID); % bad calcSldDuringFit option function setCalcSldDuringFit testCase.controls.calcSldDuringFit = 2; end end - function testUpdatePlotFreq(testCase) + function testUpdatePlotFreq(testCase) % Test if NS property setters are working testCase.controls.updatePlotFreq = 5; testCase.verifyEqual(testCase.controls.updatePlotFreq, 5, 'set.updatePlotFreq method is not working') @@ -100,40 +110,40 @@ function setUpdatePlotFreq(value) testCase.controls.updatePlotFreq = value; end end - + function testSimplexArguments(testCase) % Test if Simplex property setters are working testCase.controls.xTolerance = 5; testCase.verifyEqual(testCase.controls.xTolerance, 5, 'set.xTolerance method is not working') - testCase.verifyError(@setXTolerance, exceptions.invalidType.errorID); % bad xTolerance type + testCase.verifyError(@setXTolerance, exceptions.invalidType.errorID); % bad xTolerance type function setXTolerance testCase.controls.xTolerance = 'a'; end - + testCase.controls.funcTolerance = 2; testCase.verifyEqual(testCase.controls.funcTolerance, 2, 'set.funcTolerance method is not working') - testCase.verifyError(@setFuncTolerance, exceptions.invalidType.errorID); % bad funcTolerance type + testCase.verifyError(@setFuncTolerance, exceptions.invalidType.errorID); % bad funcTolerance type function setFuncTolerance testCase.controls.funcTolerance = 'a'; end - + testCase.controls.maxFuncEvals = 123; testCase.verifyEqual(testCase.controls.maxFuncEvals, 123, 'set.maxFuncEvals method is not working') - testCase.verifyError(@() setMaxFuncEvals('a'), exceptions.invalidType.errorID); % bad maxFuncEvals type + testCase.verifyError(@() setMaxFuncEvals('a'), exceptions.invalidType.errorID); % bad maxFuncEvals type testCase.verifyError(@() setMaxFuncEvals(1.5), exceptions.invalidValue.errorID); function setMaxFuncEvals(value) testCase.controls.maxFuncEvals = value; end - + testCase.controls.maxIterations = 456; testCase.verifyEqual(testCase.controls.maxIterations, 456, 'set.maxIterations method is not working') - testCase.verifyError(@() setMaxIterations('a'), exceptions.invalidType.errorID); % bad maxIterations type + testCase.verifyError(@() setMaxIterations('a'), exceptions.invalidType.errorID); % bad maxIterations type testCase.verifyError(@() setMaxIterations(1.5), exceptions.invalidValue.errorID); function setMaxIterations(value) testCase.controls.maxIterations = value; end end - + function testDEArguments(testCase) % Test if DE property setters are working testCase.controls.populationSize = 5; @@ -145,18 +155,18 @@ function testDEArguments(testCase) function setPopulationSize(value) testCase.controls.populationSize = value; end - + testCase.controls.fWeight = 0.2; testCase.verifyEqual(testCase.controls.fWeight, 0.2, 'set.fWeight method is not working') - testCase.verifyError(@setFWeight, exceptions.invalidType.errorID); % bad fWeight type + testCase.verifyError(@setFWeight, exceptions.invalidType.errorID); % bad fWeight type function setFWeight testCase.controls.fWeight = 'a'; end - + testCase.controls.crossoverProbability = 0.1; testCase.verifyEqual(testCase.controls.crossoverProbability, 0.1, 'set.crossoverProbability method is not working') % bad crossoverProbability type - testCase.verifyError(@() setCrossoverProbability('a'), exceptions.invalidType.errorID); + testCase.verifyError(@() setCrossoverProbability('a'), exceptions.invalidType.errorID); testCase.verifyError(@() setCrossoverProbability(-1), exceptions.invalidValue.errorID); testCase.verifyError(@() setCrossoverProbability(2), exceptions.invalidValue.errorID); function setCrossoverProbability(value) @@ -167,27 +177,27 @@ function setCrossoverProbability(value) testCase.controls.strategy = searchStrategy.fromValue(i); testCase.verifyEqual(testCase.controls.strategy, i, 'set.strategy method is not working') end - % bad strategy type - testCase.verifyError(@() setStrategy('a'), exceptions.invalidType.errorID); + % bad strategy type + testCase.verifyError(@() setStrategy('a'), exceptions.invalidType.errorID); testCase.verifyError(@() setStrategy(7), exceptions.invalidOption.errorID); testCase.verifyError(@() setStrategy(3.14), exceptions.invalidOption.errorID); testCase.verifyError(@() setStrategy(0), exceptions.invalidOption.errorID); function setStrategy(value) testCase.controls.strategy = value; end - + testCase.controls.targetValue = 4; testCase.verifyEqual(testCase.controls.targetValue, 4, 'set.targetValue method is not working') % bad targetValue type testCase.verifyError(@() setTargetValue('a'), exceptions.invalidType.errorID); - testCase.verifyError(@() setTargetValue(0), exceptions.invalidValue.errorID); + testCase.verifyError(@() setTargetValue(0), exceptions.invalidValue.errorID); function setTargetValue(value) testCase.controls.targetValue = value; end - + testCase.controls.numGenerations = 6; testCase.verifyEqual(testCase.controls.numGenerations, 6, 'set.numGenerations method is not working') - % bad numGenerations type + % bad numGenerations type testCase.verifyError(@() setNumGenerations('a'), exceptions.invalidType.errorID); testCase.verifyError(@() setNumGenerations(0), exceptions.invalidValue.errorID); testCase.verifyError(@() setNumGenerations(1.5), exceptions.invalidValue.errorID); @@ -195,8 +205,8 @@ function setNumGenerations(value) testCase.controls.numGenerations = value; end end - - function testNSArguments(testCase) + + function testNSArguments(testCase) % Test if NS property setters are working testCase.controls.nLive = 5; testCase.verifyEqual(testCase.controls.nLive, 5, 'set.nLive method is not working') @@ -207,7 +217,7 @@ function testNSArguments(testCase) function setnLive(value) testCase.controls.nLive = value; end - + testCase.controls.nMCMC = 5; testCase.verifyEqual(testCase.controls.nMCMC, 5, 'set.nMCMC method is not working') % bad nMCMC type @@ -217,7 +227,7 @@ function setnLive(value) function setnMCMC(value) testCase.controls.nMCMC = value; end - + testCase.controls.propScale = 0.1; testCase.verifyEqual(testCase.controls.propScale, 0.1, 'set.propScale method is not working') % bad propScale type @@ -227,7 +237,7 @@ function setnMCMC(value) function setPropScale(value) testCase.controls.propScale = value; end - + testCase.controls.nsTolerance = 0; testCase.verifyEqual(testCase.controls.nsTolerance, 0, 'set.nsTolerance method is not working') % bad nsTolerance type @@ -236,9 +246,9 @@ function setPropScale(value) function setNsTolerance(value) testCase.controls.nsTolerance = value; end - end - - function testDreamArguments(testCase) + end + + function testDreamArguments(testCase) % Test if Dream property setters are working testCase.controls.nSamples = 289; testCase.verifyEqual(testCase.controls.nSamples, 289, 'set.nSamples method is not working') @@ -249,7 +259,7 @@ function testDreamArguments(testCase) function setNSamples(value) testCase.controls.nSamples = value; end - + testCase.controls.nChains = 20; testCase.verifyEqual(testCase.controls.nChains, 20, 'set.nChains method is not working') % bad nChains type @@ -261,35 +271,35 @@ function setNSamples(value) function setNChains(value) testCase.controls.nChains = value; end - + testCase.controls.jumpProbability = 0; testCase.verifyEqual(testCase.controls.jumpProbability, 0, 'set.jumpProbability method is not working') testCase.controls.jumpProbability = 1; testCase.verifyEqual(testCase.controls.jumpProbability, 1, 'set.jumpProbability method is not working') testCase.controls.jumpProbability = 0.5; testCase.verifyEqual(testCase.controls.jumpProbability, 0.5, 'set.jumpProbability method is not working') - % bad jumpProbability type - testCase.verifyError(@() setJumpProbability(1.1), exceptions.invalidValue.errorID); + % bad jumpProbability type + testCase.verifyError(@() setJumpProbability(1.1), exceptions.invalidValue.errorID); testCase.verifyError(@() setJumpProbability(-0.1), exceptions.invalidValue.errorID); testCase.verifyError(@() setJumpProbability('a'), exceptions.invalidType.errorID); function setJumpProbability(value) testCase.controls.jumpProbability = value; end - + testCase.controls.pUnitGamma = 0; testCase.verifyEqual(testCase.controls.pUnitGamma, 0, 'set.pUnitGamma method is not working') testCase.controls.pUnitGamma = 1; testCase.verifyEqual(testCase.controls.pUnitGamma, 1, 'set.pUnitGamma method is not working') testCase.controls.pUnitGamma = 0.5; testCase.verifyEqual(testCase.controls.pUnitGamma, 0.5, 'set.pUnitGamma method is not working') - % bad pUnitGamma type + % bad pUnitGamma type testCase.verifyError(@() setJumpProbability(1.1), exceptions.invalidValue.errorID); testCase.verifyError(@() setPUnitGamma(-0.1), exceptions.invalidValue.errorID); testCase.verifyError(@() setPUnitGamma('a'), exceptions.invalidType.errorID); function setPUnitGamma(value) testCase.controls.pUnitGamma = value; end - + testCase.controls.boundHandling = boundHandlingOptions.None; testCase.verifyEqual(testCase.controls.boundHandling, boundHandlingOptions.None.value, 'set.boundHandling method is not working') testCase.controls.boundHandling = boundHandlingOptions.Reflect.value; @@ -298,22 +308,22 @@ function setPUnitGamma(value) testCase.verifyEqual(testCase.controls.boundHandling, boundHandlingOptions.Bound.value, 'setboundHandling method is not working') testCase.controls.boundHandling = boundHandlingOptions.Fold; testCase.verifyEqual(testCase.controls.boundHandling, boundHandlingOptions.Fold.value, 'set.boundHandling method is not working') - testCase.verifyError(@setBoundHandling, exceptions.invalidOption.errorID); % bad method option + testCase.verifyError(@setBoundHandling, exceptions.invalidOption.errorID); % bad method option function setBoundHandling testCase.controls.boundHandling = 'random'; end - + % Test if set.calcSldDuringFit method is working testCase.controls.adaptPCR = true; testCase.verifyTrue(testCase.controls.adaptPCR, 'set.adaptPCR method is not working') testCase.controls.adaptPCR = false; testCase.verifyFalse(testCase.controls.adaptPCR, 'set.adaptPCR method is not working') - testCase.verifyError(@setAdaptPCR, exceptions.invalidType.errorID); % bad adaptPCR option + testCase.verifyError(@setAdaptPCR, exceptions.invalidType.errorID); % bad adaptPCR option function setAdaptPCR testCase.controls.adaptPCR = 2; end end - + function testDisplayGroups(testCase) import matlab.unittest.constraints.ContainsSubstring % Check that the content of the controlsClass are printed @@ -325,7 +335,7 @@ function testDisplayGroups(testCase) testCase.verifyThat(display, ~ContainsSubstring('method'), 'getPropertyGroups method not working'); testCase.verifyThat(display, ~ContainsSubstring('propScale'), 'getPropertyGroups method not working'); testCase.verifyThat(display, ~ContainsSubstring('strategy'), 'getPropertyGroups method not working'); - + testCase.controls.procedure = 'dream'; display = evalc('disp(testCase.controls)'); testCase.verifySubstring(display, 'parallel: ''single''', 'getPropertyGroups method not working'); @@ -355,7 +365,7 @@ function testDisplayGroups(testCase) testCase.verifyThat(display, ~ContainsSubstring('method'), 'getPropertyGroups method not working'); testCase.verifyThat(display, ~ContainsSubstring('propScale'), 'getPropertyGroups method not working'); - + testCase.controls.procedure = procedures.Simplex; display = evalc('disp(testCase.controls)'); testCase.verifySubstring(display, 'parallel: ''contrasts''', 'getPropertyGroups method not working'); @@ -370,8 +380,8 @@ function testDisplayGroups(testCase) display = eraseBetween(sprintf(evalc('disp(testControls)')), '<', '>','Boundaries','inclusive'); testCase.verifySubstring(display, 'controlsClass array with properties', 'getPropertyGroups method not working'); end - - function testSetProcedureWithDream(testCase) + + function testSetProcedureWithDream(testCase) % Test default values for dream procedure testCase.controls = testCase.controls.setProcedure(procedures.Dream.value); testCase.verifyEqual(testCase.controls.procedure, procedures.Dream.value, 'setProcedure method is not working'); @@ -383,9 +393,10 @@ function testSetProcedureWithDream(testCase) testCase.verifyEqual(testCase.controls.adaptPCR, true, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Single.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.calcSldDuringFit, false, 'setProcedure method is not working'); - testCase.verifyEqual(testCase.controls.resampleParams, [0.9 50], 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.9, 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleNPoints, 50, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.display, displayOptions.Iter.value, 'setProcedure method is not working'); - + % Test passing valid parameter values for dream procedure testCase.controls = testCase.controls.setProcedure(procedures.Dream.value,... {'nSamples', 70000,... @@ -396,7 +407,8 @@ function testSetProcedureWithDream(testCase) 'adaptPCR', true,... 'parallel', parallelOptions.Contrasts.value,... 'calcSldDuringFit', true,... - 'resampleParams', [0 10],... + 'resampleMinAngle', 0.1,... + 'resampleNPoints', 10,... 'display', displayOptions.Notify.value}); testCase.verifyEqual(testCase.controls.procedure, procedures.Dream.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.nSamples, 70000, 'setProcedure method is not working'); @@ -407,9 +419,10 @@ function testSetProcedureWithDream(testCase) testCase.verifyTrue(testCase.controls.adaptPCR, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Contrasts.value, 'setProcedure method is not working'); testCase.verifyTrue(testCase.controls.calcSldDuringFit, 'setProcedure method is not working'); - testCase.verifyEqual(testCase.controls.resampleParams, [0 10], 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.1, 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleNPoints, 10, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.display, displayOptions.Notify.value, 'setProcedure method is not working'); - + % Test passing invalid parameter values for dream procedure testCase.verifyError(@() testCase.controls.setProcedure(procedures.Dream.value,... {'boundHandling', 'invalid'}), exceptions.invalidOption.errorID); @@ -422,10 +435,10 @@ function testSetProcedureWithDream(testCase) testCase.verifyError(@() testCase.controls.setProcedure(procedures.Dream.value,... {'nLive', 10}), exceptions.invalidOption.errorID); % NS Parameter testCase.verifyError(@() testCase.controls.setProcedure(procedures.Dream.value,... - {'nChains', '0.5'}), 'MATLAB:InputParser:ArgumentFailedValidation'); + {'nChains', '0.5'}), 'MATLAB:InputParser:ArgumentFailedValidation'); end - - function testSetProcedureWithNS(testCase) + + function testSetProcedureWithNS(testCase) % Test default values for NS procedure testCase.controls = testCase.controls.setProcedure(procedures.NS.value); testCase.verifyEqual(testCase.controls.procedure, procedures.NS.value, 'setProcedure method is not working'); @@ -435,9 +448,10 @@ function testSetProcedureWithNS(testCase) testCase.verifyEqual(testCase.controls.nsTolerance, 0.1, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Single.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.calcSldDuringFit, false, 'setProcedure method is not working'); - testCase.verifyEqual(testCase.controls.resampleParams, [0.9 50], 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.9, 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleNPoints, 50, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.display, displayOptions.Iter.value, 'setProcedure method is not working'); - + % Test passing valid parameter values for NS procedure testCase.controls = testCase.controls.setProcedure(procedures.NS.value,... {'nLive', 700,... @@ -446,7 +460,8 @@ function testSetProcedureWithNS(testCase) 'nsTolerance', 0.5,... 'parallel', parallelOptions.Contrasts.value,... 'calcSldDuringFit', true,... - 'resampleParams', [0 10],... + 'resampleMinAngle', 0.1,... + 'resampleNPoints', 10,... 'display', displayOptions.Notify.value}); testCase.verifyEqual(testCase.controls.procedure, procedures.NS.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.nLive, 700, 'setProcedure method is not working'); @@ -455,9 +470,10 @@ function testSetProcedureWithNS(testCase) testCase.verifyEqual(testCase.controls.nsTolerance, 0.5, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Contrasts.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.calcSldDuringFit, true, 'setProcedure method is not working'); - testCase.verifyEqual(testCase.controls.resampleParams, [0 10], 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.1, 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleNPoints, 10, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.display, displayOptions.Notify.value, 'setProcedure method is not working'); - + % Test passing wrong parameter for NS procedure testCase.verifyError(@() testCase.controls.setProcedure(procedures.NS.value,... {'funcTolerance', 1e-6}), exceptions.invalidOption.errorID); % Simplex Parameter @@ -466,10 +482,10 @@ function testSetProcedureWithNS(testCase) testCase.verifyError(@() testCase.controls.setProcedure(procedures.NS.value,... {'nSamples', 10}), exceptions.invalidOption.errorID); % Dream Parameter testCase.verifyError(@() testCase.controls.setProcedure(procedures.NS.value,... - {'propScale', '0.5'}), 'MATLAB:InputParser:ArgumentFailedValidation'); + {'propScale', '0.5'}), 'MATLAB:InputParser:ArgumentFailedValidation'); end - - function testSetProcedureWithDE(testCase) + + function testSetProcedureWithDE(testCase) % Test default values for DE procedure testCase.controls = testCase.controls.setProcedure(procedures.DE.value); testCase.verifyEqual(testCase.controls.procedure, procedures.DE.value, 'setProcedure method is not working'); @@ -481,11 +497,12 @@ function testSetProcedureWithDE(testCase) testCase.verifyEqual(testCase.controls.numGenerations, 500, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Single.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.calcSldDuringFit, false, 'setProcedure method is not working'); - testCase.verifyEqual(testCase.controls.resampleParams, [0.9 50], 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.9, 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleNPoints, 50, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.display, displayOptions.Iter.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.updateFreq, 1, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.updatePlotFreq, 20, 'setProcedure method is not working'); - + % Test passing valid parameter values for DE procedure testCase.controls = testCase.controls.setProcedure(procedures.DE.value,... {'populationSize', 30,... @@ -496,7 +513,8 @@ function testSetProcedureWithDE(testCase) 'numGenerations', 3,... 'parallel', parallelOptions.Contrasts.value,... 'calcSldDuringFit', true,... - 'resampleParams', [0 10],... + 'resampleMinAngle', 0.1,... + 'resampleNPoints', 10,... 'display', displayOptions.Notify.value,... 'updateFreq', 1,... 'updatePlotFreq', 4}); @@ -509,11 +527,12 @@ function testSetProcedureWithDE(testCase) testCase.verifyEqual(testCase.controls.numGenerations, 3, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Contrasts.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.calcSldDuringFit, true, 'setProcedure method is not working'); - testCase.verifyEqual(testCase.controls.resampleParams, [0 10], 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.1, 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleNPoints, 10, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.display, displayOptions.Notify.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.updateFreq, 1, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.updatePlotFreq, 4, 'setProcedure method is not working'); - + % Test passing wrong parameter for DE procedure testCase.verifyError(@() testCase.controls.setProcedure(procedures.DE.value,... {'funcTolerance', 1e-6}), exceptions.invalidOption.errorID); % Simplex Parameter @@ -522,10 +541,10 @@ function testSetProcedureWithDE(testCase) testCase.verifyError(@() testCase.controls.setProcedure(procedures.DE.value,... {'nSamples', 10}), exceptions.invalidOption.errorID); % Dream Parameter testCase.verifyError(@() testCase.controls.setProcedure(procedures.DE.value,... - {'crossoverProbability', '0.5'}), 'MATLAB:InputParser:ArgumentFailedValidation'); + {'crossoverProbability', '0.5'}), 'MATLAB:InputParser:ArgumentFailedValidation'); end - - function testSetProcedureWithSimplex(testCase) + + function testSetProcedureWithSimplex(testCase) % Test default values for Simplex procedure testCase.controls = testCase.controls.setProcedure(procedures.Simplex.value); testCase.verifyEqual(testCase.controls.procedure, procedures.Simplex.value, 'setProcedure method is not working'); @@ -537,9 +556,10 @@ function testSetProcedureWithSimplex(testCase) testCase.verifyEqual(testCase.controls.updatePlotFreq, 20, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Single.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.calcSldDuringFit, false, 'setProcedure method is not working'); - testCase.verifyEqual(testCase.controls.resampleParams, [0.9 50], 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.9, 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleNPoints, 50, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.display, displayOptions.Iter.value, 'setProcedure method is not working'); - + % Test passing valid parameter values for Simplex procedure testCase.controls = testCase.controls.setProcedure(procedures.Simplex.value,... {'xTolerance', 3e-6,... @@ -550,7 +570,8 @@ function testSetProcedureWithSimplex(testCase) 'updatePlotFreq', 4, ... 'parallel', parallelOptions.Contrasts.value,... 'calcSldDuringFit', true,... - 'resampleParams', [0 10],... + 'resampleMinAngle', 0.1,... + 'resampleNPoints', 10,... 'display', displayOptions.Notify.value}); testCase.verifyEqual(testCase.controls.procedure, procedures.Simplex.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.xTolerance, 3e-6, 'setProcedure method is not working'); @@ -561,9 +582,10 @@ function testSetProcedureWithSimplex(testCase) testCase.verifyEqual(testCase.controls.updatePlotFreq, 4, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Contrasts.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.calcSldDuringFit, true, 'setProcedure method is not working'); - testCase.verifyEqual(testCase.controls.resampleParams, [0 10], 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.1, 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleNPoints, 10, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.display, displayOptions.Notify.value, 'setProcedure method is not working'); - + % Test passing wrong parameter for Simplex procedure testCase.verifyError(@() testCase.controls.setProcedure(procedures.Simplex.value,... {'crossoverProbability', 0.7}), exceptions.invalidOption.errorID); % DE Parameter @@ -572,30 +594,33 @@ function testSetProcedureWithSimplex(testCase) testCase.verifyError(@() testCase.controls.setProcedure(procedures.Simplex.value,... {'nSamples', 10}), exceptions.invalidOption.errorID); % Dream Parameter testCase.verifyError(@() testCase.controls.setProcedure(procedures.Simplex.value,... - {'maxIterations', '1'}), 'MATLAB:InputParser:ArgumentFailedValidation'); + {'maxIterations', '1'}), 'MATLAB:InputParser:ArgumentFailedValidation'); end - - function testSetProcedureWithCalculate(testCase) + + function testSetProcedureWithCalculate(testCase) % Test default values for Calculate procedure testCase.controls = testCase.controls.setProcedure(procedures.Calculate.value); testCase.verifyEqual(testCase.controls.procedure, procedures.Calculate.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Single.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.calcSldDuringFit, false, 'setProcedure method is not working'); - testCase.verifyEqual(testCase.controls.resampleParams, [0.9 50], 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.9, 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleNPoints, 50, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.display, displayOptions.Iter.value, 'setProcedure method is not working'); % Test passing valid parameter values for Calculate procedure testCase.controls = testCase.controls.setProcedure(procedures.Calculate.value,... {'parallel', parallelOptions.Contrasts.value,... 'calcSldDuringFit', true,... - 'resampleParams', [0 10],... + 'resampleMinAngle', 0.1,... + 'resampleNPoints', 10,... 'display', displayOptions.Notify.value}); testCase.verifyEqual(testCase.controls.procedure, procedures.Calculate.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Contrasts.value, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.calcSldDuringFit, true, 'setProcedure method is not working'); - testCase.verifyEqual(testCase.controls.resampleParams, [0 10], 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.1, 'setProcedure method is not working'); + testCase.verifyEqual(testCase.controls.resampleNPoints, 10, 'setProcedure method is not working'); testCase.verifyEqual(testCase.controls.display, displayOptions.Notify.value, 'setProcedure method is not working'); - + % Test passing wrong parameter for Calculate procedure testCase.verifyError(@() testCase.controls.setProcedure(procedures.Calculate.value,... {'maxIterations', 100}), exceptions.invalidOption.errorID); % Simplex Parameter @@ -606,12 +631,12 @@ function testSetProcedureWithCalculate(testCase) testCase.verifyError(@() testCase.controls.setProcedure(procedures.Calculate.value,... {'nSamples', 10}), exceptions.invalidOption.errorID); % Dream Parameter testCase.verifyError(@() testCase.controls.setProcedure(procedures.Calculate.value,... - {'calcSldDuringFit', 1}), 'MATLAB:InputParser:ArgumentFailedValidation'); - + {'calcSldDuringFit', 1}), 'MATLAB:InputParser:ArgumentFailedValidation'); + % Test exception testCase.verifyError(@() testCase.controls.setProcedure('bayes'), exceptions.invalidOption.errorID); - + end - + end end diff --git a/tests/testProjectConversion/DSPCBilayerProjectClass.mat b/tests/testProjectConversion/DSPCBilayerProjectClass.mat index 1fca3f901..a3eda8e7b 100644 Binary files a/tests/testProjectConversion/DSPCBilayerProjectClass.mat and b/tests/testProjectConversion/DSPCBilayerProjectClass.mat differ diff --git a/tests/testProjectConversion/monolayerVolumeModelProjectClass.mat b/tests/testProjectConversion/monolayerVolumeModelProjectClass.mat index a317fba80..caaf0015e 100644 Binary files a/tests/testProjectConversion/monolayerVolumeModelProjectClass.mat and b/tests/testProjectConversion/monolayerVolumeModelProjectClass.mat differ