diff --git a/Examples/Optimisation/runOptimisation.m b/Examples/Optimisation/runOptimisation.m index bb822eff..b207ac62 100644 --- a/Examples/Optimisation/runOptimisation.m +++ b/Examples/Optimisation/runOptimisation.m @@ -120,7 +120,7 @@ p = getScaledParameterVector(simulatorSetup, parameters); [vad, gad] = evalObjectiveBattmo(p, objmatch, simulatorSetup, parameters, 'GradientMethod', 'AdjointAD', options{:}); - perturbationSize = {1e-10, 1e-5}; + perturbationSize = 1e-10; [vnum, gnum] = evalObjectiveBattmo(p, objmatch, simulatorSetup, parameters, ... 'GradientMethod', 'PerturbationADNUM' , ... 'PerturbationSize', perturbationSize , ... diff --git a/Utilities/Adjoint/evalObjectiveBattmo.m b/Utilities/Adjoint/evalObjectiveBattmo.m index b2541c5c..db73b450 100644 --- a/Utilities/Adjoint/evalObjectiveBattmo.m +++ b/Utilities/Adjoint/evalObjectiveBattmo.m @@ -143,6 +143,8 @@ This file is part of The MATLAB Reservoir Simulation Toolbox (MRST). pertsize = opt.PerturbationSize; if isempty(pertsize) pertsize = repmat({1e-7}, numel(parameters), 1); + elseif ~iscell(pertsize) && numel(pertsize) == 1 % scalar value + pertsize = repmat({pertsize}, numel(parameters), 1); end scaledGradient = cell(numel(parameters), 1);