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
3509291b
Verified
Commit
3509291b
authored
May 20, 2019
by
Houtan Bastani
Browse files
pac_model: only write growth fields if growth was passed to pac_model
parent
2753ab98
Pipeline
#1262
passed with stage
in 1 minute and 25 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/ComputingTasks.cc
View file @
3509291b
...
...
@@ -315,70 +315,73 @@ PacModelStatement::writeOutput(ostream &output, const string &basename, bool min
output
<<
"M_.pac."
<<
name
<<
".steady_state_growth_rate = "
<<
symbol_table
.
getTypeSpecificID
(
steady_state_growth_rate_symb_id
)
+
1
<<
";"
<<
endl
;
size_t
nlc
=
growth_info
.
size
();
output
<<
"M_.pac."
<<
name
<<
".growth_index = repmat(-1, "
<<
nlc
<<
", 1);"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_lag = zeros("
<<
nlc
<<
", 1);"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_param_id = repmat(-1, "
<<
nlc
<<
", 1);"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_constant = zeros("
<<
nlc
<<
", 1);"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_type = repmat({''}, "
<<
nlc
<<
", 1);"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_part_str = repmat({''}, "
<<
nlc
<<
", 1);"
<<
endl
;
int
i
=
0
;
for
(
auto
&
it
:
growth_info
)
{
i
++
;
int
growth_symb_id
,
growth_lag
,
param_id
=
-
1
;
double
constant
=
0
;
tie
(
growth_symb_id
,
growth_lag
,
param_id
,
constant
)
=
it
;
string
growth_type
;
switch
(
symbol_table
.
getType
(
growth_symb_id
))
if
(
growth
)
{
size_t
nlc
=
growth_info
.
size
();
output
<<
"M_.pac."
<<
name
<<
".growth_index = repmat(-1, "
<<
nlc
<<
", 1);"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_lag = zeros("
<<
nlc
<<
", 1);"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_param_id = repmat(-1, "
<<
nlc
<<
", 1);"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_constant = zeros("
<<
nlc
<<
", 1);"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_type = repmat({''}, "
<<
nlc
<<
", 1);"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_part_str = repmat({''}, "
<<
nlc
<<
", 1);"
<<
endl
;
int
i
=
0
;
for
(
auto
&
it
:
growth_info
)
{
case
SymbolType
::
endogenous
:
growth_type
=
"endogenous"
;
break
;
case
SymbolType
::
exogenous
:
growth_type
=
"exogenous"
;
break
;
case
SymbolType
::
parameter
:
growth_type
=
"parameter"
;
break
;
default:
{
}
}
i
++
;
int
growth_symb_id
,
growth_lag
,
param_id
=
-
1
;
double
constant
=
0
;
tie
(
growth_symb_id
,
growth_lag
,
param_id
,
constant
)
=
it
;
string
growth_type
;
switch
(
symbol_table
.
getType
(
growth_symb_id
))
{
case
SymbolType
::
endogenous
:
growth_type
=
"endogenous"
;
break
;
case
SymbolType
::
exogenous
:
growth_type
=
"exogenous"
;
break
;
case
SymbolType
::
parameter
:
growth_type
=
"parameter"
;
break
;
default:
{
}
}
try
{
// case when this is not the highest lag of the growth variable
int
aux_symb_id
=
symbol_table
.
searchAuxiliaryVars
(
growth_symb_id
,
growth_lag
);
output
<<
"M_.pac."
<<
name
<<
".growth_index("
<<
i
<<
") = "
<<
symbol_table
.
getTypeSpecificID
(
aux_symb_id
)
+
1
<<
";"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_lag("
<<
i
<<
") = 0;"
<<
endl
;
}
catch
(...)
{
try
{
// case when this is the highest lag of the growth variable
int
tmp_growth_lag
=
growth_lag
+
1
;
int
aux_symb_id
=
symbol_table
.
searchAuxiliaryVars
(
growth_symb_id
,
tmp_growth_lag
);
// case when this is not the highest lag of the growth variable
int
aux_symb_id
=
symbol_table
.
searchAuxiliaryVars
(
growth_symb_id
,
growth_lag
);
output
<<
"M_.pac."
<<
name
<<
".growth_index("
<<
i
<<
") = "
<<
symbol_table
.
getTypeSpecificID
(
aux_symb_id
)
+
1
<<
";"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_lag("
<<
i
<<
") =
-1
;"
<<
endl
;
<<
"M_.pac."
<<
name
<<
".growth_lag("
<<
i
<<
") =
0
;"
<<
endl
;
}
catch
(...)
{
// case when there is no aux var for the variable
output
<<
"M_.pac."
<<
name
<<
".growth_index("
<<
i
<<
") = "
<<
symbol_table
.
getTypeSpecificID
(
growth_symb_id
)
+
1
<<
";"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_lag("
<<
i
<<
") = "
<<
growth_lag
<<
";"
<<
endl
;
try
{
// case when this is the highest lag of the growth variable
int
tmp_growth_lag
=
growth_lag
+
1
;
int
aux_symb_id
=
symbol_table
.
searchAuxiliaryVars
(
growth_symb_id
,
tmp_growth_lag
);
output
<<
"M_.pac."
<<
name
<<
".growth_index("
<<
i
<<
") = "
<<
symbol_table
.
getTypeSpecificID
(
aux_symb_id
)
+
1
<<
";"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_lag("
<<
i
<<
") = -1;"
<<
endl
;
}
catch
(...)
{
// case when there is no aux var for the variable
output
<<
"M_.pac."
<<
name
<<
".growth_index("
<<
i
<<
") = "
<<
symbol_table
.
getTypeSpecificID
(
growth_symb_id
)
+
1
<<
";"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_lag("
<<
i
<<
") = "
<<
growth_lag
<<
";"
<<
endl
;
}
}
}
output
<<
"M_.pac."
<<
name
<<
".growth_param_id("
<<
i
<<
") = "
<<
(
param_id
==
-
1
?
-
1
:
symbol_table
.
getTypeSpecificID
(
param_id
))
+
1
<<
";"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_constant("
<<
i
<<
") = "
<<
constant
<<
";"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_type{"
<<
i
<<
"} = '"
<<
growth_type
<<
"';"
<<
endl
;
output
<<
"M_.pac."
<<
name
<<
".growth_param_id("
<<
i
<<
") = "
<<
(
param_id
==
-
1
?
-
1
:
symbol_table
.
getTypeSpecificID
(
param_id
))
+
1
<<
";"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_constant("
<<
i
<<
") = "
<<
constant
<<
";"
<<
endl
<<
"M_.pac."
<<
name
<<
".growth_type{"
<<
i
<<
"} = '"
<<
growth_type
<<
"';"
<<
endl
;
}
output
<<
"M_.pac."
<<
name
<<
".growth_str = '"
;
original_growth
->
writeJsonOutput
(
output
,
{},
{},
true
);
output
<<
"';"
<<
endl
;
}
output
<<
"M_.pac."
<<
name
<<
".growth_str = '"
;
original_growth
->
writeJsonOutput
(
output
,
{},
{},
true
);
output
<<
"';"
<<
endl
;
}
void
...
...
@@ -387,10 +390,14 @@ PacModelStatement::writeJsonOutput(ostream &output) const
output
<<
R"({"statementName": "pac_model",)"
<<
R"("model_name": ")"
<<
name
<<
R"(",)"
<<
R"("auxiliary_model_name": ")"
<<
aux_model_name
<<
R"(",)"
<<
R"("discount_index": )"
<<
symbol_table
.
getTypeSpecificID
(
discount
)
+
1
<<
R"("growth_str": ")"
;
original_growth
->
writeJsonOutput
(
output
,
{},
{},
true
);
output
<<
R"("})"
<<
endl
;
<<
R"("discount_index": )"
<<
symbol_table
.
getTypeSpecificID
(
discount
)
+
1
;
if
(
growth
)
{
output
<<
R"(,"growth_str": ")"
;
original_growth
->
writeJsonOutput
(
output
,
{},
{},
true
);
output
<<
R"(")"
;
}
output
<<
"}"
<<
endl
;
}
VarEstimationStatement
::
VarEstimationStatement
(
OptionsList
options_list_arg
)
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment