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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Stéphane Adjemian
dynare
Commits
b5262ca1
Commit
b5262ca1
authored
8 years ago
by
Houtan Bastani
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'rattoma/deterministic'
parents
e1034620
234aaacf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/perfect-foresight-models/sim1.m
+33
-23
33 additions, 23 deletions
matlab/perfect-foresight-models/sim1.m
with
33 additions
and
23 deletions
matlab/perfect-foresight-models/sim1.m
+
33
−
23
View file @
b5262ca1
...
...
@@ -165,6 +165,11 @@ for iter = 1:options.simul.maxit
dy
=
-
lin_solve
(
A
,
res
,
verbose
);
end
end
if
(
any
(
~
isreal
(
dy
))
||
any
(
isnan
(
dy
))
||
any
(
isinf
(
dy
))
,
if
verbose
display_critical_variables
(
reshape
(
dy
,[
ny
periods
])
'
,
M
);
end
end
Y
(
i_upd
)
=
Y
(
i_upd
)
+
dy
;
end
...
...
@@ -184,33 +189,12 @@ if stop
if
verbose
skipline
()
disp
(
sprintf
(
'Total time of simulation: %s.'
,
num2str
(
etime
(
clock
,
h1
))))
dyy
=
reshape
(
dy
,[
size
(
endogenousvariables
,
1
)
periods
])
'
;
if
~
isreal
(
res
)
||
~
isreal
(
Y
)
disp
(
'Simulation terminated with imaginary parts in the residuals or endogenous variables.'
)
if
any
(
~
isreal
(
dy
))
indx
=
find
(
any
(
~
isreal
(
dyy
)));
endo_names
=
cellstr
(
M
.
endo_names
(
indx
,:));
disp
(
'Newton algorithm provided complex number for variables:'
)
fprintf
(
'%s, '
,
endo_names
{:});
skipline
()
end
else
disp
(
'Simulation terminated with NaN or Inf in the residuals or endogenous variables.'
)
if
any
(
isnan
(
dy
))
indx
=
find
(
any
(
isnan
(
dyy
)));
endo_names
=
cellstr
(
M
.
endo_names
(
indx
,:));
disp
(
'Newton algorithm provided NaN for variables:'
)
fprintf
(
'%s, '
,
endo_names
{:});
skipline
()
end
if
any
(
isinf
(
dy
))
indx
=
find
(
any
(
isinf
(
dyy
)));
endo_names
=
cellstr
(
M
.
endo_names
(
indx
,:));
disp
(
'Newton algorithm diverged (Inf) for variables:'
)
fprintf
(
'%s, '
,
endo_names
{:});
skipline
()
end
end
display_critical_variables
(
reshape
(
dy
,[
ny
periods
])
'
,
M
);
disp
(
'There is most likely something wrong with your model. Try model_diagnostics or another simulation method.'
)
printline
(
105
)
end
...
...
@@ -322,4 +306,30 @@ function [ x, flag, relres ] = lin_solve_robust( A, b , verbose)
flag
=
relres
>
1e-6
;
if
flag
~=
0
&&
verbose
fprintf
(
'WARNING : Failed to find a solution to the linear system\n'
);
end
\ No newline at end of file
end
function
display_critical_variables
(
dyy
,
M
)
if
any
(
isnan
(
dyy
))
indx
=
find
(
any
(
isnan
(
dyy
)));
endo_names
=
cellstr
(
M
.
endo_names
(
indx
,:));
disp
(
'Last iteration provided NaN for the following variables:'
)
fprintf
(
'%s, '
,
endo_names
{:}),
fprintf
(
'\n'
),
end
if
any
(
isinf
(
dyy
))
indx
=
find
(
any
(
isinf
(
dyy
)));
endo_names
=
cellstr
(
M
.
endo_names
(
indx
,:));
disp
(
'Last iteration diverged (Inf) for the following variables:'
)
fprintf
(
'%s, '
,
endo_names
{:}),
fprintf
(
'\n'
),
end
if
any
(
~
isreal
(
dyy
))
indx
=
find
(
any
(
~
isreal
(
dyy
)));
endo_names
=
cellstr
(
M
.
endo_names
(
indx
,:));
disp
(
'Last iteration provided complex number for the following variables:'
)
fprintf
(
'%s, '
,
endo_names
{:}),
fprintf
(
'\n'
),
end
\ No newline at end of file
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