Commit ef26fae7 authored by michel's avatar michel
Browse files

v4: adding interface for shock decomposition

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2853 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 220a4c7f
......@@ -994,3 +994,20 @@ WriteLatexStaticModelStatement::writeOutput(ostream &output, const string &basen
{
static_model.writeLatexFile(basename);
}
ShockDecompositionStatement::ShockDecompositionStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg) :
symbol_list(symbol_list_arg),
options_list(options_list_arg)
{
}
void
ShockDecompositionStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
symbol_list.writeOutput("var_list_", output);
output << "oo_ = shock_decomposition(M_,oo_,options_,var_list_);\n";
}
......@@ -458,4 +458,15 @@ public:
virtual void writeOutput(ostream &output, const string &basename) const;
};
class ShockDecompositionStatement : public Statement
{
private:
const SymbolList symbol_list;
const OptionsList options_list;
public:
ShockDecompositionStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
};
#endif
......@@ -122,7 +122,7 @@ class ParsingDriver;
%token SPARSE SPARSE_DLL STDERR STEADY STOCH_SIMUL
%token TEX RAMSEY_POLICY PLANNER_DISCOUNT
%token <string_val> TEX_NAME
%token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL
%token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL SHOCK_DECOMPOSITION LABELS
%token VALUES VAR VAREXO VAREXO_DET VAROBS
%token WRITE_LATEX_DYNAMIC_MODEL WRITE_LATEX_STATIC_MODEL
%token XLS_SHEET XLS_RANGE
......@@ -212,6 +212,7 @@ statement : parameters
| identification
| write_latex_dynamic_model
| write_latex_static_model
| shock_decomposition
;
dsample : DSAMPLE INT_NUMBER ';'
......@@ -719,6 +720,24 @@ symbol_list_ext : symbol_list
driver.add_in_symbol_list(colon);
}
;
list_of_symbol_lists : symbol_list ';' NAME
{
string *semicolon = new string(";");
driver.add_in_symbol_list(semicolon);
driver.add_in_symbol_list($3);
}
| list_of_symbol_lists NAME
{ driver.add_in_symbol_list($2); }
| list_of_symbol_lists COMMA NAME
{ driver.add_in_symbol_list($3); }
| list_of_symbol_lists ';' NAME
{
string *semicolon = new string(";");
driver.add_in_symbol_list(semicolon);
driver.add_in_symbol_list($3);
}
;
signed_integer : PLUS INT_NUMBER
{ $$ = $2; }
......@@ -1169,6 +1188,16 @@ write_latex_static_model : WRITE_LATEX_STATIC_MODEL ';'
{ driver.write_latex_static_model(); }
;
shock_decomposition : SHOCK_DECOMPOSITION ';'
{driver.shock_decomposition(); }
| SHOCK_DECOMPOSITION '(' shock_decomposition_options_list ')' ';'
{ driver.shock_decomposition(); }
| SHOCK_DECOMPOSITION symbol_list ';'
{ driver.shock_decomposition(); }
| SHOCK_DECOMPOSITION '(' shock_decomposition_options_list ')' symbol_list ';'
{ driver.shock_decomposition(); }
;
bvar_prior_option : o_bvar_prior_tau
| o_bvar_prior_decay
| o_bvar_prior_lambda
......@@ -1269,6 +1298,14 @@ dynare_sensitivity_option : o_gsa_identification
| o_gsa_trans_ident
;
shock_decomposition_options_list : shock_decomposition_option COMMA shock_decomposition_options_list
| shock_decomposition_option
;
shock_decomposition_option : o_parameters
| o_shocks
| o_labels
;
homotopy_setup: HOMOTOPY_SETUP ';' homotopy_list END
{ driver.end_homotopy();};
......@@ -1436,6 +1473,10 @@ o_gsa_trans_ident : TRANS_IDENT EQUAL INT_NUMBER { driver.option_num("trans_iden
o_homotopy_mode : HOMOTOPY_MODE EQUAL INT_NUMBER {driver.option_num("homotopy_mode",$3); };
o_homotopy_steps : HOMOTOPY_STEPS EQUAL INT_NUMBER {driver.option_num("homotopy_steps",$3); };
o_block_mfs : BLOCK_MFS { driver.option_num("block_mfs", "1"); }
o_parameters : PARAMETERS EQUAL NAME {driver.option_str("parameters",$3);};
o_shocks : SHOCKS EQUAL '(' list_of_symbol_lists ')' { driver.option_symbol_list("shocks"); };
o_labels : LABELS EQUAL '(' symbol_list ')' { driver.option_symbol_list("labels"); };
range : NAME ':' NAME
{
......
......@@ -135,6 +135,7 @@ int sigma_e = 0;
<INITIAL>dynare_sensitivity {BEGIN DYNARE_STATEMENT; return token::DYNARE_SENSITIVITY;}
<INITIAL>initval_file {BEGIN DYNARE_STATEMENT; return token::INITVAL_FILE;}
<INITIAL>forecast {BEGIN DYNARE_STATEMENT; return token::FORECAST;}
<INITIAL>shock_decomposition {BEGIN DYNARE_STATEMENT; return token::SHOCK_DECOMPOSITION;}
/* End of a Dynare statement */
<DYNARE_STATEMENT>; {
......@@ -282,7 +283,7 @@ int sigma_e = 0;
<DYNARE_STATEMENT>xls_range {return token::XLS_RANGE;}
<DYNARE_STATEMENT>mh_recover {return token::MH_RECOVER;}
<DYNARE_STATEMENT>planner_discount {return token::PLANNER_DISCOUNT;}
<DYNARE_STATEMENT>labels {return token::LABELS;}
<DYNARE_STATEMENT>[\.] {return Dynare::parser::token_type (yytext[0]);}
<DYNARE_STATEMENT>[\\] {return Dynare::parser::token_type (yytext[0]);}
......
......@@ -1071,6 +1071,15 @@ ParsingDriver::bvar_forecast(string *nlags)
delete nlags;
}
void
ParsingDriver::shock_decomposition()
{
mod_file->addStatement(new ShockDecompositionStatement(symbol_list, options_list));
symbol_list.clear();
options_list.clear();
}
NodeID
ParsingDriver::add_model_equal(NodeID arg1, NodeID arg2)
{
......
......@@ -350,6 +350,8 @@ public:
void bvar_density(string *maxnlags);
//! BVAR forecast
void bvar_forecast(string *nlags);
//! Shock decomposition
void shock_decomposition();
//! Writes token "arg1=arg2" to model tree
NodeID add_model_equal(NodeID arg1, NodeID arg2);
//! Writes token "arg=0" to model tree
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment