Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
7c95c82b
Commit
7c95c82b
authored
Sep 19, 2011
by
Sébastien Villemot
Browse files
solve_one_boundary: make the case solve_algo=0 work under Octave
parent
afe800f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
matlab/solve_one_boundary.m
View file @
7c95c82b
...
...
@@ -225,10 +225,8 @@ for it_=start:incr:finish
if
(
verbose
==
1
)
disp
(
'steady: fsolve'
);
end
if
exist
(
'OCTAVE_VERSION'
)
||
~
license
(
'test'
,
'optimization_toolbox'
)
% Note that fsolve() exists under Octave, but has a different syntax
% So we fail for the moment under Octave, until we add the corresponding code
error
(
'DYNARE_SOLVE: you can
''
t use solve_algo=0 since you don
''
t have Matlab
''
s Optimization Toolbox'
)
if
~
exist
(
'OCTAVE_VERSION'
)
&&
~
license
(
'test'
,
'optimization_toolbox'
)
error
(
'SOLVE_ONE_BOUNDARY: you can
''
t use solve_algo=0 since you don
''
t have MATLAB
''
s Optimization Toolbox'
)
end
options
=
optimset
(
'fsolve'
);
options
.
MaxFunEvals
=
50000
;
...
...
@@ -236,8 +234,22 @@ for it_=start:incr:finish
options
.
TolFun
=
1e-8
;
options
.
Display
=
'iter'
;
options
.
Jacobian
=
'on'
;
[
yn
,
fval
,
exitval
,
output
]
=
fsolve
(
@
local_fname
,
y
(
y_index_eq
),
...
options
,
x
,
params
,
steady_state
,
y
,
y_index_eq
,
fname
,
0
);
if
~
exist
(
'OCTAVE_VERSION'
)
[
yn
,
fval
,
exitval
,
output
]
=
fsolve
(
@
local_fname
,
y
(
y_index_eq
),
...
options
,
x
,
params
,
steady_state
,
y
,
y_index_eq
,
fname
,
0
);
else
% Under Octave, use a wrapper, since fsolve() does not have a 4th arg
func
=
@
(
z
)
local_fname
(
z
,
x
,
params
,
steady_state
,
y
,
y_index_eq
,
fname
,
0
);
% The Octave version of fsolve does not converge when it starts from the solution
fvec
=
feval
(
func
,
y
(
y_index_eq
));
if
max
(
abs
(
fvec
))
>=
options_
.
solve_tolf
[
yn
,
fval
,
exitval
,
output
]
=
fsolve
(
func
,
y
(
y_index_eq
),
options
);
else
yn
=
y
(
y_index_eq
);
exitval
=
3
;
end
;
end
y
(
y_index_eq
)
=
yn
;
if
exitval
>
0
info
=
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment