Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
preprocessor
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
preprocessor
Commits
c7093a83
Commit
c7093a83
authored
Mar 15, 2010
by
Houtan Bastani
Browse files
Options
Downloads
Patches
Plain Diff
second derivatives of jacobian w.r.t. parameters
parent
be6b9dcd
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
DynamicModel.cc
+36
-1
36 additions, 1 deletion
DynamicModel.cc
DynamicModel.hh
+7
-0
7 additions, 0 deletions
DynamicModel.hh
with
43 additions
and
1 deletion
DynamicModel.cc
+
36
−
1
View file @
c7093a83
...
...
@@ -2657,6 +2657,20 @@ DynamicModel::computeParamsDerivatives()
jacobian_params_derivatives
[
make_pair
(
eq
,
make_pair
(
var
,
param
))]
=
d2
;
}
for
(
second_derivatives_type
::
const_iterator
it2
=
jacobian_params_derivatives
.
begin
();
it2
!=
jacobian_params_derivatives
.
end
();
it2
++
)
{
int
eq
=
it2
->
first
.
first
;
int
var
=
it2
->
first
.
second
.
first
;
int
param1
=
it2
->
first
.
second
.
second
;
NodeID
d1
=
it2
->
second
;
NodeID
d2
=
d1
->
getDerivative
(
param
);
if
(
d2
==
Zero
)
continue
;
jacobian_params_second_derivatives
[
make_pair
(
eq
,
make_pair
(
var
,
make_pair
(
param1
,
param
)))]
=
d2
;
}
for
(
second_derivatives_type
::
const_iterator
it2
=
second_derivatives
.
begin
();
it2
!=
second_derivatives
.
end
();
it2
++
)
{
...
...
@@ -2750,9 +2764,30 @@ DynamicModel::writeParamsDerivativesFile(const string &basename) const
paramsDerivsFile
<<
";"
<<
endl
;
}
// Write jacobian second derivatives
paramsDerivsFile
<<
"gpp = zeros("
<<
equation_number
()
<<
", "
<<
dynJacobianColsNbr
<<
", "
<<
symbol_table
.
param_nbr
()
<<
", "
<<
symbol_table
.
param_nbr
()
<<
");"
<<
endl
;
for
(
third_derivatives_type
::
const_iterator
it
=
jacobian_params_second_derivatives
.
begin
();
it
!=
jacobian_params_second_derivatives
.
end
();
it
++
)
{
int
eq
=
it
->
first
.
first
;
int
var
=
it
->
first
.
second
.
first
;
int
param1
=
it
->
first
.
second
.
second
.
first
;
int
param2
=
it
->
first
.
second
.
second
.
second
;
NodeID
d2
=
it
->
second
;
int
var_col
=
getDynJacobianCol
(
var
)
+
1
;
int
param1_col
=
symbol_table
.
getTypeSpecificID
(
getSymbIDByDerivID
(
param1
))
+
1
;
int
param2_col
=
symbol_table
.
getTypeSpecificID
(
getSymbIDByDerivID
(
param2
))
+
1
;
paramsDerivsFile
<<
"gpp("
<<
eq
+
1
<<
", "
<<
var_col
<<
", "
<<
param1_col
<<
", "
<<
param2_col
<<
") = "
;
d2
->
writeOutput
(
paramsDerivsFile
,
oMatlabDynamicModel
,
params_derivs_temporary_terms
);
paramsDerivsFile
<<
";"
<<
endl
;
}
// Write hessian derivatives
paramsDerivsFile
<<
"
g
p = zeros("
<<
equation_number
()
<<
", "
<<
dynJacobianColsNbr
<<
", "
paramsDerivsFile
<<
"
h
p = zeros("
<<
equation_number
()
<<
", "
<<
dynJacobianColsNbr
<<
", "
<<
dynJacobianColsNbr
<<
", "
<<
symbol_table
.
param_nbr
()
<<
");"
<<
endl
;
for
(
third_derivatives_type
::
const_iterator
it
=
hessian_params_derivatives
.
begin
();
...
...
This diff is collapsed.
Click to expand it.
DynamicModel.hh
+
7
−
0
View file @
c7093a83
...
...
@@ -71,6 +71,13 @@ private:
*/
second_derivatives_type
jacobian_params_derivatives
;
//! Second derivatives of the jacobian w.r. to parameters
/*! First index is equation number, second is endo/exo/exo_det variable, and third and fourth are parameters.
Only non-null derivatives are stored in the map.
Variable and parameter indices are those of the getDerivID() method.
*/
third_derivatives_type
jacobian_params_second_derivatives
;
//! Derivatives of the hessian w.r. to parameters
/*! First index is equation number, first and second are endo/exo/exo_det variable, and third is parameter.
Only non-null derivatives are stored in the map.
...
...
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