Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dynare
preprocessor
Commits
7ac33099
Commit
7ac33099
authored
Apr 17, 2018
by
Houtan Bastani
Browse files
support undiff in pac model
parent
bb1cc0be
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/DynamicModel.cc
View file @
7ac33099
...
...
@@ -3258,6 +3258,7 @@ void
DynamicModel
::
getVarModelVariablesFromEqTags
(
vector
<
string
>
&
var_model_eqtags
,
vector
<
int
>
&
eqnumber
,
vector
<
int
>
&
lhs
,
vector
<
expr_t
>
&
lhs_expr_t
,
vector
<
set
<
pair
<
int
,
int
>
>
>
&
rhs
,
vector
<
bool
>
&
nonstationary
)
const
{
...
...
@@ -3316,6 +3317,10 @@ DynamicModel::getVarModelVariablesFromEqTags(vector<string> &var_model_eqtags,
eqnumber
.
push_back
(
eqn
);
lhs
.
push_back
(
it
->
first
);
lhs_set
.
clear
();
set
<
expr_t
>
lhs_expr_t_set
;
equations
[
eqn
]
->
get_arg1
()
->
collectVARLHSVariable
(
lhs_expr_t_set
);
lhs_expr_t
.
push_back
(
*
(
lhs_expr_t_set
.
begin
()));
equations
[
eqn
]
->
get_arg2
()
->
collectDynamicVariables
(
eEndogenous
,
rhs_set
);
for
(
it
=
rhs_set
.
begin
();
it
!=
rhs_set
.
end
();
it
++
)
...
...
@@ -3332,7 +3337,7 @@ DynamicModel::getVarModelVariablesFromEqTags(vector<string> &var_model_eqtags,
int
DynamicModel
::
getVarMaxLag
(
StaticModel
&
static_model
,
vector
<
int
>
&
eqnumber
)
const
{
set
<expr_t> lhs;
vector
<
expr_t
>
lhs
;
for
(
vector
<
int
>::
const_iterator
it
=
eqnumber
.
begin
();
it
!=
eqnumber
.
end
();
it
++
)
{
...
...
@@ -3344,11 +3349,11 @@ DynamicModel::getVarMaxLag(StaticModel &static_model, vector<int> &eqnumber) con
<<
". A VAR may only have one endogenous variable on the LHS. "
<<
endl
;
exit
(
EXIT_FAILURE
);
}
lhs.
insert
(*(lhs_set.begin()));
lhs
.
push_back
(
*
(
lhs_set
.
begin
()));
}
set
<
expr_t
>
lhs_static
;
for(
set
<expr_t>::const_iterator it = lhs.begin();
for
(
vector
<
expr_t
>::
const_iterator
it
=
lhs
.
begin
();
it
!=
lhs
.
end
();
it
++
)
lhs_static
.
insert
((
*
it
)
->
toStatic
(
static_model
));
...
...
@@ -3444,23 +3449,9 @@ DynamicModel::addEquationsForVar(map<string, pair<SymbolList, int> > &var_model_
cout
<<
"Accounting for var_model lags not in model block: added "
<<
count
<<
" auxiliary variables and equations."
<<
endl
;
}
int
DynamicModel::get_undiff_max_lag(vector<int> &eqnumber, vector<int> &lhs)
{
int max_lag = 0;
for (vector<int>::const_iterator it = eqnumber.begin();
it != eqnumber.end(); it++)
{
int max_lag_tmp = dynamic_cast<BinaryOpNode *>(equations[*it])->get_arg2()->PacMaxLag(lhs);
if (max_lag_tmp > max_lag)
max_lag = max_lag_tmp;
}
return max_lag;
}
void
DynamicModel::
u
ndiff
_lhs_for_p
ac(vector<int> &lhs, vector<bool> &diff, vector<int> &orig_diff_var,
vector<int> &eqnumber, map<string, int> &undiff,
map<int, int> &undiff
_table)
DynamicModel
::
getU
ndiff
LHSForP
ac
(
vector
<
int
>
&
lhs
,
vector
<
expr_t
>
&
lhs_expr_t
,
vector
<
bool
>
&
diff
,
vector
<
int
>
&
orig_diff_var
,
vector
<
int
>
&
eqnumber
,
map
<
string
,
int
>
&
undiff
,
ExprNode
::
subst_table_t
&
diff_subst
_table
)
{
if
(
undiff
.
empty
())
return
;
...
...
@@ -3486,18 +3477,12 @@ DynamicModel::undiff_lhs_for_pac(vector<int> &lhs, vector<bool> &diff, vector<in
}
int
i
=
0
;
bool found = false;
for
(
vector
<
int
>::
const_iterator
it1
=
eqnumber
.
begin
();
it1 != eqnumber.end(); it1++)
if (eqn == i)
{
found = true;
break;
}
else
i++;
it1
!=
eqnumber
.
end
();
it1
++
,
i
++
)
if
(
*
it1
==
eqn
)
break
;
if (
!found
)
if
(
eqnumber
[
i
]
!=
eqn
)
{
cerr
<<
"ERROR: equation not found in VAR"
;
exit
(
EXIT_FAILURE
);
...
...
@@ -3511,18 +3496,67 @@ DynamicModel::undiff_lhs_for_pac(vector<int> &lhs, vector<bool> &diff, vector<in
exit
(
EXIT_FAILURE
);
}
bool
printerr
=
false
;
ExprNode
::
subst_table_t
::
const_iterator
it1
;
expr_t
node
=
NULL
;
expr_t
aux_var
=
lhs_expr_t
.
at
(
i
);
for
(
it1
=
diff_subst_table
.
begin
();
it1
!=
diff_subst_table
.
end
();
it1
++
)
if
(
it1
->
second
==
aux_var
)
{
node
=
const_cast
<
expr_t
>
(
it1
->
first
);
break
;
}
if
(
node
==
NULL
)
{
cerr
<<
"Unexpected error encountered."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
for
(
int
j
=
it
->
second
;
j
>
0
;
j
--
)
if (
undiff_table.find(lhs.at(eqnumber.at(i))) == undiff_table.end()
)
if
(
printerr
)
{
cerr
<<
"You are undiffing the LHS of equation #"
<<
eqn
<<
" "
<< it->second << " times but it has only been diffed " << j
- 1
<< " time(s)" << endl;
<<
it
->
second
<<
" times but it has only been diffed "
<<
j
<<
" time(s)"
<<
endl
;
exit
(
EXIT_FAILURE
);
}
else
lhs.at(eqnumber.at(i)) = undiff_table.at(lhs.at(eqnumber.at(i)));
{
node
=
node
->
undiff
();
it1
=
diff_subst_table
.
find
(
node
);
if
(
it1
==
diff_subst_table
.
end
())
printerr
=
true
;
}
if
(
printerr
)
{
// we have undiffed something like diff(x), hence x is not in diff_subst_table
lhs_expr_t
.
at
(
i
)
=
node
;
lhs
.
at
(
i
)
=
dynamic_cast
<
VariableNode
*>
(
node
)
->
get_symb_id
();
}
else
{
lhs_expr_t
.
at
(
i
)
=
const_cast
<
expr_t
>
(
it1
->
first
);
lhs
.
at
(
i
)
=
const_cast
<
VariableNode
*>
(
it1
->
second
)
->
get_symb_id
();
}
}
}
int
DynamicModel
::
getUndiffMaxLag
(
StaticModel
&
static_model
,
vector
<
expr_t
>
&
lhs
,
vector
<
int
>
&
eqnumber
)
const
{
set
<
expr_t
>
lhs_static
;
for
(
vector
<
expr_t
>::
const_iterator
it
=
lhs
.
begin
();
it
!=
lhs
.
end
();
it
++
)
lhs_static
.
insert
((
*
it
)
->
toStatic
(
static_model
));
int
max_lag
=
0
;
for
(
vector
<
int
>::
const_iterator
it
=
eqnumber
.
begin
();
it
!=
eqnumber
.
end
();
it
++
)
equations
[
*
it
]
->
get_arg2
()
->
VarMaxLag
(
static_model
,
lhs_static
,
max_lag
);
return
max_lag
;
}
void
DynamicModel
::
walkPacParameters
()
{
...
...
@@ -5136,7 +5170,7 @@ DynamicModel::substituteAdl()
}
void
DynamicModel::substituteDiff(StaticModel &static_model,
map<int, int> &undiff
_table)
DynamicModel
::
substituteDiff
(
StaticModel
&
static_model
,
ExprNode
::
subst_table_t
&
diff_subst
_table
)
{
// Find diff Nodes
diff_table_t
diff_table
;
...
...
@@ -5149,16 +5183,15 @@ DynamicModel::substituteDiff(StaticModel &static_model, map<int, int> &undiff_ta
// Substitute in model local variables
vector
<
BinaryOpNode
*>
neweqs
;
ExprNode::subst_table_t diff_subst_table;
for
(
map
<
int
,
expr_t
>::
iterator
it
=
local_variables_table
.
begin
();
it
!=
local_variables_table
.
end
();
it
++
)
it->second = it->second->substituteDiff(static_model, diff_table, diff_subst_table, neweqs
, undiff_table
);
it
->
second
=
it
->
second
->
substituteDiff
(
static_model
,
diff_table
,
diff_subst_table
,
neweqs
);
// Substitute in equations
for
(
int
i
=
0
;
i
<
(
int
)
equations
.
size
();
i
++
)
{
BinaryOpNode
*
substeq
=
dynamic_cast
<
BinaryOpNode
*>
(
equations
[
i
]
->
substituteDiff(static_model, diff_table, diff_subst_table, neweqs
, undiff_table
));
substituteDiff
(
static_model
,
diff_table
,
diff_subst_table
,
neweqs
));
assert
(
substeq
!=
NULL
);
equations
[
i
]
=
substeq
;
}
...
...
src/DynamicModel.hh
View file @
7ac33099
...
...
@@ -290,6 +290,7 @@ public:
void
getVarModelVariablesFromEqTags
(
vector
<
string
>
&
var_model_eqtags
,
vector
<
int
>
&
eqnumber
,
vector
<
int
>
&
lhs
,
vector
<
expr_t
>
&
lhs_expr_t
,
vector
<
set
<
pair
<
int
,
int
>
>
>
&
rhs
,
vector
<
bool
>
&
nonstationary
)
const
;
...
...
@@ -313,7 +314,7 @@ public:
vector
<
bool
>
&
nonstationary
,
int
growth_symb_id
);
//! Get the max lag for the PAC VAR
int
get
_u
ndiff
_max_lag
(
vector
<
int
>
&
eqnumber
,
vector
<
int
>
&
lhs
)
;
int
get
U
ndiff
MaxLag
(
StaticModel
&
static_model
,
vector
<
expr_t
>
&
lhs
,
vector
<
int
>
&
eqnumber
)
const
;
//! Substitutes pac_expectation operator
void
substitutePacExpectation
();
...
...
@@ -406,11 +407,11 @@ public:
void
substituteAdl
();
//! Substitutes diff operator
void
substituteDiff
(
StaticModel
&
static_model
,
map
<
int
,
int
>
&
undiff
_table
);
void
substituteDiff
(
StaticModel
&
static_model
,
ExprNode
::
subst_table_t
&
diff_subst
_table
);
//! Table to undiff LHS variables for pac vector z
void
u
ndiff
_lhs_for_p
ac
(
vector
<
int
>
&
lhs
,
vector
<
bool
>
&
diff
,
vector
<
int
>
&
orig_diff_var
,
vector
<
int
>
&
eqnumber
,
map
<
string
,
int
>
&
undiff
,
map
<
int
,
int
>
&
undiff
_table
);
void
getU
ndiff
LHSForP
ac
(
vector
<
int
>
&
lhs
,
vector
<
expr_t
>
&
lhs_expr_t
,
vector
<
bool
>
&
diff
,
vector
<
int
>
&
orig_diff_var
,
vector
<
int
>
&
eqnumber
,
map
<
string
,
int
>
&
undiff
,
ExprNode
::
subst_table_t
&
diff_subst
_table
);
//! Adds contents of diff_aux_equations to the back of aux_equations
void
combineDiffAuxEquations
();
...
...
src/ExprNode.cc
View file @
7ac33099
...
...
@@ -462,6 +462,12 @@ NumConstNode::maxLag() const
return 0;
}
expr_t
NumConstNode::undiff() const
{
return const_cast<NumConstNode *>(this);
}
void
NumConstNode::VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const
{
...
...
@@ -527,7 +533,7 @@ NumConstNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table)
}
expr_t
NumConstNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs
, map<int, int> &undiff_table
) const
NumConstNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
return const_cast<NumConstNode *>(this);
}
...
...
@@ -1352,6 +1358,12 @@ VariableNode::maxLag() const
}
}
expr_t
VariableNode::undiff() const
{
return const_cast<VariableNode *>(this);
}
void
VariableNode::VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const
{
...
...
@@ -1383,7 +1395,8 @@ VariableNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table)
}
expr_t
VariableNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, map<int, int> &undiff_table) const
VariableNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table,
vector<BinaryOpNode *> &neweqs) const
{
return const_cast<VariableNode *>(this);
}
...
...
@@ -2896,6 +2909,14 @@ UnaryOpNode::maxLag() const
return arg->maxLag();
}
expr_t
UnaryOpNode::undiff() const
{
if (op_code == oDiff)
return arg;
return arg->undiff();
}
void
UnaryOpNode::VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const
{
...
...
@@ -2992,11 +3013,11 @@ UnaryOpNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table)
expr_t
UnaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table,
vector<BinaryOpNode *> &neweqs
, map<int, int> &undiff_table
) const
vector<BinaryOpNode *> &neweqs) const
{
if (op_code != oDiff)
{
expr_t argsubst = arg->substituteDiff(static_datatree, diff_table, subst_table, neweqs
, undiff_table
);
expr_t argsubst = arg->substituteDiff(static_datatree, diff_table, subst_table, neweqs);
return buildSimilarUnaryOpNode(argsubst, datatree);
}
...
...
@@ -3006,7 +3027,11 @@ UnaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table,
expr_t sthis = dynamic_cast<UnaryOpNode *>(this->toStatic(static_datatree));
diff_table_t::iterator it = diff_table.find(sthis);
assert(it != diff_table.end() && it->second[-arg->maxLag()] == this);
if (it == diff_table.end() || it->second[-arg->maxLag()] != this)
{
cerr << "Internal error encountered. Please report" << endl;
exit(EXIT_FAILURE);
}
int last_arg_max_lag = 0;
VariableNode *last_aux_var = NULL;
...
...
@@ -3014,7 +3039,7 @@ UnaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table,
rit != it->second.rend(); rit++)
{
expr_t argsubst = dynamic_cast<UnaryOpNode *>(rit->second)->
get_arg()->substituteDiff(static_datatree, diff_table, subst_table, neweqs
, undiff_table
);
get_arg()->substituteDiff(static_datatree, diff_table, subst_table, neweqs);
int symb_id;
VariableNode *vn = dynamic_cast<VariableNode *>(argsubst);
if (rit == it->second.rbegin())
...
...
@@ -3032,11 +3057,10 @@ UnaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table,
datatree.AddMinus(argsubst,
argsubst->decreaseLeadsLags(1)))));
subst_table[rit->second] = dynamic_cast<VariableNode *>(last_aux_var);
undiff_table[symb_id] = vn->get_symb_id();
}
else
{
// just add equation of form: AUX_DIFF =
ORIG
_AUX_
DIFF(last_arg_max_lag - rit->first
)
// just add equation of form: AUX_DIFF =
LAST
_AUX_
VAR(-1
)
VariableNode *new_aux_var = NULL;
for (int i = last_arg_max_lag; i > rit->first; i--)
{
...
...
@@ -4577,6 +4601,14 @@ BinaryOpNode::maxLag() const
return max(arg1->maxLag(), arg2->maxLag());
}
expr_t
BinaryOpNode::undiff() const
{
expr_t arg1subst = arg1->undiff();
expr_t arg2subst = arg2->undiff();
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
}
int
BinaryOpNode::PacMaxLag(vector<int> &lhs) const
{
...
...
@@ -4727,10 +4759,11 @@ BinaryOpNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table)
}
expr_t
BinaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, map<int, int> &undiff_table) const
BinaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table,
vector<BinaryOpNode *> &neweqs) const
{
expr_t arg1subst = arg1->substituteDiff(static_datatree, diff_table, subst_table, neweqs
, undiff_table
);
expr_t arg2subst = arg2->substituteDiff(static_datatree, diff_table, subst_table, neweqs
, undiff_table
);
expr_t arg1subst = arg1->substituteDiff(static_datatree, diff_table, subst_table, neweqs);
expr_t arg2subst = arg2->substituteDiff(static_datatree, diff_table, subst_table, neweqs);
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
}
...
...
@@ -5511,6 +5544,15 @@ TrinaryOpNode::maxLag() const
return max(arg1->maxLag(), max(arg2->maxLag(), arg3->maxLag()));
}
expr_t
TrinaryOpNode::undiff() const
{
expr_t arg1subst = arg1->undiff();
expr_t arg2subst = arg2->undiff();
expr_t arg3subst = arg3->undiff();
return buildSimilarTrinaryOpNode(arg1subst, arg2subst, arg3subst, datatree);
}
void
TrinaryOpNode::VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const
{
...
...
@@ -5620,11 +5662,12 @@ TrinaryOpNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table
}
expr_t
TrinaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, map<int, int> &undiff_table) const
TrinaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table,
vector<BinaryOpNode *> &neweqs) const
{
expr_t arg1subst = arg1->substituteDiff(static_datatree, diff_table, subst_table, neweqs
, undiff_table
);
expr_t arg2subst = arg2->substituteDiff(static_datatree, diff_table, subst_table, neweqs
, undiff_table
);
expr_t arg3subst = arg3->substituteDiff(static_datatree, diff_table, subst_table, neweqs
, undiff_table
);
expr_t arg1subst = arg1->substituteDiff(static_datatree, diff_table, subst_table, neweqs);
expr_t arg2subst = arg2->substituteDiff(static_datatree, diff_table, subst_table, neweqs);
expr_t arg3subst = arg3->substituteDiff(static_datatree, diff_table, subst_table, neweqs);
return buildSimilarTrinaryOpNode(arg1subst, arg2subst, arg3subst, datatree);
}
...
...
@@ -5925,6 +5968,15 @@ AbstractExternalFunctionNode::maxLag() const
return val;
}
expr_t
AbstractExternalFunctionNode::undiff() const
{
vector<expr_t> arguments_subst;
for (vector<expr_t>::const_iterator it = arguments.begin(); it != arguments.end(); it++)
arguments_subst.push_back((*it)->undiff());
return buildSimilarExternalFunctionNode(arguments_subst, datatree);
}
void
AbstractExternalFunctionNode::VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const
{
...
...
@@ -6023,11 +6075,12 @@ AbstractExternalFunctionNode::findDiffNodes(DataTree &static_datatree, diff_tabl
}
expr_t
AbstractExternalFunctionNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, map<int, int> &undiff_table) const
AbstractExternalFunctionNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table,
vector<BinaryOpNode *> &neweqs) const
{
vector<expr_t> arguments_subst;
for (vector<expr_t>::const_iterator it = arguments.begin(); it != arguments.end(); it++)
arguments_subst.push_back((*it)->substituteDiff(static_datatree, diff_table, subst_table, neweqs
, undiff_table
));
arguments_subst.push_back((*it)->substituteDiff(static_datatree, diff_table, subst_table, neweqs));
return buildSimilarExternalFunctionNode(arguments_subst, datatree);
}
...
...
@@ -7434,6 +7487,12 @@ VarExpectationNode::maxLag() const
return 0;
}
expr_t
VarExpectationNode::undiff() const
{
return const_cast<VarExpectationNode *>(this);
}
void
VarExpectationNode::VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const
{
...
...
@@ -7573,7 +7632,8 @@ VarExpectationNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_
}
expr_t
VarExpectationNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, map<int, int> &undiff_table) const
VarExpectationNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table,
vector<BinaryOpNode *> &neweqs) const
{
return const_cast<VarExpectationNode *>(this);
}
...
...
@@ -7843,6 +7903,12 @@ PacExpectationNode::maxLag() const
return 0;
}
expr_t
PacExpectationNode::undiff() const
{
return const_cast<PacExpectationNode *>(this);
}
void
PacExpectationNode::VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const
{
...
...
@@ -7981,7 +8047,8 @@ PacExpectationNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_
}
expr_t
PacExpectationNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, map<int, int> &undiff_table) const
PacExpectationNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table,
vector<BinaryOpNode *> &neweqs) const
{
return const_cast<PacExpectationNode *>(this);
}
...
...
src/ExprNode.hh
View file @
7ac33099
...
...
@@ -59,6 +59,7 @@ typedef map<int, double> eval_context_t;
typedef
map
<
pair
<
int
,
vector
<
expr_t
>
>
,
int
>
deriv_node_temp_terms_t
;
//! Type for the substitution map used in the process of substitutitng diff expressions
//! diff_table[static_expr_t][lag] -> dynamic_expr_t
typedef
map
<
expr_t
,
map
<
int
,
expr_t
>
>
diff_table_t
;
//! Possible types of output when writing ExprNode(s)
...
...
@@ -359,6 +360,8 @@ class ExprNode
//! Takes account of undiffed LHS variables in calculating the max lag
virtual
int
PacMaxLag
(
vector
<
int
>
&
lhs
)
const
=
0
;
virtual
expr_t
undiff
()
const
=
0
;
//! Returns a new expression where all the leads/lags have been shifted backwards by the same amount
/*!
Only acts on endogenous, exogenous, exogenous det
...
...
@@ -486,7 +489,7 @@ class ExprNode
//! Substitute diff operator
virtual
void
findDiffNodes
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
)
const
=
0
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
map
<
int
,
int
>
&
undiff_table
)
const
=
0
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
=
0
;
//! Substitute pac_expectation operator
virtual
expr_t
substitutePacExpectation
(
map
<
const
PacExpectationNode
*
,
const
BinaryOpNode
*>
&
subst_table
)
=
0
;
...
...
@@ -568,6 +571,7 @@ public:
virtual
int
maxLag
()
const
;
virtual
void
VarMaxLag
(
DataTree
&
static_datatree
,
set
<
expr_t
>
&
static_lhs
,
int
&
max_lag
)
const
;
virtual
int
PacMaxLag
(
vector
<
int
>
&
lhs
)
const
;
virtual
expr_t
undiff
()
const
;
virtual
expr_t
decreaseLeadsLags
(
int
n
)
const
;
virtual
expr_t
substituteEndoLeadGreaterThanTwo
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
deterministic_model
)
const
;
virtual
expr_t
substituteEndoLagGreaterThanTwo
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
...
...
@@ -576,7 +580,7 @@ public:
virtual
expr_t
substituteExpectation
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
partial_information_model
)
const
;
virtual
expr_t
substituteAdl
()
const
;
virtual
void
findDiffNodes
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
map
<
int
,
int
>
&
undiff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
virtual
expr_t
substitutePacExpectation
(
map
<
const
PacExpectationNode
*
,
const
BinaryOpNode
*>
&
subst_table
);
virtual
expr_t
decreaseLeadsLagsPredeterminedVariables
()
const
;
virtual
expr_t
differentiateForwardVars
(
const
vector
<
string
>
&
subset
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
...
...
@@ -654,6 +658,7 @@ public:
virtual
int
maxLag
()
const
;
virtual
void
VarMaxLag
(
DataTree
&
static_datatree
,
set
<
expr_t
>
&
static_lhs
,
int
&
max_lag
)
const
;
virtual
int
PacMaxLag
(
vector
<
int
>
&
lhs
)
const
;
virtual
expr_t
undiff
()
const
;
virtual
expr_t
decreaseLeadsLags
(
int
n
)
const
;
virtual
expr_t
substituteEndoLeadGreaterThanTwo
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
deterministic_model
)
const
;
virtual
expr_t
substituteEndoLagGreaterThanTwo
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
...
...
@@ -662,7 +667,7 @@ public:
virtual
expr_t
substituteExpectation
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
partial_information_model
)
const
;
virtual
expr_t
substituteAdl
()
const
;
virtual
void
findDiffNodes
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
map
<
int
,
int
>
&
undiff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
virtual
expr_t
substitutePacExpectation
(
map
<
const
PacExpectationNode
*
,
const
BinaryOpNode
*>
&
subst_table
);
virtual
expr_t
decreaseLeadsLagsPredeterminedVariables
()
const
;
virtual
expr_t
differentiateForwardVars
(
const
vector
<
string
>
&
subset
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
...
...
@@ -760,6 +765,7 @@ public:
virtual
int
maxLag
()
const
;
virtual
void
VarMaxLag
(
DataTree
&
static_datatree
,
set
<
expr_t
>
&
static_lhs
,
int
&
max_lag
)
const
;
virtual
int
PacMaxLag
(
vector
<
int
>
&
lhs
)
const
;
virtual
expr_t
undiff
()
const
;
virtual
expr_t
decreaseLeadsLags
(
int
n
)
const
;
virtual
expr_t
substituteEndoLeadGreaterThanTwo
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
deterministic_model
)
const
;
//! Creates another UnaryOpNode with the same opcode, but with a possibly different datatree and argument
...
...
@@ -770,7 +776,7 @@ public:
virtual
expr_t
substituteExpectation
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
partial_information_model
)
const
;
virtual
expr_t
substituteAdl
()
const
;
virtual
void
findDiffNodes
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
map
<
int
,
int
>
&
undiff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
virtual
expr_t
substitutePacExpectation
(
map
<
const
PacExpectationNode
*
,
const
BinaryOpNode
*>
&
subst_table
);
virtual
expr_t
decreaseLeadsLagsPredeterminedVariables
()
const
;
virtual
expr_t
differentiateForwardVars
(
const
vector
<
string
>
&
subset
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
...
...
@@ -884,6 +890,7 @@ public:
virtual
int
maxLag
()
const
;
virtual
void
VarMaxLag
(
DataTree
&
static_datatree
,
set
<
expr_t
>
&
static_lhs
,
int
&
max_lag
)
const
;
virtual
int
PacMaxLag
(
vector
<
int
>
&
lhs
)
const
;
virtual
expr_t
undiff
()
const
;
virtual
expr_t
decreaseLeadsLags
(
int
n
)
const
;
virtual
expr_t
substituteEndoLeadGreaterThanTwo
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
deterministic_model
)
const
;
//! Creates another BinaryOpNode with the same opcode, but with a possibly different datatree and arguments
...
...
@@ -894,7 +901,7 @@ public:
virtual
expr_t
substituteExpectation
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
partial_information_model
)
const
;
virtual
expr_t
substituteAdl
()
const
;
virtual
void
findDiffNodes
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
map
<
int
,
int
>
&
undiff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
virtual
expr_t
substitutePacExpectation
(
map
<
const
PacExpectationNode
*
,
const
BinaryOpNode
*>
&
subst_table
);
virtual
expr_t
decreaseLeadsLagsPredeterminedVariables
()
const
;
virtual
expr_t
differentiateForwardVars
(
const
vector
<
string
>
&
subset
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
...
...
@@ -985,6 +992,7 @@ public:
virtual
int
maxLag
()
const
;
virtual
void
VarMaxLag
(
DataTree
&
static_datatree
,
set
<
expr_t
>
&
static_lhs
,
int
&
max_lag
)
const
;
virtual
int
PacMaxLag
(
vector
<
int
>
&
lhs
)
const
;
virtual
expr_t
undiff
()
const
;
virtual
expr_t
decreaseLeadsLags
(
int
n
)
const
;
virtual
expr_t
substituteEndoLeadGreaterThanTwo
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
deterministic_model
)
const
;
//! Creates another TrinaryOpNode with the same opcode, but with a possibly different datatree and arguments
...
...
@@ -995,7 +1003,7 @@ public:
virtual
expr_t
substituteExpectation
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
partial_information_model
)
const
;
virtual
expr_t
substituteAdl
()
const
;
virtual
void
findDiffNodes
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
map
<
int
,
int
>
&
undiff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
virtual
expr_t
substitutePacExpectation
(
map
<
const
PacExpectationNode
*
,
const
BinaryOpNode
*>
&
subst_table
);
virtual
expr_t
decreaseLeadsLagsPredeterminedVariables
()
const
;
virtual
expr_t
differentiateForwardVars
(
const
vector
<
string
>
&
subset
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
...
...
@@ -1088,6 +1096,7 @@ public:
virtual
int
maxLag
()
const
;
virtual
void
VarMaxLag
(
DataTree
&
static_datatree
,
set
<
expr_t
>
&
static_lhs
,
int
&
max_lag
)
const
;
virtual
int
PacMaxLag
(
vector
<
int
>
&
lhs
)
const
;
virtual
expr_t
undiff
()
const
;
virtual
expr_t
decreaseLeadsLags
(
int
n
)
const
;
virtual
expr_t
substituteEndoLeadGreaterThanTwo
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
deterministic_model
)
const
;
virtual
expr_t
substituteEndoLagGreaterThanTwo
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
...
...
@@ -1096,7 +1105,7 @@ public:
virtual
expr_t
substituteExpectation
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
partial_information_model
)
const
;
virtual
expr_t
substituteAdl
()
const
;
virtual
void
findDiffNodes
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
map
<
int
,
int
>
&
undiff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
virtual
expr_t
substitutePacExpectation
(
map
<
const
PacExpectationNode
*
,
const
BinaryOpNode
*>
&
subst_table
);
virtual
expr_t
buildSimilarExternalFunctionNode
(
vector
<
expr_t
>
&
alt_args
,
DataTree
&
alt_datatree
)
const
=
0
;
virtual
expr_t
decreaseLeadsLagsPredeterminedVariables
()
const
;
...
...
@@ -1273,6 +1282,7 @@ public:
virtual
int
maxLag
()
const
;
virtual
void
VarMaxLag
(
DataTree
&
static_datatree
,
set
<
expr_t
>
&
static_lhs
,
int
&
max_lag
)
const
;
virtual
int
PacMaxLag
(
vector
<
int
>
&
lhs
)
const
;
virtual
expr_t
undiff
()
const
;
virtual
expr_t
decreaseLeadsLags
(
int
n
)
const
;
virtual
void
prepareForDerivation
();
virtual
expr_t
computeDerivative
(
int
deriv_id
);
...
...
@@ -1287,7 +1297,7 @@ public:
virtual
expr_t
substituteExpectation
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
partial_information_model
)
const
;
virtual
expr_t
substituteAdl
()
const
;
virtual
void
findDiffNodes
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
map
<
int
,
int
>
&
undiff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
virtual
expr_t
substitutePacExpectation
(
map
<
const
PacExpectationNode
*
,
const
BinaryOpNode
*>
&
subst_table
);
virtual
pair
<
int
,
expr_t
>
normalizeEquation
(
int
symb_id_endo
,
vector
<
pair
<
int
,
pair
<
expr_t
,
expr_t
>
>
>
&
List_of_Op_RHS
)
const
;
virtual
void
compile
(
ostream
&
CompileCode
,
unsigned
int
&
instruction_number
,
...
...
@@ -1353,6 +1363,7 @@ public:
virtual
int
maxLag
()
const
;
virtual
void
VarMaxLag
(
DataTree
&
static_datatree
,
set
<
expr_t
>
&
static_lhs
,
int
&
max_lag
)
const
;
virtual
int
PacMaxLag
(
vector
<
int
>
&
lhs
)
const
;
virtual
expr_t
undiff
()
const
;
virtual
expr_t
decreaseLeadsLags
(
int
n
)
const
;
virtual
void
prepareForDerivation
();
virtual
expr_t
computeDerivative
(
int
deriv_id
);
...
...
@@ -1367,7 +1378,7 @@ public:
virtual
expr_t
substituteExpectation
(
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
bool
partial_information_model
)
const
;
virtual
expr_t
substituteAdl
()
const
;
virtual
void
findDiffNodes
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
,
map
<
int
,
int
>
&
undiff_table
)
const
;
virtual
expr_t
substituteDiff
(
DataTree
&
static_datatree
,
diff_table_t
&
diff_table
,
subst_table_t
&
subst_table
,
vector
<
BinaryOpNode
*>
&
neweqs
)
const
;
virtual
expr_t
substitutePacExpectation
(
map
<
const
PacExpectationNode
*
,
const
BinaryOpNode
*>
&
subst_table
);
virtual
pair
<
int
,
expr_t
>
normalizeEquation
(
int
symb_id_endo
,
vector
<
pair
<
int
,
pair
<
expr_t
,
expr_t
>
>
>
&
List_of_Op_RHS
)
const
;