Skip to content
GitLab
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
d6055c14
Commit
d6055c14
authored
Jul 17, 2018
by
Sébastien Villemot
Browse files
C++11: convert SymbolType to a class enum
parent
c12088f3
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
src/CodeInterpreter.hh
View file @
d6055c14
...
...
@@ -139,20 +139,20 @@ enum BlockSimulationType
//! Enumeration of possible symbol types
/*! Warning: do not to change existing values for 0 to 4: the values matter for homotopy_setup command */
enum
SymbolType
{
e
E
ndogenous
=
0
,
//!< Endogenous
e
E
xogenous
=
1
,
//!< Exogenous
e
E
xogenousDet
=
2
,
//!< Exogenous deterministic
eP
arameter
=
4
,
//!< Parameter
eM
odelLocalVariable
=
10
,
//!< Local variable whose scope is model (pound expression)
eM
odFileLocalVariable
=
11
,
//!< Local variable whose scope is mod file (model excluded)
e
E
xternalFunction
=
12
,
//!< External (user-defined) function
eT
rend
=
13
,
//!< Trend variable
eS
tatementDeclaredVariable
=
14
,
//!< Local variable assigned within a Statement (see subsample statement for example)
eL
ogTrend
=
15
,
//!< Log-trend variable
eU
nusedEndogenous
=
16
,
e
E
ndogenousVAR
=
17
//!< Variables declared in a var_model statement
enum
class
SymbolType
{
endogenous
=
0
,
//!< Endogenous
exogenous
=
1
,
//!< Exogenous
exogenousDet
=
2
,
//!< Exogenous deterministic
p
arameter
=
4
,
//!< Parameter
m
odelLocalVariable
=
10
,
//!< Local variable whose scope is model (pound expression)
m
odFileLocalVariable
=
11
,
//!< Local variable whose scope is mod file (model excluded)
externalFunction
=
12
,
//!< External (user-defined) function
t
rend
=
13
,
//!< Trend variable
s
tatementDeclaredVariable
=
14
,
//!< Local variable assigned within a Statement (see subsample statement for example)
l
ogTrend
=
15
,
//!< Log-trend variable
u
nusedEndogenous
=
16
,
endogenousVAR
=
17
//!< Variables declared in a var_model statement
};
enum
ExpressionType
...
...
src/ComputingTasks.cc
View file @
d6055c14
...
...
@@ -298,13 +298,13 @@ PacModelStatement::writeOutput(ostream &output, const string &basename, bool min
<<
"M_.pac."
<<
name
<<
".growth_type = "
;
switch
(
symbol_table
.
getType
(
growth
))
{
case
e
E
ndogenous
:
case
SymbolType
::
endogenous
:
output
<<
"'endogenous';"
<<
endl
;
break
;
case
e
E
xogenous
:
case
SymbolType
::
exogenous
:
output
<<
"'exogenous';"
<<
endl
;
break
;
case
eP
arameter
:
case
SymbolType
::
p
arameter
:
output
<<
"'parameter';"
<<
endl
;
break
;
default:
...
...
@@ -354,13 +354,13 @@ PacModelStatement::writeJsonOutput(ostream &output) const
<<
"
\"
growth_type
\"
: "
;
switch
(
symbol_table
.
getType
(
growth
))
{
case
e
E
ndogenous
:
case
SymbolType
::
endogenous
:
output
<<
"
\"
endogenous
\"
"
<<
endl
;
break
;
case
e
E
xogenous
:
case
SymbolType
::
exogenous
:
output
<<
"
\"
exogenous
\"
"
<<
endl
;
break
;
case
eP
arameter
:
case
SymbolType
::
p
arameter
:
output
<<
"
\"
parameter
\"
"
<<
endl
;
break
;
default:
...
...
@@ -1060,7 +1060,7 @@ RamseyPolicyStatement::checkRamseyPolicyList()
cerr
<<
"ERROR: ramsey_policy: "
<<
it
<<
" was not declared."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
if
(
symbol_table
.
getType
(
it
)
!=
e
E
ndogenous
)
if
(
symbol_table
.
getType
(
it
)
!=
SymbolType
::
endogenous
)
{
cerr
<<
"ERROR: ramsey_policy: "
<<
it
<<
" is not endogenous."
<<
endl
;
exit
(
EXIT_FAILURE
);
...
...
@@ -1528,9 +1528,9 @@ EstimatedParamsStatement::writeOutput(ostream &output, const string &basename, b
switch
(
it
.
type
)
{
case
1
:
if
(
symb_type
==
e
E
xogenous
)
if
(
symb_type
==
SymbolType
::
exogenous
)
output
<<
"estim_params_.var_exo = [estim_params_.var_exo; "
;
else
if
(
symb_type
==
e
E
ndogenous
)
else
if
(
symb_type
==
SymbolType
::
endogenous
)
output
<<
"estim_params_.var_endo = [estim_params_.var_endo; "
;
output
<<
symb_id
;
break
;
...
...
@@ -1539,9 +1539,9 @@ EstimatedParamsStatement::writeOutput(ostream &output, const string &basename, b
<<
symb_id
;
break
;
case
3
:
if
(
symb_type
==
e
E
xogenous
)
if
(
symb_type
==
SymbolType
::
exogenous
)
output
<<
"estim_params_.corrx = [estim_params_.corrx; "
;
else
if
(
symb_type
==
e
E
ndogenous
)
else
if
(
symb_type
==
SymbolType
::
endogenous
)
output
<<
"estim_params_.corrn = [estim_params_.corrn; "
;
output
<<
symb_id
<<
" "
<<
symbol_table
.
getTypeSpecificID
(
it
.
name2
)
+
1
;
break
;
...
...
@@ -1644,21 +1644,21 @@ EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basenam
if
(
it
.
type
<
3
)
{
if
(
symb_type
==
e
E
xogenous
)
if
(
symb_type
==
SymbolType
::
exogenous
)
{
output
<<
"tmp1 = find(estim_params_.var_exo(:,1)=="
<<
symb_id
<<
");"
<<
endl
;
output
<<
"estim_params_.var_exo(tmp1,2) = "
;
it
.
init_val
->
writeOutput
(
output
);
output
<<
";"
<<
endl
;
}
else
if
(
symb_type
==
e
E
ndogenous
)
else
if
(
symb_type
==
SymbolType
::
endogenous
)
{
output
<<
"tmp1 = find(estim_params_.var_endo(:,1)=="
<<
symb_id
<<
");"
<<
endl
;
output
<<
"estim_params_.var_endo(tmp1,2) = "
;
it
.
init_val
->
writeOutput
(
output
);
output
<<
";"
<<
endl
;
}
else
if
(
symb_type
==
eP
arameter
)
else
if
(
symb_type
==
SymbolType
::
p
arameter
)
{
output
<<
"tmp1 = find(estim_params_.param_vals(:,1)=="
<<
symb_id
<<
");"
<<
endl
;
output
<<
"estim_params_.param_vals(tmp1,2) = "
;
...
...
@@ -1668,7 +1668,7 @@ EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basenam
}
else
{
if
(
symb_type
==
e
E
xogenous
)
if
(
symb_type
==
SymbolType
::
exogenous
)
{
output
<<
"tmp1 = find((estim_params_.corrx(:,1)=="
<<
symb_id
<<
" & estim_params_.corrx(:,2)=="
<<
symbol_table
.
getTypeSpecificID
(
it
.
name2
)
+
1
<<
") | "
<<
"(estim_params_.corrx(:,2)=="
<<
symb_id
<<
" & estim_params_.corrx(:,1)=="
<<
symbol_table
.
getTypeSpecificID
(
it
.
name2
)
+
1
<<
"));"
<<
endl
;
...
...
@@ -1676,7 +1676,7 @@ EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basenam
it
.
init_val
->
writeOutput
(
output
);
output
<<
";"
<<
endl
;
}
else
if
(
symb_type
==
e
E
ndogenous
)
else
if
(
symb_type
==
SymbolType
::
endogenous
)
{
output
<<
"tmp1 = find((estim_params_.corrn(:,1)=="
<<
symb_id
<<
" & estim_params_.corrn(:,2)=="
<<
symbol_table
.
getTypeSpecificID
(
it
.
name2
)
+
1
<<
") | "
<<
"(estim_params_.corrn(:,2)=="
<<
symb_id
<<
" & estim_params_.corrn(:,1)=="
<<
symbol_table
.
getTypeSpecificID
(
it
.
name2
)
+
1
<<
"));"
<<
endl
;
...
...
@@ -1740,7 +1740,7 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
if
(
it
.
type
<
3
)
{
if
(
symb_type
==
e
E
xogenous
)
if
(
symb_type
==
SymbolType
::
exogenous
)
{
output
<<
"tmp1 = find(estim_params_.var_exo(:,1)=="
<<
symb_id
<<
");"
<<
endl
;
...
...
@@ -1752,7 +1752,7 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
it
.
up_bound
->
writeOutput
(
output
);
output
<<
";"
<<
endl
;
}
else
if
(
symb_type
==
e
E
ndogenous
)
else
if
(
symb_type
==
SymbolType
::
endogenous
)
{
output
<<
"tmp1 = find(estim_params_.var_endo(:,1)=="
<<
symb_id
<<
");"
<<
endl
;
...
...
@@ -1764,7 +1764,7 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
it
.
up_bound
->
writeOutput
(
output
);
output
<<
";"
<<
endl
;
}
else
if
(
symb_type
==
eP
arameter
)
else
if
(
symb_type
==
SymbolType
::
p
arameter
)
{
output
<<
"tmp1 = find(estim_params_.param_vals(:,1)=="
<<
symb_id
<<
");"
<<
endl
;
...
...
@@ -1779,7 +1779,7 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
}
else
{
if
(
symb_type
==
e
E
xogenous
)
if
(
symb_type
==
SymbolType
::
exogenous
)
{
output
<<
"tmp1 = find((estim_params_.corrx(:,1)=="
<<
symb_id
<<
" & estim_params_.corrx(:,2)=="
<<
symbol_table
.
getTypeSpecificID
(
it
.
name2
)
+
1
<<
") | "
<<
"(estim_params_.corrx(:,2)=="
<<
symb_id
<<
" & estim_params_.corrx(:,1)=="
<<
symbol_table
.
getTypeSpecificID
(
it
.
name2
)
+
1
<<
"));"
<<
endl
;
...
...
@@ -1792,7 +1792,7 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
it
.
up_bound
->
writeOutput
(
output
);
output
<<
";"
<<
endl
;
}
else
if
(
symb_type
==
e
E
ndogenous
)
else
if
(
symb_type
==
SymbolType
::
endogenous
)
{
output
<<
"tmp1 = find((estim_params_.corrn(:,1)=="
<<
symb_id
<<
" & estim_params_.corrn(:,2)=="
<<
symbol_table
.
getTypeSpecificID
(
it
.
name2
)
+
1
<<
") | "
<<
"(estim_params_.corrn(:,2)=="
<<
symb_id
<<
" & estim_params_.corrn(:,1)=="
<<
symbol_table
.
getTypeSpecificID
(
it
.
name2
)
+
1
<<
"));"
<<
endl
;
...
...
@@ -1856,7 +1856,7 @@ ObservationTrendsStatement::writeOutput(ostream &output, const string &basename,
for
(
const
auto
&
trend_element
:
trend_elements
)
{
SymbolType
type
=
symbol_table
.
getType
(
trend_element
.
first
);
if
(
type
==
e
E
ndogenous
)
if
(
type
==
SymbolType
::
endogenous
)
{
output
<<
"tmp1 = strmatch('"
<<
trend_element
.
first
<<
"',options_.varobs,'exact');"
<<
endl
;
output
<<
"options_.trend_coeffs{tmp1} = '"
;
...
...
@@ -1876,7 +1876,7 @@ ObservationTrendsStatement::writeJsonOutput(ostream &output) const
bool
printed
=
false
;
for
(
const
auto
&
trend_element
:
trend_elements
)
{
if
(
symbol_table
.
getType
(
trend_element
.
first
)
==
e
E
ndogenous
)
if
(
symbol_table
.
getType
(
trend_element
.
first
)
==
SymbolType
::
endogenous
)
{
if
(
printed
)
output
<<
", "
;
...
...
@@ -3562,9 +3562,9 @@ SubsamplesStatement::writeOutput(ostream &output, const string &basename, bool m
// Initialize associated subsample substructures in estimation_info
const
SymbolType
symb_type
=
symbol_table
.
getType
(
name1
);
string
lhs_field
;
if
(
symb_type
==
eP
arameter
)
if
(
symb_type
==
SymbolType
::
p
arameter
)
lhs_field
=
"parameter"
;
else
if
(
symb_type
==
e
E
xogenous
||
symb_type
==
e
E
xogenousDet
)
else
if
(
symb_type
==
SymbolType
::
exogenous
||
symb_type
==
SymbolType
::
exogenousDet
)
lhs_field
=
"structural_innovation"
;
else
lhs_field
=
"measurement_error"
;
...
...
@@ -3648,9 +3648,9 @@ SubsamplesEqualStatement::writeOutput(ostream &output, const string &basename, b
// Initialize associated subsample substructures in estimation_info
const
SymbolType
symb_type
=
symbol_table
.
getType
(
to_name1
);
string
lhs_field
;
if
(
symb_type
==
eP
arameter
)
if
(
symb_type
==
SymbolType
::
p
arameter
)
lhs_field
=
"parameter"
;
else
if
(
symb_type
==
e
E
xogenous
||
symb_type
==
e
E
xogenousDet
)
else
if
(
symb_type
==
SymbolType
::
exogenous
||
symb_type
==
SymbolType
::
exogenousDet
)
lhs_field
=
"structural_innovation"
;
else
lhs_field
=
"measurement_error"
;
...
...
@@ -3909,7 +3909,7 @@ BasicPriorStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
bool
BasicPriorStatement
::
is_structural_innovation
(
const
SymbolType
symb_type
)
const
{
if
(
symb_type
==
e
E
xogenous
||
symb_type
==
e
E
xogenousDet
)
if
(
symb_type
==
SymbolType
::
exogenous
||
symb_type
==
SymbolType
::
exogenousDet
)
return
true
;
return
false
;
}
...
...
@@ -3917,7 +3917,7 @@ BasicPriorStatement::is_structural_innovation(const SymbolType symb_type) const
void
BasicPriorStatement
::
get_base_name
(
const
SymbolType
symb_type
,
string
&
lhs_field
)
const
{
if
(
symb_type
==
e
E
xogenous
||
symb_type
==
e
E
xogenousDet
)
if
(
symb_type
==
SymbolType
::
exogenous
||
symb_type
==
SymbolType
::
exogenousDet
)
lhs_field
=
"structural_innovation"
;
else
lhs_field
=
"measurement_error"
;
...
...
@@ -4314,7 +4314,7 @@ PriorEqualStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
void
PriorEqualStatement
::
get_base_name
(
const
SymbolType
symb_type
,
string
&
lhs_field
)
const
{
if
(
symb_type
==
e
E
xogenous
||
symb_type
==
e
E
xogenousDet
)
if
(
symb_type
==
SymbolType
::
exogenous
||
symb_type
==
SymbolType
::
exogenousDet
)
lhs_field
=
"structural_innovation"
;
else
lhs_field
=
"measurement_error"
;
...
...
@@ -4416,7 +4416,7 @@ BasicOptionsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso
bool
BasicOptionsStatement
::
is_structural_innovation
(
const
SymbolType
symb_type
)
const
{
if
(
symb_type
==
e
E
xogenous
||
symb_type
==
e
E
xogenousDet
)
if
(
symb_type
==
SymbolType
::
exogenous
||
symb_type
==
SymbolType
::
exogenousDet
)
return
true
;
return
false
;
}
...
...
@@ -4424,7 +4424,7 @@ BasicOptionsStatement::is_structural_innovation(const SymbolType symb_type) cons
void
BasicOptionsStatement
::
get_base_name
(
const
SymbolType
symb_type
,
string
&
lhs_field
)
const
{
if
(
symb_type
==
e
E
xogenous
||
symb_type
==
e
E
xogenousDet
)
if
(
symb_type
==
SymbolType
::
exogenous
||
symb_type
==
SymbolType
::
exogenousDet
)
lhs_field
=
"structural_innovation"
;
else
lhs_field
=
"measurement_error"
;
...
...
@@ -4692,7 +4692,7 @@ OptionsEqualStatement::writeJsonOutput(ostream &output) const
void
OptionsEqualStatement
::
get_base_name
(
const
SymbolType
symb_type
,
string
&
lhs_field
)
const
{
if
(
symb_type
==
e
E
xogenous
||
symb_type
==
e
E
xogenousDet
)
if
(
symb_type
==
SymbolType
::
exogenous
||
symb_type
==
SymbolType
::
exogenousDet
)
lhs_field
=
"structural_innovation"
;
else
lhs_field
=
"measurement_error"
;
...
...
src/DataTree.cc
View file @
d6055c14
...
...
@@ -79,7 +79,7 @@ bool
DataTree
::
ParamUsedWithLeadLagInternal
()
const
{
for
(
const
auto
&
it
:
variable_node_map
)
if
(
symbol_table
.
getType
(
it
.
first
.
first
)
==
eP
arameter
&&
it
.
first
.
second
!=
0
)
if
(
symbol_table
.
getType
(
it
.
first
.
first
)
==
SymbolType
::
p
arameter
&&
it
.
first
.
second
!=
0
)
return
true
;
return
false
;
}
...
...
@@ -507,7 +507,7 @@ DataTree::AddExpectation(int iArg1, expr_t iArg2)
expr_t
DataTree
::
AddVarExpectation
(
const
int
symb_id
,
const
int
forecast_horizon
,
const
string
&
model_name
)
{
assert
(
symbol_table
.
getType
(
symb_id
)
==
e
E
ndogenous
);
assert
(
symbol_table
.
getType
(
symb_id
)
==
SymbolType
::
endogenous
);
auto
it
=
var_expectation_node_map
.
find
({
model_name
,
symb_id
,
forecast_horizon
});
if
(
it
!=
var_expectation_node_map
.
end
())
...
...
@@ -535,7 +535,7 @@ DataTree::AddEqual(expr_t iArg1, expr_t iArg2)
void
DataTree
::
AddLocalVariable
(
int
symb_id
,
expr_t
value
)
noexcept
(
false
)
{
assert
(
symbol_table
.
getType
(
symb_id
)
==
eM
odelLocalVariable
);
assert
(
symbol_table
.
getType
(
symb_id
)
==
SymbolType
::
m
odelLocalVariable
);
// Throw an exception if symbol already declared
auto
it
=
local_variables_table
.
find
(
symb_id
);
...
...
@@ -549,7 +549,7 @@ DataTree::AddLocalVariable(int symb_id, expr_t value) noexcept(false)
expr_t
DataTree
::
AddExternalFunction
(
int
symb_id
,
const
vector
<
expr_t
>
&
arguments
)
{
assert
(
symbol_table
.
getType
(
symb_id
)
==
e
E
xternalFunction
);
assert
(
symbol_table
.
getType
(
symb_id
)
==
SymbolType
::
externalFunction
);
auto
it
=
external_function_node_map
.
find
({
arguments
,
symb_id
});
if
(
it
!=
external_function_node_map
.
end
())
...
...
@@ -561,7 +561,7 @@ DataTree::AddExternalFunction(int symb_id, const vector<expr_t> &arguments)
expr_t
DataTree
::
AddFirstDerivExternalFunction
(
int
top_level_symb_id
,
const
vector
<
expr_t
>
&
arguments
,
int
input_index
)
{
assert
(
symbol_table
.
getType
(
top_level_symb_id
)
==
e
E
xternalFunction
);
assert
(
symbol_table
.
getType
(
top_level_symb_id
)
==
SymbolType
::
externalFunction
);
auto
it
=
first_deriv_external_function_node_map
.
find
({
arguments
,
input_index
,
top_level_symb_id
});
...
...
@@ -574,7 +574,7 @@ DataTree::AddFirstDerivExternalFunction(int top_level_symb_id, const vector<expr
expr_t
DataTree
::
AddSecondDerivExternalFunction
(
int
top_level_symb_id
,
const
vector
<
expr_t
>
&
arguments
,
int
input_index1
,
int
input_index2
)
{
assert
(
symbol_table
.
getType
(
top_level_symb_id
)
==
e
E
xternalFunction
);
assert
(
symbol_table
.
getType
(
top_level_symb_id
)
==
SymbolType
::
externalFunction
);
auto
it
=
second_deriv_external_function_node_map
.
find
({
arguments
,
input_index1
,
input_index2
,
...
...
src/DynamicModel.cc
View file @
d6055c14
This diff is collapsed.
Click to expand it.
src/DynareBison.yy
View file @
d6055c14
...
...
@@ -688,13 +688,13 @@ change_type : CHANGE_TYPE '(' change_type_arg ')' change_type_var_list ';'
;
change_type_arg : PARAMETERS
{ $$ =
eP
arameter; }
{ $$ =
SymbolType::p
arameter; }
| VAR
{ $$ = e
E
ndogenous; }
{ $$ =
SymbolType::
endogenous; }
| VAREXO
{ $$ = e
E
xogenous; }
{ $$ =
SymbolType::
exogenous; }
| VAREXO_DET
{ $$ = e
E
xogenousDet; }
{ $$ =
SymbolType::
exogenousDet; }
;
change_type_var_list : symbol
...
...
@@ -894,11 +894,11 @@ hand_side : '(' hand_side ')'
| symbol
{ $$ = driver.add_model_variable($1); }
| symbol PIPE_E
{ $$ = driver.declare_or_change_type(e
E
ndogenous, $1); }
{ $$ = driver.declare_or_change_type(
SymbolType::
endogenous, $1); }
| symbol PIPE_X
{ $$ = driver.declare_or_change_type(e
E
xogenous, $1); }
{ $$ = driver.declare_or_change_type(
SymbolType::
exogenous, $1); }
| symbol PIPE_P
{ $$ = driver.declare_or_change_type(
eP
arameter, $1); }
{ $$ = driver.declare_or_change_type(
SymbolType::p
arameter, $1); }
| non_negative_number
{ $$ = driver.add_non_negative_constant($1); }
| hand_side PLUS hand_side
...
...
src/ExprNode.cc
View file @
d6055c14
This diff is collapsed.
Click to expand it.
src/ModFile.cc
View file @
d6055c14
...
...
@@ -83,8 +83,8 @@ ModFile::evalAllExpressions(bool warn_uninit, const bool nopreprocessoroutput)
for
(
int
id
=
0
;
id
<=
symbol_table
.
maxID
();
id
++
)
{
SymbolType
type
=
symbol_table
.
getType
(
id
);
if
((
type
==
e
E
ndogenous
||
type
==
e
E
xogenous
||
type
==
e
E
xogenousDet
||
type
==
eP
arameter
||
type
==
eM
odelLocalVariable
)
if
((
type
==
SymbolType
::
endogenous
||
type
==
SymbolType
::
exogenous
||
type
==
SymbolType
::
exogenousDet
||
type
==
SymbolType
::
p
arameter
||
type
==
SymbolType
::
m
odelLocalVariable
)
&&
global_eval_context
.
find
(
id
)
==
global_eval_context
.
end
())
{
if
(
warn_uninit
)
...
...
@@ -214,7 +214,7 @@ ModFile::checkPass(bool nostrict, bool stochastic)
if
(
symbol_table
.
exists
(
"dsge_prior_weight"
))
{
if
(
symbol_table
.
getType
(
"dsge_prior_weight"
)
!=
eP
arameter
)
if
(
symbol_table
.
getType
(
"dsge_prior_weight"
)
!=
SymbolType
::
p
arameter
)
{
cerr
<<
"ERROR: dsge_prior_weight may only be used as a parameter."
<<
endl
;
exit
(
EXIT_FAILURE
);
...
...
@@ -357,7 +357,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
set
<
int
>
unusedEndogs
=
dynamic_model
.
findUnusedEndogenous
();
for
(
int
unusedEndog
:
unusedEndogs
)
{
symbol_table
.
changeType
(
unusedEndog
,
eU
nusedEndogenous
);
symbol_table
.
changeType
(
unusedEndog
,
SymbolType
::
u
nusedEndogenous
);
warnings
<<
"WARNING: '"
<<
symbol_table
.
getName
(
unusedEndog
)
<<
"' not used in model block, removed by nostrict command-line option"
<<
endl
;
}
...
...
@@ -554,7 +554,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
if
(
mod_file_struct
.
dsge_var_estimated
||
!
mod_file_struct
.
dsge_var_calibrated
.
empty
())
try
{
int
sid
=
symbol_table
.
addSymbol
(
"dsge_prior_weight"
,
eP
arameter
);
int
sid
=
symbol_table
.
addSymbol
(
"dsge_prior_weight"
,
SymbolType
::
p
arameter
);
if
(
!
mod_file_struct
.
dsge_var_calibrated
.
empty
())
addStatementAtFront
(
new
InitParamStatement
(
sid
,
expressions_tree
.
AddNonNegativeConstant
(
mod_file_struct
.
dsge_var_calibrated
),
...
...
src/ModelTree.cc
View file @
d6055c14
...
...
@@ -128,7 +128,7 @@ ModelTree::computeNormalization(const jacob_map_t &contemporaneous_jacobian, boo
{
if
(
verbose
)
cerr
<<
"ERROR: Could not normalize the model. Variable "
<<
symbol_table
.
getName
(
symbol_table
.
getID
(
e
E
ndogenous
,
it
-
mate_map
.
begin
()))
<<
symbol_table
.
getName
(
symbol_table
.
getID
(
SymbolType
::
endogenous
,
it
-
mate_map
.
begin
()))
<<
" is not in the maximum cardinality matching."
<<
endl
;
check
=
false
;
}
...
...
@@ -208,12 +208,12 @@ ModelTree::computeNonSingularNormalization(jacob_map_t &contemporaneous_jacobian
contemporaneous_jacobian
[{
it
->
first
.
first
,
it
->
first
.
second
}]
=
0
;
try
{
if
(
first_derivatives
.
find
({
it
->
first
.
first
,
getDerivID
(
symbol_table
.
getID
(
e
E
ndogenous
,
it
->
first
.
second
),
0
)
})
==
first_derivatives
.
end
())
first_derivatives
[{
it
->
first
.
first
,
getDerivID
(
symbol_table
.
getID
(
e
E
ndogenous
,
it
->
first
.
second
),
0
)
}]
=
Zero
;
if
(
first_derivatives
.
find
({
it
->
first
.
first
,
getDerivID
(
symbol_table
.
getID
(
SymbolType
::
endogenous
,
it
->
first
.
second
),
0
)
})
==
first_derivatives
.
end
())
first_derivatives
[{
it
->
first
.
first
,
getDerivID
(
symbol_table
.
getID
(
SymbolType
::
endogenous
,
it
->
first
.
second
),
0
)
}]
=
Zero
;
}
catch
(
DataTree
::
UnknownDerivIDException
&
e
)
{
cerr
<<
"The variable "
<<
symbol_table
.
getName
(
symbol_table
.
getID
(
e
E
ndogenous
,
it
->
first
.
second
))
cerr
<<
"The variable "
<<
symbol_table
.
getName
(
symbol_table
.
getID
(
SymbolType
::
endogenous
,
it
->
first
.
second
))
<<
" does not appear at the current period (i.e. with no lead and no lag); this case is not handled by the 'block' option of the 'model' block."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
...
...
@@ -238,7 +238,7 @@ ModelTree::computeNormalizedEquations(multimap<int, int> &endo2eqs) const
continue
;
int
symb_id
=
lhs
->
get_symb_id
();
if
(
symbol_table
.
getType
(
symb_id
)
!=
e
E
ndogenous
)
if
(
symbol_table
.
getType
(
symb_id
)
!=
SymbolType
::
endogenous
)
continue
;
set
<
pair
<
int
,
int
>>
endo
;
...
...
@@ -260,7 +260,7 @@ ModelTree::evaluateAndReduceJacobian(const eval_context_t &eval_context, jacob_m
it
!=
first_derivatives
.
end
();
it
++
)
{
int
deriv_id
=
it
->
first
.
second
;
if
(
getTypeByDerivID
(
deriv_id
)
==
e
E
ndogenous
)
if
(
getTypeByDerivID
(
deriv_id
)
==
SymbolType
::
endogenous
)
{
expr_t
Id
=
it
->
second
;
int
eq
=
it
->
first
.
first
;
...
...
@@ -457,7 +457,7 @@ ModelTree::equationTypeDetermination(const map<pair<int, pair<int, int>>, expr_t
derivative
->
second
->
collectEndogenous
(
result
);
auto
d_endo_variable
=
result
.
find
({
var
,
0
});
//Determine whether the equation could be evaluated rather than to be solved
if
(
lhs
->
isVariableNodeEqualTo
(
e
E
ndogenous
,
Index_Var_IM
[
i
],
0
)
&&
derivative
->
second
->
isNumConstNodeEqualTo
(
1
))
if
(
lhs
->
isVariableNodeEqualTo
(
SymbolType
::
endogenous
,
Index_Var_IM
[
i
],
0
)
&&
derivative
->
second
->
isNumConstNodeEqualTo
(
1
))
{
Equation_Simulation_Type
=
E_EVALUATE
;
}
...
...
@@ -1120,7 +1120,7 @@ ModelTree::computeTemporaryTerms(bool is_matlab)
// All used model local variables are automatically set as temporary variables
set
<
int
>
used_local_vars
;
for
(
auto
&
equation
:
equations
)
equation
->
collectVariables
(
eM
odelLocalVariable
,
used_local_vars
);
equation
->
collectVariables
(
SymbolType
::
m
odelLocalVariable
,
used_local_vars
);
for
(
int
used_local_var
:
used_local_vars
)
{
...
...
@@ -1459,7 +1459,7 @@ ModelTree::writeJsonModelLocalVariables(ostream &output, deriv_node_temp_terms_t
const
temporary_terms_t
tt
;
for
(
auto
equation
:
equations
)
equation
->
collectVariables
(
eM
odelLocalVariable
,
used_local_vars
);
equation
->
collectVariables
(
SymbolType
::
m
odelLocalVariable
,
used_local_vars
);
output
<<
"
\"
model_local_variables
\"
: ["
;
bool
printed
=
false
;
...
...
@@ -1621,7 +1621,7 @@ ModelTree::Write_Inf_To_Bin_File(const string &filename,
for
(
const
auto
&
first_derivative
:
first_derivatives
)
{
int
deriv_id
=
first_derivative
.
first
.
second
;
if
(
getTypeByDerivID
(
deriv_id
)
==
e
E
ndogenous
)
if
(
getTypeByDerivID
(
deriv_id
)
==
SymbolType
::
endogenous
)
{
int
eq
=
first_derivative
.
first
.
first
;
int
symb
=
getSymbIDByDerivID
(
deriv_id
);
...
...
src/NumericalInitialization.cc
View file @
d6055c14
...
...
@@ -127,9 +127,9 @@ InitOrEndValStatement::getUninitializedVariables(SymbolType type)
if
(
!
all_values_required
)
return
unused
;
if
(
type
==
e
E
ndogenous
)
if
(
type
==
SymbolType
::
endogenous
)
unused
=
symbol_table
.
getEndogenous
();
else
if
(
type
==
e
E
xogenous
)
else
if
(
type
==
SymbolType
::
exogenous
)
unused
=
symbol_table
.
getExogenous
();
else
{
...
...
@@ -158,11 +158,11 @@ InitOrEndValStatement::writeInitValues(ostream &output) const
SymbolType
type
=
symbol_table
.
getType
(
symb_id
);
int
tsid
=
symbol_table
.
getTypeSpecificID
(
symb_id
)
+
1
;
if
(
type
==
e
E
ndogenous
)
if
(
type
==
SymbolType
::
endogenous
)
output
<<
"oo_.steady_state"
;
else
if
(
type
==
e
E
xogenous
)
else
if
(
type
==
SymbolType
::
exogenous
)
output
<<
"oo_.exo_steady_state"
;
else
if
(
type
==
e
E
xogenousDet
)
else
if
(
type
==
SymbolType
::
exogenousDet
)
output
<<
"oo_.exo_det_steady_state"
;
output
<<
"( "
<<
tsid
<<
" ) = "
;
...
...
@@ -195,8 +195,8 @@ InitValStatement::InitValStatement(const init_values_t &init_values_arg,
void
InitValStatement
::
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
)
{
set
<
int
>
exogs
=
getUninitializedVariables
(
e
E
xogenous
);
set
<
int
>
endogs
=
getUninitializedVariables
(
e
E
ndogenous
);
set
<
int
>
exogs
=
getUninitializedVariables
(
SymbolType
::
exogenous
);
set
<
int
>
endogs
=
getUninitializedVariables
(
SymbolType
::
endogenous
);
if
(
endogs
.
size
()
>
0
)
{
...
...
@@ -259,8 +259,8 @@ EndValStatement::EndValStatement(const init_values_t &init_values_arg,
void
EndValStatement
::
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
)
{
set
<
int
>
exogs
=
getUninitializedVariables
(
e
E
xogenous
);
set
<
int
>
endogs
=
getUninitializedVariables
(
e
E
ndogenous
);
set
<
int
>
exogs
=
getUninitializedVariables
(
SymbolType
::
exogenous
);
set
<
int
>
endogs
=
getUninitializedVariables
(
SymbolType
::
endogenous
);
if
(
endogs
.
size
()
>
0
)
{
...
...
@@ -375,18 +375,18 @@ HistValStatement::writeOutput(ostream &output, const string &basename, bool mini
SymbolType
type
=
symbol_table
.
getType
(
symb_id
);
// For a lag greater than 1 on endo, or for any exo, lookup for auxiliary variable
if
((
type
==
e
E
ndogenous
&&
lag
<
0
)
||
type
==
e
E
xogenous
)
if
((
type
==
SymbolType
::
endogenous
&&
lag
<
0
)
||
type
==
SymbolType
::
exogenous
)
{
try
{
// This function call must remain the 1st statement in this block
symb_id
=
symbol_table
.
searchAuxiliaryVars
(
symb_id
,
lag
);
lag
=
0
;
type
=
e
E
ndogenous
;
type
=
SymbolType
::
endogenous
;
}
catch
(
SymbolTable
::
SearchFailedException
&
e
)
{
if
(
type
==
e
E
ndogenous
)
if
(
type
==
SymbolType
::
endogenous
)
{
cerr
<<
"HISTVAL: internal error of Dynare, please contact the developers"
;
exit
(
EXIT_FAILURE
);
...
...
@@ -398,11 +398,11 @@ HistValStatement::writeOutput(ostream &output, const string &basename, bool mini
int
tsid
=
symbol_table
.
getTypeSpecificID
(
symb_id
)
+
1
;
if
(
type
==
e
E
ndogenous
)
if
(
type
==
SymbolType
::
endogenous
)
output
<<
"M_.endo_histval( "
<<
tsid
<<
", M_.maximum_lag + "
<<
lag
<<
") = "
;
else
if
(
type
==
e
E
xogenous
)
else
if
(
type
==
SymbolType
::
exogenous
)
output
<<
"M_.exo_histval( "
<<
tsid
<<
", M_.maximum_lag + "
<<
lag
<<
") = "
;
else
if
(
type
==
e
E
xogenousDet
)
else
if
(
type
==
SymbolType
::
exogenousDet
)
output
<<
"M_.exo_det_histval( "
<<
tsid
<<
", M_.maximum_lag + "
<<
lag
<<
") = "
;
expression
->
writeOutput
(
output
);
...
...
@@ -494,7 +494,7 @@ HomotopyStatement::writeOutput(ostream &output, const string &basename, bool min
const
SymbolType
type
=
symbol_table
.
getType
(
symb_id
);
const
int
tsid
=
symbol_table
.
getTypeSpecificID
(
symb_id
)
+
1
;
output
<<
"options_.homotopy_values = vertcat(options_.homotopy_values, [ "
<<
type
<<
", "
<<
tsid
<<
", "
;
output
<<
"options_.homotopy_values = vertcat(options_.homotopy_values, [ "
<<
static_cast
<
int
>
(
type
)
<<
", "
<<
tsid
<<
", "
;
if
(
expression1
!=
nullptr
)
expression1
->
writeOutput
(
output
);
else
...
...
@@ -590,16 +590,16 @@ LoadParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba
{
switch
(
symbol_table
.
getType
(
it
.
first
))
{
case
eP
arameter
:
case
SymbolType
::
p
arameter
:
output
<<
"M_.params"
;
break
;
case
e
E
ndogenous
:
case
SymbolType
::
endogenous
:
output
<<
"oo_.steady_state"
;
break
;
case
e
E
xogenous
:
case
SymbolType
::
exogenous
:
output
<<
"oo_.exo_steady_state"
;
break
;
case
e
E
xogenousDet
:
case
SymbolType
::
exogenousDet
:
output
<<
"oo_.exo_det_steady_state"
;
break
;
default:
...
...
src/ParsingDriver.cc
View file @
d6055c14
This diff is collapsed.
Click to expand it.
src/Shocks.cc
View file @
d6055c14
...
...
@@ -43,7 +43,7 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
for
(
const
auto
&
det_shock
:
det_shocks
)
{
int
id
=
symbol_table
.
getTypeSpecificID
(
det_shock
.
first
)
+
1
;
bool
exo_det
=
(
symbol_table
.
getType
(
det_shock
.
first
)
==
e
E
xogenousDet
);
bool
exo_det
=
(
symbol_table
.
getType
(
det_shock
.
first
)
==
SymbolType
::