preprocessor: new command write_latex_original_model. closes #657

issue#70
Houtan Bastani 2015-02-16 08:31:30 +01:00
parent 904c93a75e
commit 4ba729fdd6
12 changed files with 73 additions and 11 deletions

View File

@ -1431,6 +1431,17 @@ WriteLatexStaticModelStatement::writeOutput(ostream &output, const string &basen
static_model.writeLatexFile(basename);
}
WriteLatexOriginalModelStatement::WriteLatexOriginalModelStatement(const DynamicModel &original_model_arg) :
original_model(original_model_arg)
{
}
void
WriteLatexOriginalModelStatement::writeOutput(ostream &output, const string &basename) const
{
original_model.writeLatexOriginalFile(basename);
}
ShockDecompositionStatement::ShockDecompositionStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg) :
symbol_list(symbol_list_arg),

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2014 Dynare Team
* Copyright (C) 2003-2015 Dynare Team
*
* This file is part of Dynare.
*
@ -509,6 +509,15 @@ public:
virtual void writeOutput(ostream &output, const string &basename) const;
};
class WriteLatexOriginalModelStatement : public Statement
{
private:
const DynamicModel &original_model;
public:
WriteLatexOriginalModelStatement(const DynamicModel &original_model_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
};
class ShockDecompositionStatement : public Statement
{
private:

View File

@ -3997,6 +3997,12 @@ DynamicModel::writeLatexFile(const string &basename) const
writeLatexModelFile(basename + "_dynamic.tex", oLatexDynamicModel);
}
void
DynamicModel::writeLatexOriginalFile(const string &basename) const
{
writeLatexModelFile(basename + "_original.tex", oLatexDynamicModel);
}
void
DynamicModel::substituteEndoLeadGreaterThanTwo(bool deterministic_model)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2014 Dynare Team
* Copyright (C) 2003-2015 Dynare Team
*
* This file is part of Dynare.
*
@ -252,6 +252,9 @@ public:
//! Writes LaTeX file with the equations of the dynamic model
void writeLatexFile(const string &basename) const;
//! Writes LaTeX file with the equations of the dynamic model (for the original model)
void writeLatexOriginalFile(const string &basename) const;
virtual int getDerivID(int symb_id, int lag) const throw (UnknownDerivIDException);
virtual int getDynJacobianCol(int deriv_id) const throw (UnknownDerivIDException);
virtual void addAllParamDerivId(set<int> &deriv_id_set);

View File

@ -126,7 +126,7 @@ class ParsingDriver;
%token <string_val> TEX_NAME
%token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL USEAUTOCORR GSA_SAMPLE_FILE USE_UNIVARIATE_FILTERS_IF_SINGULARITY_IS_DETECTED
%token VALUES VAR VAREXO VAREXO_DET VAROBS PREDETERMINED_VARIABLES
%token WRITE_LATEX_DYNAMIC_MODEL WRITE_LATEX_STATIC_MODEL
%token WRITE_LATEX_DYNAMIC_MODEL WRITE_LATEX_STATIC_MODEL WRITE_LATEX_ORIGINAL_MODEL
%token XLS_SHEET XLS_RANGE LONG_NAME
%left COMMA
%left EQUAL_EQUAL EXCLAMATION_EQUAL
@ -250,6 +250,7 @@ statement : parameters
| identification
| write_latex_dynamic_model
| write_latex_static_model
| write_latex_original_model
| shock_decomposition
| conditional_forecast
| conditional_forecast_paths
@ -1906,6 +1907,10 @@ write_latex_static_model : WRITE_LATEX_STATIC_MODEL ';'
{ driver.write_latex_static_model(); }
;
write_latex_original_model : WRITE_LATEX_ORIGINAL_MODEL ';'
{ driver.write_latex_original_model(); }
;
shock_decomposition : SHOCK_DECOMPOSITION ';'
{driver.shock_decomposition(); }
| SHOCK_DECOMPOSITION '(' shock_decomposition_options_list ')' ';'

View File

@ -129,6 +129,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<INITIAL>save_params_and_steady_state {BEGIN DYNARE_STATEMENT; return token::SAVE_PARAMS_AND_STEADY_STATE;}
<INITIAL>write_latex_dynamic_model {BEGIN DYNARE_STATEMENT; return token::WRITE_LATEX_DYNAMIC_MODEL;}
<INITIAL>write_latex_static_model {BEGIN DYNARE_STATEMENT; return token::WRITE_LATEX_STATIC_MODEL;}
<INITIAL>write_latex_original_model {BEGIN DYNARE_STATEMENT; return token::WRITE_LATEX_ORIGINAL_MODEL;}
<INITIAL>steady {BEGIN DYNARE_STATEMENT; return token::STEADY;}
<INITIAL>check {BEGIN DYNARE_STATEMENT; return token::CHECK;}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007-2014 Dynare Team
* Copyright (C) 2007-2015 Dynare Team
*
* This file is part of Dynare.
*
@ -1851,8 +1851,20 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
}
return;
case oExpectation:
cerr << "UnaryOpNode::writeOutput: not implemented on oExpectation" << endl;
exit(EXIT_FAILURE);
if (!IS_LATEX(output_type))
{
cerr << "UnaryOpNode::writeOutput: not implemented on oExpectation" << endl;
exit(EXIT_FAILURE);
}
output << "\\mathbb{E}_{t";
if (expectation_information_set != 0)
{
if (expectation_information_set > 0)
output << "+";
output << expectation_information_set;
}
output << "}";
break;
case oErf:
output << "erf";
break;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2014 Dynare Team
* Copyright (C) 2006-2015 Dynare Team
*
* This file is part of Dynare.
*
@ -32,6 +32,7 @@
ModFile::ModFile(WarningConsolidation &warnings_arg)
: expressions_tree(symbol_table, num_constants, external_functions_table),
original_model(symbol_table, num_constants, external_functions_table),
dynamic_model(symbol_table, num_constants, external_functions_table),
trend_dynamic_model(symbol_table, num_constants, external_functions_table),
ramsey_FOC_equations_dynamic_model(symbol_table, num_constants, external_functions_table),
@ -306,6 +307,9 @@ ModFile::checkPass()
void
ModFile::transformPass(bool nostrict)
{
// Save the original model (must be done before any model transformations by preprocessor)
dynamic_model.cloneDynamic(original_model);
if (nostrict)
{
set<int> unusedEndogs = dynamic_model.findUnusedEndogenous();

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2014 Dynare Team
* Copyright (C) 2006-2015 Dynare Team
*
* This file is part of Dynare.
*
@ -51,6 +51,8 @@ public:
NumericalConstants num_constants;
//! Expressions outside model block
DataTree expressions_tree;
//! Original model, as declared in the "model" block, that won't be modified by the preprocessor
DynamicModel original_model;
//! Dynamic model, as declared in the "model" block
DynamicModel dynamic_model;
//! A copy of Dynamic model, for testing trends declared by user

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2014 Dynare Team
* Copyright (C) 2003-2015 Dynare Team
*
* This file is part of Dynare.
*
@ -1352,6 +1352,7 @@ ModelTree::writeLatexModelFile(const string &filename, ExprNodeOutputType output
output << "\\documentclass[10pt,a4paper]{article}" << endl
<< "\\usepackage[landscape]{geometry}" << endl
<< "\\usepackage{fullpage}" << endl
<< "\\usepackage{amsfonts}" << endl
<< "\\usepackage{breqn}" << endl
<< "\\begin{document}" << endl
<< "\\footnotesize" << endl;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2014 Dynare Team
* Copyright (C) 2003-2015 Dynare Team
*
* This file is part of Dynare.
*
@ -1820,6 +1820,12 @@ ParsingDriver::write_latex_static_model()
mod_file->addStatement(new WriteLatexStaticModelStatement(mod_file->static_model));
}
void
ParsingDriver::write_latex_original_model()
{
mod_file->addStatement(new WriteLatexOriginalModelStatement(mod_file->original_model));
}
void
ParsingDriver::bvar_density(string *maxnlags)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2014 Dynare Team
* Copyright (C) 2003-2015 Dynare Team
*
* This file is part of Dynare.
*
@ -503,6 +503,8 @@ public:
void write_latex_dynamic_model();
//! Adds a write_latex_static_model statement
void write_latex_static_model();
//! Adds a write_latex_original_model statement
void write_latex_original_model();
//! BVAR marginal density
void bvar_density(string *maxnlags);
//! BVAR forecast