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
19ca8624
Commit
19ca8624
authored
May 6, 2020
by
Sébastien Villemot
Committed by
MichelJuillard
May 7, 2020
Browse files
Options
Downloads
Patches
Plain Diff
Block decomposition: simplify code for ordering dynamic Jacobian columns
parent
39a1a4a1
No related branches found
No related tags found
1 merge request
!19
Initval histval file
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/CodeInterpreter.hh
+11
-11
11 additions, 11 deletions
src/CodeInterpreter.hh
src/DynamicModel.cc
+136
-368
136 additions, 368 deletions
src/DynamicModel.cc
src/DynamicModel.hh
+14
-7
14 additions, 7 deletions
src/DynamicModel.hh
with
161 additions
and
386 deletions
src/CodeInterpreter.hh
+
11
−
11
View file @
19ca8624
...
...
@@ -1406,9 +1406,9 @@ private:
uint8_t
type
;
vector
<
int
>
variable
;
vector
<
int
>
equation
;
vector
<
unsigned
int
>
other_endogenous
;
vector
<
unsigned
int
>
exogenous
;
vector
<
unsigned
int
>
det_exogenous
;
vector
<
int
>
other_endogenous
;
vector
<
int
>
exogenous
;
vector
<
int
>
det_exogenous
;
bool
is_linear
;
vector
<
Block_contain_type
>
Block_Contain_
;
int
endo_nbr
;
...
...
@@ -1429,14 +1429,14 @@ public:
const
vector
<
int
>
&
variable_arg
,
const
vector
<
int
>
&
equation_arg
,
bool
is_linear_arg
,
int
endo_nbr_arg
,
int
Max_Lag_arg
,
int
Max_Lead_arg
,
int
&
u_count_int_arg
,
int
nb_col_jacob_arg
,
unsigned
int
det_exo_size_arg
,
unsigned
int
nb_col_det_exo_jacob_arg
,
unsigned
int
exo_size_arg
,
unsigned
int
nb_col_exo_jacob_arg
,
unsigned
int
other_endo_size_arg
,
unsigned
int
nb_col_other_endo_jacob_arg
,
const
vector
<
unsigned
int
>
&
det_exogenous_arg
,
const
vector
<
unsigned
int
>
&
exogenous_arg
,
const
vector
<
unsigned
int
>
&
other_endogenous_arg
)
:
vector
<
int
>
det_exogenous_arg
,
vector
<
int
>
exogenous_arg
,
vector
<
int
>
other_endogenous_arg
)
:
size
{
static_cast
<
int
>
(
size_arg
)},
type
{
static_cast
<
uint8_t
>
(
type_arg
)},
variable
{
variable_arg
.
begin
()
+
first_element
,
variable_arg
.
begin
()
+
(
first_element
+
block_size
)},
equation
{
equation_arg
.
begin
()
+
first_element
,
equation_arg
.
begin
()
+
(
first_element
+
block_size
)},
other_endogenous
{
other_endogenous_arg
},
exogenous
{
exogenous_arg
},
det_exogenous
{
det_exogenous_arg
},
other_endogenous
{
move
(
other_endogenous_arg
)
},
exogenous
{
move
(
exogenous_arg
)
},
det_exogenous
{
move
(
det_exogenous_arg
)
},
is_linear
{
is_linear_arg
},
endo_nbr
{
endo_nbr_arg
},
Max_Lag
{
Max_Lag_arg
},
...
...
@@ -1553,7 +1553,7 @@ public:
{
return
variable
;
}
inline
vector
<
unsigned
int
>
inline
vector
<
int
>
get_exogenous
()
{
return
exogenous
;
...
...
@@ -1632,19 +1632,19 @@ public:
for
(
unsigned
int
i
=
0
;
i
<
det_exo_size
;
i
++
)
{
unsigned
int
tmp_i
;
int
tmp_i
;
memcpy
(
&
tmp_i
,
code
,
sizeof
(
tmp_i
));
code
+=
sizeof
(
tmp_i
);
det_exogenous
.
push_back
(
tmp_i
);
}
for
(
unsigned
int
i
=
0
;
i
<
exo_size
;
i
++
)
{
unsigned
int
tmp_i
;
int
tmp_i
;
memcpy
(
&
tmp_i
,
code
,
sizeof
(
tmp_i
));
code
+=
sizeof
(
tmp_i
);
exogenous
.
push_back
(
tmp_i
);
}
for
(
unsigned
int
i
=
0
;
i
<
other_endo_size
;
i
++
)
{
unsigned
int
tmp_i
;
int
tmp_i
;
memcpy
(
&
tmp_i
,
code
,
sizeof
(
tmp_i
));
code
+=
sizeof
(
tmp_i
);
other_endogenous
.
push_back
(
tmp_i
);
}
...
...
This diff is collapsed.
Click to expand it.
src/DynamicModel.cc
+
136
−
368
View file @
19ca8624
This diff is collapsed.
Click to expand it.
src/DynamicModel.hh
+
14
−
7
View file @
19ca8624
...
...
@@ -110,6 +110,15 @@ private:
vector
<
map
<
tuple
<
int
,
int
,
int
>
,
expr_t
>>
blocks_derivatives_other_endo
,
blocks_derivatives_exo
,
blocks_derivatives_exo_det
;
// For each block, gives type-specific other endos / exo / exo det that appear in it
vector
<
set
<
int
>>
blocks_other_endo
,
blocks_exo
,
blocks_exo_det
;
/* For each block, and for each variable type, maps (variable ID, lag) to
Jacobian column.
For the “endo” version, the variable ID is the index within the block. For
the three others, it’s the type-specific ID */
vector
<
map
<
pair
<
int
,
int
>
,
int
>>
blocks_jacob_cols_endo
,
blocks_jacob_cols_other_endo
,
blocks_jacob_cols_exo
,
blocks_jacob_cols_exo_det
;
//! Writes dynamic model file (Matlab version)
void
writeDynamicMFile
(
const
string
&
basename
)
const
;
//! Writes dynamic model file (Julia version)
...
...
@@ -177,8 +186,11 @@ private:
/*! Also computes max_{endo,exo}_{lead_lag}, and initializes dynJacobianColsNbr to the number of dynamic endos */
void
computeDerivIDs
();
//! Collecte the derivatives w.r. to endogenous of the block, to endogenous of previouys blocks and to exogenous
void
collect_block_first_order_derivatives
();
/* Compute the Jacobian column indices in the block decomposition case
(stored in blocks_jacob_cols_*).
Also fills auxiliary structures related to “other” endogenous and
exogenous: blocks{,_derivatives}_{other_endo,exo_exo_det} */
void
computeBlockDynJacobianCols
();
//! Factorized code for substitutions of leads/lags
/*! \param[in] type determines which type of variables is concerned
...
...
@@ -190,11 +202,6 @@ private:
//! Indicate if the temporary terms are computed for the overall model (true) or not (false). Default value true
bool
global_temporary_terms
{
true
};
//!List for each block and for each lag-lead all the other endogenous variables and exogenous variables
using
var_t
=
set
<
int
>
;
using
lag_var_t
=
map
<
int
,
var_t
>
;
vector
<
lag_var_t
>
other_endo_block
,
exo_block
,
exo_det_block
;
//! Help computeXrefs to compute the reverse references (i.e. param->eqs, endo->eqs, etc)
void
computeRevXref
(
map
<
pair
<
int
,
int
>
,
set
<
int
>>
&
xrefset
,
const
set
<
pair
<
int
,
int
>>
&
eiref
,
int
eqn
);
...
...
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