From 933986994294ca6b53c3b715d87b44558dba7cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Fri, 15 Feb 2019 17:03:12 +0100 Subject: [PATCH] Octave compatibility fix in solow.mod test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - use optimoptions instead of optimset - since one can't take the handle of a function in a package, use str2func to workaround it It still does not work, the solver does not convergeā€¦ --- tests/bgp/solow-1/solow.mod | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/bgp/solow-1/solow.mod b/tests/bgp/solow-1/solow.mod index 74e979296..6302b221c 100644 --- a/tests/bgp/solow-1/solow.mod +++ b/tests/bgp/solow-1/solow.mod @@ -45,11 +45,19 @@ verbatim; GY = NaN(MC,1); GK = NaN(MC,1); EG = NaN(MC,1); - options = optimoptions('fsolve','Display','off','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-8,'StepTolerance',1e-8); + if isoctave + options = optimset('Display', 'off', 'MaxFunEvals', 1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-8,'TolX',1e-8); + % Octave can't take a function handle of a function in a package + % See https://savannah.gnu.org/bugs/index.php?46659 + fun = str2func('solow.bgpfun'); + else + options = optimoptions('fsolve','Display','off','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-8,'StepTolerance',1e-8); + fun = @solow.bgpfun; + end for i=1:MC y = 1+(rand(6,1)-.5)*.2; g = ones(6,1); - [y, fval, exitflag] = fsolve(@solow.bgpfun, [y;g], options); + [y, fval, exitflag] = fsolve(fun, [y;g], options); if exitflag>0 KY(i) = y(6)/y(5); GY(i) = y(11); @@ -77,4 +85,4 @@ verbatim; assert(abs(mean(EG(~isnan(EG)))-EfficiencyGrowth_ss)<1e-8) assert(var(EG(~isnan(EG)))<1e-16); -end; \ No newline at end of file +end;