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
Dynare
dynare
Commits
74dc4f81
Commit
74dc4f81
authored
2 years ago
by
Johannes Pfeifer
Browse files
Options
Downloads
Patches
Plain Diff
perfect_foresight_solver.m: loop over dynamic file when mex cannot be used
Closes
Dynare/dynare#1850
parent
05ab494d
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!2031
perfect_foresight_solver.m: loop over dynamic file when mex cannot be used
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/perfect-foresight-models/perfect_foresight_solver.m
+16
-5
16 additions, 5 deletions
matlab/perfect-foresight-models/perfect_foresight_solver.m
with
16 additions
and
5 deletions
matlab/perfect-foresight-models/perfect_foresight_solver.m
+
16
−
5
View file @
74dc4f81
...
...
@@ -192,9 +192,9 @@ if ~oo_.deterministic_simulation.status && ~options_.no_homotopy
warning
(
warning_old_state
);
end
%If simulated paths are complex, take real part and recompute the residuals to check whether this is actually a solution
if
~
isreal
(
oo_
.
endo_simul
(:))
% cannot happen with bytecode or the perfect_foresight_problem DLL
ny
=
size
(
oo_
.
endo_simul
,
1
)
ny
=
size
(
oo_
.
endo_simul
,
1
)
;
if
M_
.
maximum_lag
>
0
y0
=
real
(
oo_
.
endo_simul
(:,
M_
.
maximum_lag
));
else
...
...
@@ -205,9 +205,20 @@ if ~isreal(oo_.endo_simul(:)) % cannot happen with bytecode or the perfect_fores
else
yT
=
NaN
(
ny
,
1
);
end
yy
=
real
(
oo_
.
endo_simul
(:,
M_
.
maximum_lag
+
(
1
:
periods
)));
residuals
=
perfect_foresight_problem
(
yy
(:),
y0
,
yT
,
oo_
.
exo_simul
,
M_
.
params
,
oo_
.
steady_state
,
periods
,
M_
,
options_
);
if
M_
.
maximum_lag
~=
0
&&
M_
.
maximum_lead
~=
0
yy
=
real
(
oo_
.
endo_simul
(:,
M_
.
maximum_lag
+
(
1
:
periods
)));
residuals
=
perfect_foresight_problem
(
yy
(:),
y0
,
yT
,
oo_
.
exo_simul
,
M_
.
params
,
oo_
.
steady_state
,
periods
,
M_
,
options_
);
else
%The perfect_foresight_problem MEX only works on models with lags and leads
i_cols
=
find
(
M_
.
lead_lag_incidence
'
);
residuals
=
NaN
(
ny
,
periods
);
yy
=
real
(
oo_
.
endo_simul
);
for
it
=
(
M_
.
maximum_lag
+
1
):(
M_
.
maximum_lag
+
periods
)
residuals
(:,
it
)
=
feval
([
M_
.
fname
'.dynamic'
],
yy
(
i_cols
),
oo_
.
exo_simul
,
M_
.
params
,
oo_
.
steady_state
,
it
);
i_cols
=
i_cols
+
ny
;
end
residuals
=
residuals
(:);
end
if
max
(
abs
(
residuals
))
<
options_
.
dynatol
.
f
oo_
.
deterministic_simulation
.
status
=
true
;
...
...
This diff is collapsed.
Click to expand it.
Johannes Pfeifer
@JohannesPfeifer
mentioned in commit
d465b613
·
2 years ago
mentioned in commit
d465b613
mentioned in commit d465b6133b0ae49dcc5b742ecdcf0481cadee69b
Toggle commit list
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