preprocessor: add write_latex_steady_steade_model command. Closes #1496
parent
85d00ad267
commit
349834eeca
|
@ -2257,10 +2257,11 @@ Note that the model written in the @TeX{} file will differ from the
|
|||
model declared by the user in the some dimensions
|
||||
(@pxref{write_latex_dynamic_model} for details).
|
||||
|
||||
Also note that this command will not output the contents of the
|
||||
optional @code{steady_state_model} block (@pxref{steady_state_model});
|
||||
it will rather output a static version (@i{i.e.} without leads and
|
||||
lags) of the dynamic model declared in the @code{model} block.
|
||||
Also note that this command will not output the contents of the optional
|
||||
@code{steady_state_model} block (@pxref{steady_state_model}); it will rather
|
||||
output a static version (@i{i.e.} without leads and lags) of the dynamic model
|
||||
declared in the @code{model} block. To write the @LaTeX{} contents of the
|
||||
@code{steady_state_model} @pxref{write_latex_steady_state_model}.
|
||||
|
||||
For the required @LaTeX{} packages, @pxref{write_latex_original_model}.
|
||||
|
||||
|
@ -2275,6 +2276,31 @@ For the required @LaTeX{} packages, @pxref{write_latex_original_model}.
|
|||
|
||||
@end deffn
|
||||
|
||||
@anchor{write_latex_steady_state_model}
|
||||
@deffn Command write_latex_steady_state_model ;
|
||||
|
||||
@descriptionhead
|
||||
|
||||
This command creates two @LaTeX{} files: one containing the steady state model
|
||||
and one containing the @LaTeX{} document header information.
|
||||
|
||||
If your @file{.mod} file is @file{@var{FILENAME}.mod}, then Dynare will create
|
||||
a file called @file{@var{FILENAME}_steady_state.tex}, which includes a file
|
||||
called @file{@var{FILENAME}_steady_state_content.tex} (also created by Dynare)
|
||||
containing the list of all the steady state model equations.
|
||||
|
||||
If @LaTeX{} names were given for variables and parameters (@pxref{Variable
|
||||
declarations}), then those will be used; otherwise, the plain text names will
|
||||
be used.
|
||||
|
||||
Note that the model written in the @TeX{} file will differ from the model
|
||||
declared by the user in the some dimensions (@pxref{write_latex_dynamic_model}
|
||||
for details).
|
||||
|
||||
For the required @LaTeX{} packages, @pxref{write_latex_original_model}.
|
||||
|
||||
@end deffn
|
||||
|
||||
@node Auxiliary variables
|
||||
@section Auxiliary variables
|
||||
|
||||
|
|
|
@ -2377,6 +2377,23 @@ WriteLatexOriginalModelStatement::writeJsonOutput(ostream &output) const
|
|||
output << "{\"statementName\": \"write_latex_original_model\"}";
|
||||
}
|
||||
|
||||
WriteLatexSteadyStateModelStatement::WriteLatexSteadyStateModelStatement(const SteadyStateModel &steady_state_model_arg) :
|
||||
steady_state_model(steady_state_model_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
WriteLatexSteadyStateModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||
{
|
||||
steady_state_model.writeLatexSteadyStateFile(basename);
|
||||
}
|
||||
|
||||
void
|
||||
WriteLatexSteadyStateModelStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"write_latex_steady_state_model\"}";
|
||||
}
|
||||
|
||||
ShockDecompositionStatement::ShockDecompositionStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
symbol_list(symbol_list_arg),
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "Statement.hh"
|
||||
#include "StaticModel.hh"
|
||||
#include "DynamicModel.hh"
|
||||
#include "SteadyStateModel.hh"
|
||||
|
||||
class SteadyStatement : public Statement
|
||||
{
|
||||
|
@ -625,6 +626,16 @@ public:
|
|||
virtual void writeJsonOutput(ostream &output) const;
|
||||
};
|
||||
|
||||
class WriteLatexSteadyStateModelStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const SteadyStateModel &steady_state_model;
|
||||
public:
|
||||
WriteLatexSteadyStateModelStatement(const SteadyStateModel &steady_state_model_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||
virtual void writeJsonOutput(ostream &output) const;
|
||||
};
|
||||
|
||||
class ShockDecompositionStatement : public Statement
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -130,7 +130,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 PLOT_SHOCK_DECOMPOSITION MODEL_LOCAL_VARIABLE
|
||||
%token WRITE_LATEX_DYNAMIC_MODEL WRITE_LATEX_STATIC_MODEL WRITE_LATEX_ORIGINAL_MODEL
|
||||
%token WRITE_LATEX_DYNAMIC_MODEL WRITE_LATEX_STATIC_MODEL WRITE_LATEX_ORIGINAL_MODEL WRITE_LATEX_STEADY_STATE_MODEL
|
||||
%token XLS_SHEET XLS_RANGE LMMCP OCCBIN BANDPASS_FILTER COLORMAP QOQ YOY AOA
|
||||
%left COMMA
|
||||
%left EQUAL_EQUAL EXCLAMATION_EQUAL
|
||||
|
@ -261,6 +261,7 @@ statement : parameters
|
|||
| write_latex_dynamic_model
|
||||
| write_latex_static_model
|
||||
| write_latex_original_model
|
||||
| write_latex_steady_state_model
|
||||
| shock_decomposition
|
||||
| realtime_shock_decomposition
|
||||
| plot_shock_decomposition
|
||||
|
@ -2142,6 +2143,10 @@ write_latex_original_model : WRITE_LATEX_ORIGINAL_MODEL ';'
|
|||
{ driver.write_latex_original_model(true); }
|
||||
;
|
||||
|
||||
write_latex_steady_state_model : WRITE_LATEX_STEADY_STATE_MODEL ';'
|
||||
{ driver.write_latex_steady_state_model(); }
|
||||
;
|
||||
|
||||
shock_decomposition : SHOCK_DECOMPOSITION ';'
|
||||
{driver.shock_decomposition(); }
|
||||
| SHOCK_DECOMPOSITION '(' shock_decomposition_options_list ')' ';'
|
||||
|
|
|
@ -131,6 +131,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>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>write_latex_steady_state_model {BEGIN DYNARE_STATEMENT; return token::WRITE_LATEX_STEADY_STATE_MODEL;}
|
||||
|
||||
<INITIAL>steady {BEGIN DYNARE_STATEMENT; return token::STEADY;}
|
||||
<INITIAL>check {BEGIN DYNARE_STATEMENT; return token::CHECK;}
|
||||
|
|
|
@ -1978,6 +1978,12 @@ ParsingDriver::write_latex_original_model(bool write_equation_tags)
|
|||
mod_file->addStatement(new WriteLatexOriginalModelStatement(mod_file->original_model, write_equation_tags));
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::write_latex_steady_state_model()
|
||||
{
|
||||
mod_file->addStatement(new WriteLatexSteadyStateModelStatement(mod_file->steady_state_model));
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::bvar_density(string *maxnlags)
|
||||
{
|
||||
|
|
|
@ -568,6 +568,8 @@ public:
|
|||
void write_latex_static_model(bool write_equation_tags);
|
||||
//! Adds a write_latex_original_model statement
|
||||
void write_latex_original_model(bool write_equation_tags);
|
||||
//! Adds a write_latex_steady_state_model statement
|
||||
void write_latex_steady_state_model();
|
||||
//! BVAR marginal density
|
||||
void bvar_density(string *maxnlags);
|
||||
//! BVAR forecast
|
||||
|
|
|
@ -2173,6 +2173,23 @@ StaticModel::writeAuxVarRecursiveDefinitions(ostream &output, ExprNodeOutputType
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
StaticModel::writeLatexAuxVarRecursiveDefinitions(ostream &output) const
|
||||
{
|
||||
deriv_node_temp_terms_t tef_terms;
|
||||
temporary_terms_t temporary_terms;
|
||||
for (int i = 0; i < (int) aux_equations.size(); i++)
|
||||
if (dynamic_cast<ExprNode *>(aux_equations[i])->containsExternalFunction())
|
||||
dynamic_cast<ExprNode *>(aux_equations[i])->writeExternalFunctionOutput(output, oLatexStaticModel,
|
||||
temporary_terms, tef_terms);
|
||||
for (int i = 0; i < (int) aux_equations.size(); i++)
|
||||
{
|
||||
output << "\\begin{dmath}" << endl;
|
||||
dynamic_cast<ExprNode *>(aux_equations[i]->substituteStaticAuxiliaryDefinition())->writeOutput(output, oLatexStaticModel);
|
||||
output << endl << "\\end{dmath}" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
StaticModel::writeParamsDerivativesFile(const string &basename, bool julia) const
|
||||
{
|
||||
|
|
|
@ -191,6 +191,7 @@ public:
|
|||
//! Writes definition of the auxiliary variables in a .m or .jl file
|
||||
void writeSetAuxiliaryVariables(const string &basename, const bool julia) const;
|
||||
void writeAuxVarRecursiveDefinitions(ostream &output, ExprNodeOutputType output_type) const;
|
||||
void writeLatexAuxVarRecursiveDefinitions(ostream &output) const;
|
||||
|
||||
//! To ensure that no exogenous is present in the planner objective
|
||||
//! See #1264
|
||||
|
|
|
@ -104,6 +104,57 @@ SteadyStateModel::checkPass(bool ramsey_model, WarningConsolidation &warnings) c
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SteadyStateModel::writeLatexSteadyStateFile(const string &basename) const
|
||||
{
|
||||
ofstream output, content_output;
|
||||
string filename = basename + "_steady_state.tex";
|
||||
string content_basename = basename + "_steady_state_content";
|
||||
string content_filename = content_basename + ".tex";
|
||||
|
||||
output.open(filename.c_str(), ios::out | ios::binary);
|
||||
if (!output.is_open())
|
||||
{
|
||||
cerr << "ERROR: Can't open file " << filename << " for writing" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
content_output.open(content_filename.c_str(), ios::out | ios::binary);
|
||||
if (!content_output.is_open())
|
||||
{
|
||||
cerr << "ERROR: Can't open file " << content_filename << " for writing" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
output << "\\documentclass[10pt,a4paper]{article}" << endl
|
||||
<< "\\usepackage[landscape]{geometry}" << endl
|
||||
<< "\\usepackage{fullpage}" << endl
|
||||
<< "\\usepackage{amsfonts}" << endl
|
||||
<< "\\usepackage{breqn}" << endl
|
||||
<< "\\begin{document}" << endl
|
||||
<< "\\footnotesize" << endl;
|
||||
|
||||
for (vector<pair<vector<int>, expr_t> >::const_iterator it = def_table.begin();
|
||||
it != def_table.end(); it++)
|
||||
for (vector<int>::const_iterator it1 = it->first.begin(); it1 != it->first.end(); it1++)
|
||||
{
|
||||
int id = *it1;
|
||||
expr_t value = it->second;
|
||||
content_output << "\\begin{dmath}" << endl
|
||||
<< symbol_table.getTeXName(id) << " = ";
|
||||
value->writeOutput(content_output, oLatexStaticModel);
|
||||
content_output << endl << "\\end{dmath}" << endl;
|
||||
}
|
||||
|
||||
static_model.writeLatexAuxVarRecursiveDefinitions(content_output);
|
||||
|
||||
output << "\\include{" << content_basename << "}" << endl
|
||||
<< "\\end{document}" << endl;
|
||||
|
||||
output.close();
|
||||
content_output.close();
|
||||
}
|
||||
|
||||
void
|
||||
SteadyStateModel::writeSteadyStateFile(const string &basename, bool ramsey_model, bool julia) const
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2010-2015 Dynare Team
|
||||
* Copyright (C) 2010-2017 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -50,6 +50,8 @@ public:
|
|||
*/
|
||||
void writeSteadyStateFile(const string &basename, bool ramsey_model, bool julia) const;
|
||||
void writeSteadyStateFileC(const string &basename, bool ramsey_model) const;
|
||||
//! Writes LaTeX file with the equations of the dynamic model (for the steady state model)
|
||||
void writeLatexSteadyStateFile(const string &basename) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue