Skip to content
Snippets Groups Projects
Commit c49bdfb4 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Merge branch 'octave_bgp' into 'master'

bgp-tests: Octave compatibility fixes

See merge request !1774
parents ba2cdafd 90429673
No related branches found
No related tags found
1 merge request!1774bgp-tests: Octave compatibility fixes
Pipeline #4410 passed
......@@ -62,10 +62,19 @@ end;
verbatim;
bgp.write(M_);
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-6,'StepTolerance',1e-6);
y = 1+(rand(M_.endo_nbr,1)-.5)*.5;
y = 1+(rand(M_.endo_nbr,1)-.5)*.25;
g = ones(M_.endo_nbr,1);% 1+(rand(M_.endo_nbr,1)-.5)*.1;
if ~isoctave
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-6,'StepTolerance',1e-6);
[y, fval, exitflag] = fsolve(@fs2000.bgpfun, [y;g], options);
else
options = optimset('Display','iter','Algorithm','levenberg-marquardt','MaxFunEvals',1000000,'MaxIter',100000,'GradObj','on','TolFun',1e-6,'TolX',1e-6);
h=str2func('fs2000.bgpfun'); %workaround for https://savannah.gnu.org/bugs/?46659 still present in Octave 5
[y, fval, exitflag] = fsolve(h, [y;g], options);
end
if exitflag<1
error('Solution not found')
end
y(1:M_.orig_endo_nbr)
y(M_.endo_nbr+(1:M_.orig_endo_nbr))
......
......@@ -17,7 +17,7 @@ verbatim;
bgp.write(M_);
if isoctave
options = optimset('Display', 'iter', 'MaxFunEvals', 1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-6,'TolX',1e-6);
options = optimset('Display', 'iter', 'MaxFunEvals', 1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-7,'TolX',1e-7);
else
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-6,'StepTolerance',1e-6);
end
......@@ -28,7 +28,7 @@ verbatim;
else
fun = @ramsey.bgpfun;
end
y = 1+(rand(M_.endo_nbr,1)-.5)*.5;
y = 1+(rand(M_.endo_nbr,1)-.5)*.25;
g = ones(M_.endo_nbr,1);% 1+(rand(M_.endo_nbr,1)-.5)*.1;
[y, fval, exitflag] = fsolve(fun, [y;g], options);
assert(max(abs(y(M_.endo_nbr+(1:M_.orig_endo_nbr))-1.02))<1e-6)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment