Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
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
Johannes Pfeifer
dynare
Commits
63564e7d
Verified
Commit
63564e7d
authored
9 months ago
by
Sébastien Villemot
Browse files
Options
Downloads
Patches
Plain Diff
Discretionary policy: use sparse representation for the dynamic Jacobian
Ref. #1859
parent
14518f55
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/discretionary_policy/discretionary_policy_1.m
+9
-21
9 additions, 21 deletions
matlab/discretionary_policy/discretionary_policy_1.m
with
9 additions
and
21 deletions
matlab/discretionary_policy/discretionary_policy_1.m
+
9
−
21
View file @
63564e7d
...
@@ -76,32 +76,20 @@ g2_v = feval([M_.fname,'.objective.sparse.static_g2'], y, [], params, T_order, T
...
@@ -76,32 +76,20 @@ g2_v = feval([M_.fname,'.objective.sparse.static_g2'], y, [], params, T_order, T
W
=
build_two_dim_hessian
(
M_
.
objective_g2_sparse_indices
,
g2_v
,
1
,
M_
.
endo_nbr
);
W
=
build_two_dim_hessian
(
M_
.
objective_g2_sparse_indices
,
g2_v
,
1
,
M_
.
endo_nbr
);
W
=
reshape
(
W
,
M_
.
endo_nbr
,
M_
.
endo_nbr
);
W
=
reshape
(
W
,
M_
.
endo_nbr
,
M_
.
endo_nbr
);
klen
=
M_
.
maximum_lag
+
M_
.
maximum_lead
+
1
;
iyv
=
M_
.
lead_lag_incidence
'
;
% Find the jacobian
% Find the jacobian
z
=
repmat
(
ys
,
1
,
klen
);
y3n
=
repmat
(
ys
,
1
,
3
);
iyr0
=
find
(
iyv
(:))
;
x
=
zeros
(
M_
.
exo_nbr
+
M_
.
exo_det_nbr
,
1
);
[
resid
,
T_order
,
T
]
=
feval
([
M_
.
fname
'.sparse.dynamic_resid'
],
y3n
,
x
,
M_
.
params
,
ys
);
z
=
z
(
iyr0
);
if
max
(
abs
(
resid
))
>
options_
.
solve_tolf
it_
=
M_
.
maximum_lag
+
1
;
[
junk
,
jacobia_
]
=
feval
([
M_
.
fname
'.dynamic'
],
z
,
zeros
(
M_
.
exo_nbr
+
M_
.
exo_det_nbr
,
klen
),
M_
.
params
,
ys
,
it_
);
if
max
(
abs
(
junk
))
>
options_
.
solve_tolf
info
=
65
;
%the model must be written in deviation form and not have constant terms or have a steady state provided
info
=
65
;
%the model must be written in deviation form and not have constant terms or have a steady state provided
return
;
return
;
end
end
g1
=
feval
([
M_
.
fname
'.sparse.dynamic_g1'
],
y3n
,
x
,
M_
.
params
,
ys
,
M_
.
dynamic_g1_sparse_rowval
,
M_
.
dynamic_g1_sparse_colval
,
M_
.
dynamic_g1_sparse_colptr
,
T_order
,
T
);
Indices
=
{
'lag'
,
'contemp'
,
'lead'
};
A
.
lag
=
full
(
g1
(:,
1
:
M_
.
endo_nbr
));
iter
=
1
;
A
.
contemp
=
full
(
g1
(:,
M_
.
endo_nbr
+
(
1
:
M_
.
endo_nbr
)));
for
j
=
1
:
numel
(
Indices
)
A
.
lead
=
full
(
g1
(:,
2
*
M_
.
endo_nbr
+
(
1
:
M_
.
endo_nbr
)));
A
.
(
Indices
{
j
})
=
zeros
(
M_
.
eq_nbr
,
M_
.
endo_nbr
);
B
=
full
(
g1
(:,
3
*
M_
.
endo_nbr
+
1
:
end
));
if
strcmp
(
Indices
{
j
},
'contemp'
)
||
(
strcmp
(
Indices
{
j
},
'lag'
)
&&
M_
.
maximum_lag
)
||
(
strcmp
(
Indices
{
j
},
'lead'
)
&&
M_
.
maximum_lead
)
[
~
,
row
,
col
]
=
find
(
M_
.
lead_lag_incidence
(
iter
,:));
A
.
(
Indices
{
j
})(:,
row
)
=
jacobia_
(:,
col
);
iter
=
iter
+
1
;
end
end
B
=
jacobia_
(:,
nnz
(
iyv
)
+
1
:
end
);
%%% MAIN ENGINE %%%
%%% MAIN ENGINE %%%
...
...
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