Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dynare
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Camilo Marchesini
dynare
Commits
48e00c57
Commit
48e00c57
authored
12 years ago
by
MichelJuillard
Browse files
Options
Downloads
Patches
Plain Diff
corrected and clarified error messages when steady state computation fails
parent
6c7501d9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
matlab/dynare_solve.m
+32
-28
32 additions, 28 deletions
matlab/dynare_solve.m
matlab/print_info.m
+3
-3
3 additions, 3 deletions
matlab/print_info.m
matlab/solve1.m
+4
-2
4 additions, 2 deletions
matlab/solve1.m
with
39 additions
and
33 deletions
matlab/dynare_solve.m
+
32
−
28
View file @
48e00c57
...
@@ -35,7 +35,35 @@ function [x,info] = dynare_solve(func,x,jacobian_flag,varargin)
...
@@ -35,7 +35,35 @@ function [x,info] = dynare_solve(func,x,jacobian_flag,varargin)
global
options_
global
options_
tolf
=
options_
.
solve_tolf
;
info
=
0
;
info
=
0
;
% checking initial values
if
jacobian_flag
[
fvec
,
fjac
]
=
feval
(
func
,
x
,
varargin
{:});
else
fvec
=
feval
(
func
,
x
,
varargin
{:});
fjac
=
zeros
(
nn
,
nn
)
;
end
i
=
find
(
~
isfinite
(
fvec
));
if
~
isempty
(
i
)
disp
([
'STEADY: numerical initial values or parameters incompatible with the following'
...
' equations'
])
disp
(
i
'
)
disp
(
'Please check for example'
)
disp
(
' i) if all parameters occurring in these equations are defined'
)
disp
(
' ii) that no division by an endogenous variable initialized to 0 occurs'
)
info
=
1
;
x
=
NaN
;
return
;
end
if
max
(
abs
(
fvec
))
<
tolf
return
;
end
if
options_
.
solve_algo
==
0
if
options_
.
solve_algo
==
0
if
~
exist
(
'OCTAVE_VERSION'
)
if
~
exist
(
'OCTAVE_VERSION'
)
if
~
user_has_matlab_license
(
'optimization_toolbox'
)
if
~
user_has_matlab_license
(
'optimization_toolbox'
)
...
@@ -60,7 +88,7 @@ if options_.solve_algo == 0
...
@@ -60,7 +88,7 @@ if options_.solve_algo == 0
func
=
@
(
x
)
func2
(
x
,
varargin
{:});
func
=
@
(
x
)
func2
(
x
,
varargin
{:});
% The Octave version of fsolve does not converge when it starts from the solution
% The Octave version of fsolve does not converge when it starts from the solution
fvec
=
feval
(
func
,
x
);
fvec
=
feval
(
func
,
x
);
if
max
(
abs
(
fvec
))
>=
options_
.
solve_
tolf
if
max
(
abs
(
fvec
))
>=
tolf
[
x
,
fval
,
exitval
,
output
]
=
fsolve
(
func
,
x
,
options
);
[
x
,
fval
,
exitval
,
output
]
=
fsolve
(
func
,
x
,
options
);
else
else
exitval
=
3
;
exitval
=
3
;
...
@@ -75,34 +103,10 @@ if options_.solve_algo == 0
...
@@ -75,34 +103,10 @@ if options_.solve_algo == 0
elseif
options_
.
solve_algo
==
1
elseif
options_
.
solve_algo
==
1
nn
=
size
(
x
,
1
);
nn
=
size
(
x
,
1
);
[
x
,
info
]
=
solve1
(
func
,
x
,
1
:
nn
,
1
:
nn
,
jacobian_flag
,
1
,
options_
.
gstep
,
...
[
x
,
info
]
=
solve1
(
func
,
x
,
1
:
nn
,
1
:
nn
,
jacobian_flag
,
1
,
options_
.
gstep
,
...
options_
.
solve_
tolf
,
options_
.
solve_tolx
,
...
tolf
,
options_
.
solve_tolx
,
...
options_
.
solve_maxit
,
options_
.
debug
,
varargin
{:});
options_
.
solve_maxit
,
options_
.
debug
,
varargin
{:});
elseif
options_
.
solve_algo
==
2
||
options_
.
solve_algo
==
4
elseif
options_
.
solve_algo
==
2
||
options_
.
solve_algo
==
4
nn
=
size
(
x
,
1
)
;
nn
=
size
(
x
,
1
)
;
tolf
=
options_
.
solve_tolf
;
if
jacobian_flag
[
fvec
,
fjac
]
=
feval
(
func
,
x
,
varargin
{:});
else
fvec
=
feval
(
func
,
x
,
varargin
{:});
fjac
=
zeros
(
nn
,
nn
)
;
end
i
=
find
(
~
isfinite
(
fvec
));
if
~
isempty
(
i
)
disp
([
'STEADY: numerical initial values incompatible with the following'
...
' equations'
])
disp
(
i
'
)
disp
(
'Please check for example'
)
disp
(
' i) if all parameters occurring in these equations are defined'
)
disp
(
' ii) that no division by an endogenous variable initialized to 0 occurs'
)
error
(
'exiting ...'
)
end
if
max
(
abs
(
fvec
))
<
tolf
return
;
end
if
~
jacobian_flag
if
~
jacobian_flag
fjac
=
zeros
(
nn
,
nn
)
;
fjac
=
zeros
(
nn
,
nn
)
;
...
@@ -129,7 +133,7 @@ elseif options_.solve_algo == 2 || options_.solve_algo == 4
...
@@ -129,7 +133,7 @@ elseif options_.solve_algo == 2 || options_.solve_algo == 4
end
end
[
x
,
info
]
=
solve1
(
func
,
x
,
j1
(
r
(
i
):
r
(
i
+
1
)
-
1
),
j2
(
r
(
i
):
r
(
i
+
1
)
-
1
),
jacobian_flag
,
...
[
x
,
info
]
=
solve1
(
func
,
x
,
j1
(
r
(
i
):
r
(
i
+
1
)
-
1
),
j2
(
r
(
i
):
r
(
i
+
1
)
-
1
),
jacobian_flag
,
...
bad_cond_flag
,
options_
.
gstep
,
...
bad_cond_flag
,
options_
.
gstep
,
...
options_
.
solve_
tolf
,
options_
.
solve_tolx
,
...
tolf
,
options_
.
solve_tolx
,
...
options_
.
solve_maxit
,
options_
.
debug
,
varargin
{:});
options_
.
solve_maxit
,
options_
.
debug
,
varargin
{:});
if
info
if
info
return
return
...
@@ -138,7 +142,7 @@ elseif options_.solve_algo == 2 || options_.solve_algo == 4
...
@@ -138,7 +142,7 @@ elseif options_.solve_algo == 2 || options_.solve_algo == 4
fvec
=
feval
(
func
,
x
,
varargin
{:});
fvec
=
feval
(
func
,
x
,
varargin
{:});
if
max
(
abs
(
fvec
))
>
tolf
if
max
(
abs
(
fvec
))
>
tolf
[
x
,
info
]
=
solve1
(
func
,
x
,
1
:
nn
,
1
:
nn
,
jacobian_flag
,
bad_cond_flag
,
...
[
x
,
info
]
=
solve1
(
func
,
x
,
1
:
nn
,
1
:
nn
,
jacobian_flag
,
bad_cond_flag
,
...
options_
.
gstep
,
options_
.
solve_
tolf
,
options_
.
solve_tolx
,
...
options_
.
gstep
,
tolf
,
options_
.
solve_tolx
,
...
options_
.
solve_maxit
,
options_
.
debug
,
varargin
{:});
options_
.
solve_maxit
,
options_
.
debug
,
varargin
{:});
end
end
elseif
options_
.
solve_algo
==
3
elseif
options_
.
solve_algo
==
3
...
...
This diff is collapsed.
Click to expand it.
matlab/print_info.m
+
3
−
3
View file @
48e00c57
...
@@ -64,12 +64,12 @@ if ~noprint
...
@@ -64,12 +64,12 @@ if ~noprint
error
([
'The Jacobian contains NaNs'
])
error
([
'The Jacobian contains NaNs'
])
end
end
case
19
case
19
error
(
'The steadystate file did not compute the steady state'
)
error
(
'The steadystate file did not compute the steady state'
)
case
20
case
20
error
([
'Impossible to find the steady state. Either the model'
...
error
([
'Impossible to find the steady state. Either the model'
...
' doesn
''
t have a
unique
steady state o
f
the
guess valu
es'
...
' doesn
''
t have a steady state o
r
the
re is an infinity of steady stat
es'
...
' are too far from the solution'
])
'
or the guess values
are too far from the solution'
])
case
21
case
21
error
(
'The steady state is complex'
)
error
(
'The steady state is complex'
)
case
22
case
22
...
...
This diff is collapsed.
Click to expand it.
matlab/solve1.m
+
4
−
2
View file @
48e00c57
...
@@ -59,9 +59,11 @@ fvec = fvec(j1);
...
@@ -59,9 +59,11 @@ fvec = fvec(j1);
i
=
find
(
~
isfinite
(
fvec
));
i
=
find
(
~
isfinite
(
fvec
));
if
~
isempty
(
i
)
if
~
isempty
(
i
)
disp
([
'S
TEADY: numerical initial values incompatible with
the following'
...
disp
([
'S
OLVE1: during the resolution of the non-linear system, the evaluation of
the following
'
...
'
equation
s
'
])
'equation
(s) resulted in a non-finite number:
'
])
disp
(
j1
(
i
)
'
)
disp
(
j1
(
i
)
'
)
check
=
1
;
return
;
end
end
f
=
0.5
*
fvec
'*
fvec
;
f
=
0.5
*
fvec
'*
fvec
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment