Merge branch 'master' into ecb-master
Fixed conflicts: matlab/backward/backward_model_forecast.m preprocessor/DynareBison.yy preprocessor/ParsingDriver.hh tests/practicing/datasaver.missue#70
commit
8e767ee720
|
@ -626,9 +626,7 @@ ForecastStatement::writeJsonOutput(ostream &output) const
|
|||
output << "}";
|
||||
}
|
||||
|
||||
RamseyModelStatement::RamseyModelStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
symbol_list(symbol_list_arg),
|
||||
RamseyModelStatement::RamseyModelStatement(const OptionsList &options_list_arg) :
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
@ -2606,15 +2604,16 @@ WriteLatexDynamicModelStatement::writeJsonOutput(ostream &output) const
|
|||
output << "{\"statementName\": \"write_latex_dynamic_model\"}";
|
||||
}
|
||||
|
||||
WriteLatexStaticModelStatement::WriteLatexStaticModelStatement(const StaticModel &static_model_arg) :
|
||||
static_model(static_model_arg)
|
||||
WriteLatexStaticModelStatement::WriteLatexStaticModelStatement(const StaticModel &static_model_arg, bool write_equation_tags_arg) :
|
||||
static_model(static_model_arg),
|
||||
write_equation_tags(write_equation_tags_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
WriteLatexStaticModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||
{
|
||||
static_model.writeLatexFile(basename);
|
||||
static_model.writeLatexFile(basename, write_equation_tags);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2623,15 +2622,16 @@ WriteLatexStaticModelStatement::writeJsonOutput(ostream &output) const
|
|||
output << "{\"statementName\": \"write_latex_static_model\"}";
|
||||
}
|
||||
|
||||
WriteLatexOriginalModelStatement::WriteLatexOriginalModelStatement(const DynamicModel &original_model_arg) :
|
||||
original_model(original_model_arg)
|
||||
WriteLatexOriginalModelStatement::WriteLatexOriginalModelStatement(const DynamicModel &original_model_arg, bool write_equation_tags_arg) :
|
||||
original_model(original_model_arg),
|
||||
write_equation_tags(write_equation_tags_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
WriteLatexOriginalModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||
{
|
||||
original_model.writeLatexOriginalFile(basename);
|
||||
original_model.writeLatexOriginalFile(basename, write_equation_tags);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -4608,10 +4608,13 @@ void
|
|||
CalibSmootherStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
OptionsList::string_options_t::const_iterator it = options_list.string_options.find("parameter_set");
|
||||
if (it == options_list.string_options.end())
|
||||
output << "options_.parameter_set = 'calibration';" << endl;
|
||||
symbol_list.writeOutput("var_list_", output);
|
||||
output << "options_.smoother = 1;" << endl;
|
||||
output << "options_.order = 1;" << endl;
|
||||
output << "[oo_,M_,options_,bayestopt_]=evaluate_smoother('calibration',var_list_,M_,oo_,options_,bayestopt_,estim_params_);" << endl;
|
||||
output << "options_.smoother = 1;" << endl
|
||||
<< "options_.order = 1;" << endl
|
||||
<< "[oo_, M_, options_, bayestopt_] = evaluate_smoother(options_.parameter_set, var_list_, M_, oo_, options_, bayestopt_, estim_params_);" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -186,11 +186,9 @@ public:
|
|||
class RamseyModelStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const SymbolList symbol_list;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
RamseyModelStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
RamseyModelStatement(const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||
virtual void writeJsonOutput(ostream &output) const;
|
||||
|
@ -662,8 +660,9 @@ class WriteLatexStaticModelStatement : public Statement
|
|||
{
|
||||
private:
|
||||
const StaticModel &static_model;
|
||||
const bool write_equation_tags;
|
||||
public:
|
||||
WriteLatexStaticModelStatement(const StaticModel &static_model_arg);
|
||||
WriteLatexStaticModelStatement(const StaticModel &static_model_arg, bool write_equation_tags_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||
virtual void writeJsonOutput(ostream &output) const;
|
||||
};
|
||||
|
@ -672,8 +671,9 @@ class WriteLatexOriginalModelStatement : public Statement
|
|||
{
|
||||
private:
|
||||
const DynamicModel &original_model;
|
||||
const bool write_equation_tags;
|
||||
public:
|
||||
WriteLatexOriginalModelStatement(const DynamicModel &original_model_arg);
|
||||
WriteLatexOriginalModelStatement(const DynamicModel &original_model_arg, bool write_equation_tags_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||
virtual void writeJsonOutput(ostream &output) const;
|
||||
};
|
||||
|
|
|
@ -537,6 +537,7 @@ DataTree::AddLocalVariable(int symb_id, expr_t value) throw (LocalVariableExcept
|
|||
throw LocalVariableException(symbol_table.getName(symb_id));
|
||||
|
||||
local_variables_table[symb_id] = value;
|
||||
local_variables_vector.push_back(symb_id);
|
||||
}
|
||||
|
||||
expr_t
|
||||
|
|
|
@ -90,6 +90,8 @@ protected:
|
|||
|
||||
//! Stores local variables value (maps symbol ID to corresponding node)
|
||||
map<int, expr_t> local_variables_table;
|
||||
//! Stores the order of appearance of local variables in the model block. Needed following change in #563
|
||||
vector<int> local_variables_vector;
|
||||
|
||||
//! Internal implementation of AddVariable(), without the check on the lag
|
||||
VariableNode *AddVariableInternal(int symb_id, int lag);
|
||||
|
|
|
@ -2695,23 +2695,24 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
|
|||
(julia ? "false" : "0"))
|
||||
<< ";" << endl;
|
||||
|
||||
vector<int> state_var;
|
||||
for (int endoID = 0; endoID < symbol_table.endo_nbr(); endoID++)
|
||||
// Loop on periods
|
||||
for (int lag = -max_endo_lag; lag < 0; lag++)
|
||||
try
|
||||
{
|
||||
getDerivID(symbol_table.getID(eEndogenous, variable_reordered[endoID]), lag);
|
||||
if (lag < 0 && find(state_var.begin(), state_var.end(), variable_reordered[endoID]+1) == state_var.end())
|
||||
state_var.push_back(variable_reordered[endoID]+1);
|
||||
}
|
||||
catch (UnknownDerivIDException &e)
|
||||
{
|
||||
}
|
||||
|
||||
//In case of sparse model, writes the block_decomposition structure of the model
|
||||
if (block_decomposition)
|
||||
{
|
||||
vector<int> state_var, state_equ;
|
||||
for (int endoID = 0; endoID < symbol_table.endo_nbr(); endoID++)
|
||||
// Loop on periods
|
||||
for (int lag = -max_endo_lag; lag < 0; lag++)
|
||||
try
|
||||
{
|
||||
getDerivID(symbol_table.getID(eEndogenous, variable_reordered[endoID]), lag);
|
||||
if (lag < 0 && find(state_var.begin(), state_var.end(), variable_reordered[endoID]+1) == state_var.end())
|
||||
state_var.push_back(variable_reordered[endoID]+1);
|
||||
}
|
||||
catch (UnknownDerivIDException &e)
|
||||
{
|
||||
}
|
||||
|
||||
vector<int> state_equ;
|
||||
int count_lead_lag_incidence = 0;
|
||||
int max_lead, max_lag, max_lag_endo, max_lead_endo, max_lag_exo, max_lead_exo, max_lag_exo_det, max_lead_exo_det;
|
||||
unsigned int nb_blocks = getNbBlocks();
|
||||
|
@ -3129,13 +3130,13 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
|
|||
KF_index_file.write(reinterpret_cast<char *>(&(*it)), sizeof(index_KF));
|
||||
KF_index_file.close();
|
||||
}
|
||||
output << modstruct << "state_var = [";
|
||||
|
||||
for (vector<int>::const_iterator it = state_var.begin(); it != state_var.end(); it++)
|
||||
output << *it << " ";
|
||||
output << "];" << endl;
|
||||
}
|
||||
|
||||
output << modstruct << "state_var = [";
|
||||
for (vector<int>::const_iterator it=state_var.begin(); it != state_var.end(); it++)
|
||||
output << *it << " ";
|
||||
output << "];" << endl;
|
||||
|
||||
// Writing initialization for some other variables
|
||||
if (!julia)
|
||||
output << modstruct << "exo_names_orig_ord = [1:" << symbol_table.exo_nbr() << "];" << endl;
|
||||
|
@ -3818,9 +3819,9 @@ DynamicModel::cloneDynamic(DynamicModel &dynamic_model) const
|
|||
assert(&symbol_table == &dynamic_model.symbol_table);
|
||||
|
||||
// Convert model local variables (need to be done first)
|
||||
for (map<int, expr_t>::const_iterator it = local_variables_table.begin();
|
||||
it != local_variables_table.end(); it++)
|
||||
dynamic_model.AddLocalVariable(it->first, it->second->cloneDynamic(dynamic_model));
|
||||
for (vector<int>::const_iterator it = local_variables_vector.begin();
|
||||
it != local_variables_vector.end(); it++)
|
||||
dynamic_model.AddLocalVariable(*it, local_variables_table.find(*it)->second->cloneDynamic(dynamic_model));
|
||||
|
||||
// Convert equations
|
||||
for (size_t i = 0; i < equations.size(); i++)
|
||||
|
@ -3841,7 +3842,8 @@ DynamicModel::cloneDynamic(DynamicModel &dynamic_model) const
|
|||
// Convert static_only equations
|
||||
for (size_t i = 0; i < static_only_equations.size(); i++)
|
||||
dynamic_model.addStaticOnlyEquation(static_only_equations[i]->cloneDynamic(dynamic_model),
|
||||
static_only_equations_lineno[i]);
|
||||
static_only_equations_lineno[i],
|
||||
static_only_equations_equation_tags[i]);
|
||||
|
||||
dynamic_model.setLeadsLagsOrig();
|
||||
}
|
||||
|
@ -3942,9 +3944,9 @@ DynamicModel::toStatic(StaticModel &static_model) const
|
|||
assert(&symbol_table == &static_model.symbol_table);
|
||||
|
||||
// Convert model local variables (need to be done first)
|
||||
for (map<int, expr_t>::const_iterator it = local_variables_table.begin();
|
||||
it != local_variables_table.end(); it++)
|
||||
static_model.AddLocalVariable(it->first, it->second->toStatic(static_model));
|
||||
for (vector<int>::const_iterator it = local_variables_vector.begin();
|
||||
it != local_variables_vector.end(); it++)
|
||||
static_model.AddLocalVariable(*it, local_variables_table.find(*it)->second->toStatic(static_model));
|
||||
|
||||
// Convert equations
|
||||
int static_only_index = 0;
|
||||
|
@ -3952,12 +3954,14 @@ DynamicModel::toStatic(StaticModel &static_model) const
|
|||
{
|
||||
// Detect if equation is marked [dynamic]
|
||||
bool is_dynamic_only = false;
|
||||
vector<pair<string, string> > eq_tags;
|
||||
for (vector<pair<int, pair<string, string> > >::const_iterator it = equation_tags.begin();
|
||||
it != equation_tags.end(); ++it)
|
||||
if (it->first == i && it->second.first == "dynamic")
|
||||
if (it->first == i)
|
||||
{
|
||||
is_dynamic_only = true;
|
||||
break;
|
||||
eq_tags.push_back(it->second);
|
||||
if (it->second.first == "dynamic")
|
||||
is_dynamic_only = true;
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -3965,11 +3969,11 @@ DynamicModel::toStatic(StaticModel &static_model) const
|
|||
// If yes, replace it by an equation marked [static]
|
||||
if (is_dynamic_only)
|
||||
{
|
||||
static_model.addEquation(static_only_equations[static_only_index]->toStatic(static_model), static_only_equations_lineno[static_only_index]);
|
||||
static_model.addEquation(static_only_equations[static_only_index]->toStatic(static_model), static_only_equations_lineno[static_only_index], static_only_equations_equation_tags[static_only_index]);
|
||||
static_only_index++;
|
||||
}
|
||||
else
|
||||
static_model.addEquation(equations[i]->toStatic(static_model), equations_lineno[i]);
|
||||
static_model.addEquation(equations[i]->toStatic(static_model), equations_lineno[i], eq_tags);
|
||||
}
|
||||
catch (DataTree::DivisionByZeroException)
|
||||
{
|
||||
|
@ -4548,9 +4552,9 @@ DynamicModel::writeLatexFile(const string &basename, const bool write_equation_t
|
|||
}
|
||||
|
||||
void
|
||||
DynamicModel::writeLatexOriginalFile(const string &basename) const
|
||||
DynamicModel::writeLatexOriginalFile(const string &basename, const bool write_equation_tags) const
|
||||
{
|
||||
writeLatexModelFile(basename + "_original", oLatexDynamicModel);
|
||||
writeLatexModelFile(basename + "_original", oLatexDynamicModel, write_equation_tags);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -4870,13 +4874,18 @@ DynamicModel::isModelLocalVariableUsed() const
|
|||
}
|
||||
|
||||
void
|
||||
DynamicModel::addStaticOnlyEquation(expr_t eq, int lineno)
|
||||
DynamicModel::addStaticOnlyEquation(expr_t eq, int lineno, const vector<pair<string, string> > &eq_tags)
|
||||
{
|
||||
BinaryOpNode *beq = dynamic_cast<BinaryOpNode *>(eq);
|
||||
assert(beq != NULL && beq->get_op_code() == oEqual);
|
||||
|
||||
vector<pair<string, string> > soe_eq_tags;
|
||||
for (size_t i = 0; i < eq_tags.size(); i++)
|
||||
soe_eq_tags.push_back(eq_tags[i]);
|
||||
|
||||
static_only_equations.push_back(beq);
|
||||
static_only_equations_lineno.push_back(lineno);
|
||||
static_only_equations_equation_tags.push_back(soe_eq_tags);
|
||||
}
|
||||
|
||||
size_t
|
||||
|
|
|
@ -39,6 +39,9 @@ private:
|
|||
//! Stores line numbers of equations declared as [static]
|
||||
vector<int> static_only_equations_lineno;
|
||||
|
||||
//! Stores the equation tags of equations declared as [static]
|
||||
vector<vector<pair<string, string> > > static_only_equations_equation_tags;
|
||||
|
||||
typedef map<pair<int, int>, int> deriv_id_table_t;
|
||||
//! Maps a pair (symbol_id, lag) to a deriv ID
|
||||
deriv_id_table_t deriv_id_table;
|
||||
|
@ -308,7 +311,7 @@ public:
|
|||
void replaceMyEquations(DynamicModel &dynamic_model) const;
|
||||
|
||||
//! Adds an equation marked as [static]
|
||||
void addStaticOnlyEquation(expr_t eq, int lineno);
|
||||
void addStaticOnlyEquation(expr_t eq, int lineno, const vector<pair<string, string> > &eq_tags);
|
||||
|
||||
//! Returns number of static only equations
|
||||
size_t staticOnlyEquationsNbr() const;
|
||||
|
@ -320,7 +323,7 @@ public:
|
|||
void writeLatexFile(const string &basename, const bool write_equation_tags) const;
|
||||
|
||||
//! Writes LaTeX file with the equations of the dynamic model (for the original model)
|
||||
void writeLatexOriginalFile(const string &basename) const;
|
||||
void writeLatexOriginalFile(const string &basename, const bool write_equation_tags) const;
|
||||
|
||||
virtual int getDerivID(int symb_id, int lag) const throw (UnknownDerivIDException);
|
||||
virtual int getDynJacobianCol(int deriv_id) const throw (UnknownDerivIDException);
|
||||
|
|
|
@ -129,7 +129,7 @@ class ParsingDriver;
|
|||
%token TEX RAMSEY_MODEL RAMSEY_POLICY RAMSEY_CONSTRAINTS PLANNER_DISCOUNT DISCRETIONARY_POLICY DISCRETIONARY_TOL
|
||||
%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 VAREXOBS PREDETERMINED_VARIABLES VAR_EXPECTATION PLOT_SHOCK_DECOMPOSITION
|
||||
%token VALUES VAR VAREXO VAREXO_DET VAROBS VAREXOBS PREDETERMINED_VARIABLES VAR_EXPECTATION PLOT_SHOCK_DECOMPOSITION MODEL_LOCAL_VARIABLE
|
||||
%token WRITE_LATEX_DYNAMIC_MODEL WRITE_LATEX_STATIC_MODEL WRITE_LATEX_ORIGINAL_MODEL CROSSEQUATIONS COVARIANCE
|
||||
%token XLS_SHEET XLS_RANGE LMMCP OCCBIN BANDPASS_FILTER COLORMAP VAR_MODEL QOQ YOY AOA
|
||||
%left COMMA
|
||||
|
@ -203,6 +203,7 @@ statement : parameters
|
|||
| varexo
|
||||
| varexo_det
|
||||
| predetermined_variables
|
||||
| model_local_variable
|
||||
| change_type
|
||||
| periods
|
||||
| model
|
||||
|
@ -494,6 +495,8 @@ predetermined_variables : PREDETERMINED_VARIABLES predetermined_variables_list '
|
|||
|
||||
parameters : PARAMETERS parameter_list ';';
|
||||
|
||||
model_local_variable : MODEL_LOCAL_VARIABLE model_local_variable_list ';';
|
||||
|
||||
named_var_elem : symbol EQUAL QUOTED_STRING
|
||||
{
|
||||
pair<string *, string *> *pr = new pair<string *, string *>($1, $3);
|
||||
|
@ -638,6 +641,20 @@ predetermined_variables_list : predetermined_variables_list symbol
|
|||
{ driver.add_predetermined_variable($1); }
|
||||
;
|
||||
|
||||
model_local_variable_list : model_local_variable_list symbol
|
||||
{ driver.declare_model_local_variable($2); }
|
||||
| model_local_variable_list COMMA symbol
|
||||
{ driver.declare_model_local_variable($3); }
|
||||
| symbol
|
||||
{ driver.declare_model_local_variable($1); }
|
||||
| model_local_variable_list symbol TEX_NAME
|
||||
{ driver.declare_model_local_variable($2, $3); }
|
||||
| model_local_variable_list COMMA symbol TEX_NAME
|
||||
{ driver.declare_model_local_variable($3, $4); }
|
||||
| symbol TEX_NAME
|
||||
{ driver.declare_model_local_variable($1, $2); }
|
||||
;
|
||||
|
||||
change_type : CHANGE_TYPE '(' change_type_arg ')' change_type_var_list ';'
|
||||
{ driver.change_type($3, $5); }
|
||||
;
|
||||
|
@ -2169,10 +2186,6 @@ ramsey_model : RAMSEY_MODEL ';'
|
|||
{ driver.ramsey_model(); }
|
||||
| RAMSEY_MODEL '(' ramsey_model_options_list ')' ';'
|
||||
{ driver.ramsey_model(); }
|
||||
| RAMSEY_MODEL symbol_list ';'
|
||||
{ driver.ramsey_model(); }
|
||||
| RAMSEY_MODEL '(' ramsey_model_options_list ')' symbol_list ';'
|
||||
{ driver.ramsey_model(); }
|
||||
;
|
||||
|
||||
ramsey_policy : RAMSEY_POLICY ';'
|
||||
|
@ -2253,11 +2266,15 @@ write_latex_dynamic_model : WRITE_LATEX_DYNAMIC_MODEL ';'
|
|||
;
|
||||
|
||||
write_latex_static_model : WRITE_LATEX_STATIC_MODEL ';'
|
||||
{ driver.write_latex_static_model(); }
|
||||
{ driver.write_latex_static_model(false); }
|
||||
| WRITE_LATEX_STATIC_MODEL '(' WRITE_EQUATION_TAGS ')' ';'
|
||||
{ driver.write_latex_static_model(true); }
|
||||
;
|
||||
|
||||
write_latex_original_model : WRITE_LATEX_ORIGINAL_MODEL ';'
|
||||
{ driver.write_latex_original_model(); }
|
||||
{ driver.write_latex_original_model(false); }
|
||||
| WRITE_LATEX_ORIGINAL_MODEL '(' WRITE_EQUATION_TAGS ')' ';'
|
||||
{ driver.write_latex_original_model(true); }
|
||||
;
|
||||
|
||||
shock_decomposition : SHOCK_DECOMPOSITION ';'
|
||||
|
@ -2818,6 +2835,7 @@ calib_smoother_option : o_filtered_vars
|
|||
| o_diffuse_kalman_tol
|
||||
| o_diffuse_filter
|
||||
| o_smoothed_state_uncertainty
|
||||
| o_parameter_set
|
||||
;
|
||||
|
||||
extended_path : EXTENDED_PATH ';'
|
||||
|
|
|
@ -111,6 +111,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>log_trend_var {BEGIN DYNARE_STATEMENT; return token::LOG_TREND_VAR;}
|
||||
<INITIAL>predetermined_variables {BEGIN DYNARE_STATEMENT; return token::PREDETERMINED_VARIABLES;}
|
||||
<INITIAL>parameters {BEGIN DYNARE_STATEMENT; return token::PARAMETERS;}
|
||||
<INITIAL>model_local_variable {BEGIN DYNARE_STATEMENT; return token::MODEL_LOCAL_VARIABLE;}
|
||||
<INITIAL>periods {BEGIN DYNARE_STATEMENT; return token::PERIODS;}
|
||||
<INITIAL>model_info {BEGIN DYNARE_STATEMENT; return token::MODEL_INFO;}
|
||||
<INITIAL>estimation {BEGIN DYNARE_STATEMENT; return token::ESTIMATION;}
|
||||
|
|
|
@ -62,7 +62,7 @@ usage()
|
|||
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
|
||||
<< " [cygwin] [msvc] [mingw]"
|
||||
#endif
|
||||
<< "[json=parse|check|transform|compute] [jsonstdout] [onlyjson] [jsonderivsimple]"
|
||||
<< " [json=parse|check|transform|compute] [jsonstdout] [onlyjson] [jsonderivsimple] [nopathchange] [nopreprocessoroutput]"
|
||||
<< endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
@ -829,7 +829,8 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
|
|||
|
||||
mOutputFile << "M_.orig_eq_nbr = " << mod_file_struct.orig_eq_nbr << ";" << endl
|
||||
<< "M_.eq_nbr = " << dynamic_model.equation_number() << ";" << endl
|
||||
<< "M_.ramsey_eq_nbr = " << mod_file_struct.ramsey_eq_nbr << ";" << endl;
|
||||
<< "M_.ramsey_eq_nbr = " << mod_file_struct.ramsey_eq_nbr << ";" << endl
|
||||
<< "M_.set_auxiliary_variables = exist(['./' M_.fname '_set_auxiliary_variables.m'], 'file') == 2;" << endl;
|
||||
|
||||
if (dynamic_model.equation_number() > 0)
|
||||
{
|
||||
|
|
78
ModelTree.cc
78
ModelTree.cc
|
@ -1418,24 +1418,25 @@ ModelTree::writeModelLocalVariables(ostream &output, ExprNodeOutputType output_t
|
|||
for (size_t i = 0; i < equations.size(); i++)
|
||||
equations[i]->collectVariables(eModelLocalVariable, used_local_vars);
|
||||
|
||||
for (set<int>::const_iterator it = used_local_vars.begin();
|
||||
it != used_local_vars.end(); ++it)
|
||||
{
|
||||
int id = *it;
|
||||
expr_t value = local_variables_table.find(id)->second;
|
||||
value->writeExternalFunctionOutput(output, output_type, tt, tef_terms);
|
||||
for (vector<int>::const_iterator it = local_variables_vector.begin();
|
||||
it != local_variables_vector.end(); it++)
|
||||
if (used_local_vars.find(*it) != used_local_vars.end())
|
||||
{
|
||||
int id = *it;
|
||||
expr_t value = local_variables_table.find(id)->second;
|
||||
value->writeExternalFunctionOutput(output, output_type, tt, tef_terms);
|
||||
|
||||
if (IS_C(output_type))
|
||||
output << "double ";
|
||||
else if (IS_JULIA(output_type))
|
||||
output << " @inbounds ";
|
||||
if (IS_C(output_type))
|
||||
output << "double ";
|
||||
else if (IS_JULIA(output_type))
|
||||
output << " @inbounds ";
|
||||
|
||||
/* We append underscores to avoid name clashes with "g1" or "oo_" (see
|
||||
also VariableNode::writeOutput) */
|
||||
output << symbol_table.getName(id) << "__ = ";
|
||||
value->writeOutput(output, output_type, tt, tef_terms);
|
||||
output << ";" << endl;
|
||||
}
|
||||
/* We append underscores to avoid name clashes with "g1" or "oo_" (see
|
||||
also VariableNode::writeOutput) */
|
||||
output << symbol_table.getName(id) << "__ = ";
|
||||
value->writeOutput(output, output_type, tt, tef_terms);
|
||||
output << ";" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1468,21 +1469,26 @@ ModelTree::writeJsonModelLocalVariables(ostream &output, deriv_node_temp_terms_t
|
|||
}
|
||||
output << "]"
|
||||
<< ", \"model_local_variables\": [";
|
||||
for (set<int>::const_iterator it = used_local_vars.begin();
|
||||
it != used_local_vars.end(); ++it)
|
||||
{
|
||||
if (it != used_local_vars.begin())
|
||||
output << ", ";
|
||||
int id = *it;
|
||||
expr_t value = local_variables_table.find(id)->second;
|
||||
bool printed = false;
|
||||
for (vector<int>::const_iterator it = local_variables_vector.begin();
|
||||
it != local_variables_vector.end(); it++)
|
||||
if (used_local_vars.find(*it) != used_local_vars.end())
|
||||
{
|
||||
int id = *it;
|
||||
expr_t value = local_variables_table.find(id)->second;
|
||||
|
||||
/* We append underscores to avoid name clashes with "g1" or "oo_" (see
|
||||
also VariableNode::writeOutput) */
|
||||
output << "{\"variable\": \"" << symbol_table.getName(id) << "__\""
|
||||
<< ", \"value\": \"";
|
||||
value->writeJsonOutput(output, tt, tef_terms);
|
||||
output << "\"}" << endl;
|
||||
}
|
||||
if (printed)
|
||||
output << ", ";
|
||||
else
|
||||
printed = true;
|
||||
|
||||
/* We append underscores to avoid name clashes with "g1" or "oo_" (see
|
||||
also VariableNode::writeOutput) */
|
||||
output << "{\"variable\": \"" << symbol_table.getName(id) << "__\""
|
||||
<< ", \"value\": \"";
|
||||
value->writeJsonOutput(output, tt, tef_terms);
|
||||
output << "\"}" << endl;
|
||||
}
|
||||
output << "]";
|
||||
}
|
||||
|
||||
|
@ -1660,11 +1666,11 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output
|
|||
<< "\\footnotesize" << endl;
|
||||
|
||||
// Write model local variables
|
||||
for (map<int, expr_t>::const_iterator it = local_variables_table.begin();
|
||||
it != local_variables_table.end(); it++)
|
||||
for (vector<int>::const_iterator it = local_variables_vector.begin();
|
||||
it != local_variables_vector.end(); it++)
|
||||
{
|
||||
int id = it->first;
|
||||
expr_t value = it->second;
|
||||
int id = *it;
|
||||
expr_t value = local_variables_table.find(id)->second;
|
||||
|
||||
content_output << "\\begin{dmath*}" << endl
|
||||
<< symbol_table.getTeXName(id) << " = ";
|
||||
|
@ -1690,7 +1696,7 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output
|
|||
|
||||
content_output << iteqt->second.first;
|
||||
|
||||
if (iteqt->second.second.empty())
|
||||
if (!(iteqt->second.second.empty()))
|
||||
content_output << "= `" << iteqt->second.second << "'";
|
||||
|
||||
wrote_eq_tag = true;
|
||||
|
@ -1723,7 +1729,7 @@ ModelTree::addEquation(expr_t eq, int lineno)
|
|||
}
|
||||
|
||||
void
|
||||
ModelTree::addEquation(expr_t eq, int lineno, vector<pair<string, string> > &eq_tags)
|
||||
ModelTree::addEquation(expr_t eq, int lineno, const vector<pair<string, string> > &eq_tags)
|
||||
{
|
||||
int n = equations.size();
|
||||
for (size_t i = 0; i < eq_tags.size(); i++)
|
||||
|
|
|
@ -200,7 +200,7 @@ protected:
|
|||
void compileModelEquations(ostream &code_file, unsigned int &instruction_number, const temporary_terms_t &tt, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const;
|
||||
|
||||
//! Writes LaTeX model file
|
||||
void writeLatexModelFile(const string &basename, ExprNodeOutputType output_type, const bool write_equation_tags = false) const;
|
||||
void writeLatexModelFile(const string &basename, ExprNodeOutputType output_type, const bool write_equation_tags) const;
|
||||
|
||||
//! Sparse matrix of double to store the values of the Jacobian
|
||||
/*! First index is equation number, second index is endogenous type specific ID */
|
||||
|
@ -318,7 +318,7 @@ public:
|
|||
//! Declare a node as an equation of the model; also give its line number
|
||||
void addEquation(expr_t eq, int lineno);
|
||||
//! Declare a node as an equation of the model, also giving its tags
|
||||
void addEquation(expr_t eq, int lineno, vector<pair<string, string> > &eq_tags);
|
||||
void addEquation(expr_t eq, int lineno, const vector<pair<string, string> > &eq_tags);
|
||||
//! Declare a node as an auxiliary equation of the model, adding it at the end of the list of auxiliary equations
|
||||
void addAuxEquation(expr_t eq);
|
||||
//! Returns the number of equations in the model
|
||||
|
|
|
@ -2126,8 +2126,7 @@ ParsingDriver::ramsey_model()
|
|||
{
|
||||
if (!mod_file->symbol_table.exists("optimal_policy_discount_factor"))
|
||||
declare_optimal_policy_discount_factor_parameter(data_tree->One);
|
||||
mod_file->addStatement(new RamseyModelStatement(symbol_list, options_list));
|
||||
symbol_list.clear();
|
||||
mod_file->addStatement(new RamseyModelStatement(options_list));
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
|
@ -2165,15 +2164,15 @@ ParsingDriver::write_latex_dynamic_model(bool write_equation_tags)
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::write_latex_static_model()
|
||||
ParsingDriver::write_latex_static_model(bool write_equation_tags)
|
||||
{
|
||||
mod_file->addStatement(new WriteLatexStaticModelStatement(mod_file->static_model));
|
||||
mod_file->addStatement(new WriteLatexStaticModelStatement(mod_file->static_model, write_equation_tags));
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::write_latex_original_model()
|
||||
ParsingDriver::write_latex_original_model(bool write_equation_tags)
|
||||
{
|
||||
mod_file->addStatement(new WriteLatexOriginalModelStatement(mod_file->original_model));
|
||||
mod_file->addStatement(new WriteLatexOriginalModelStatement(mod_file->original_model, write_equation_tags));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2409,7 +2408,7 @@ ParsingDriver::add_model_equal(expr_t arg1, expr_t arg2)
|
|||
if (!id->isInStaticForm())
|
||||
error("An equation tagged [static] cannot contain leads, lags, expectations or STEADY_STATE operators");
|
||||
|
||||
dynamic_model->addStaticOnlyEquation(id, location.begin.line);
|
||||
dynamic_model->addStaticOnlyEquation(id, location.begin.line, eq_tags);
|
||||
}
|
||||
else
|
||||
model_tree->addEquation(id, location.begin.line, eq_tags);
|
||||
|
@ -2424,6 +2423,15 @@ ParsingDriver::add_model_equal_with_zero_rhs(expr_t arg)
|
|||
return add_model_equal(arg, model_tree->Zero);
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::declare_model_local_variable(string *name, string *tex_name)
|
||||
{
|
||||
declare_symbol(name, eModelLocalVariable, tex_name, NULL);
|
||||
delete name;
|
||||
if (tex_name != NULL)
|
||||
delete tex_name;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::declare_and_init_model_local_variable(string *name, expr_t rhs)
|
||||
{
|
||||
|
|
|
@ -325,6 +325,8 @@ public:
|
|||
void declare_parameter(string *name, string *tex_name = NULL, vector<pair<string *, string *> *> *partition_value = NULL);
|
||||
//! Declares a VAR variable and adds to symbol_list
|
||||
void declare_var_endogenous(string *name);
|
||||
//! Declares a model local variable
|
||||
void declare_model_local_variable(string *name, string *tex_name = NULL);
|
||||
//! Declares a statement local variable
|
||||
void declare_statement_local_variable(string *name);
|
||||
//! Completes a subsample statement
|
||||
|
@ -387,7 +389,7 @@ public:
|
|||
void end_shocks(bool overwrite);
|
||||
//! Writes a mshocks statement
|
||||
void end_mshocks(bool overwrite);
|
||||
//! Adds a deterministic chock or a path element inside a conditional_forecast_paths block
|
||||
//! Adds a deterministic shock or a path element inside a conditional_forecast_paths block
|
||||
void add_det_shock(string *var, bool conditional_forecast);
|
||||
//! Adds a std error chock
|
||||
void add_stderr_shock(string *var, expr_t value);
|
||||
|
@ -591,9 +593,9 @@ public:
|
|||
//! Adds a write_latex_dynamic_model statement
|
||||
void write_latex_dynamic_model(bool write_equation_tags);
|
||||
//! Adds a write_latex_static_model statement
|
||||
void write_latex_static_model();
|
||||
void write_latex_static_model(bool write_equation_tags);
|
||||
//! Adds a write_latex_original_model statement
|
||||
void write_latex_original_model();
|
||||
void write_latex_original_model(bool write_equation_tags);
|
||||
//! BVAR marginal density
|
||||
void bvar_density(string *maxnlags);
|
||||
//! BVAR forecast
|
||||
|
|
|
@ -2112,9 +2112,9 @@ StaticModel::writeChainRuleDerivative(ostream &output, int eqr, int varr, int la
|
|||
}
|
||||
|
||||
void
|
||||
StaticModel::writeLatexFile(const string &basename) const
|
||||
StaticModel::writeLatexFile(const string &basename, bool write_equation_tags) const
|
||||
{
|
||||
writeLatexModelFile(basename + "_static", oLatexStaticModel);
|
||||
writeLatexModelFile(basename + "_static", oLatexStaticModel, write_equation_tags);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2130,6 +2130,11 @@ StaticModel::writeAuxVarInitval(ostream &output, ExprNodeOutputType output_type)
|
|||
void
|
||||
StaticModel::writeSetAuxiliaryVariables(const string &basename, const bool julia) const
|
||||
{
|
||||
ostringstream output_func_body;
|
||||
writeAuxVarRecursiveDefinitions(output_func_body, oMatlabStaticModel);
|
||||
|
||||
if (output_func_body.str().empty())
|
||||
return;
|
||||
|
||||
string func_name = basename + "_set_auxiliary_variables";
|
||||
string filename = julia ? func_name + ".jl" : func_name + ".m";
|
||||
|
@ -2148,10 +2153,8 @@ StaticModel::writeSetAuxiliaryVariables(const string &basename, const bool julia
|
|||
<< comment << " Status : Computes static model for Dynare" << endl
|
||||
<< comment << endl
|
||||
<< comment << " Warning : this file is generated automatically by Dynare" << endl
|
||||
<< comment << " from model file (.mod)" << endl
|
||||
<< endl;
|
||||
|
||||
writeAuxVarRecursiveDefinitions(output, oMatlabStaticModel);
|
||||
<< comment << " from model file (.mod)" << endl << endl
|
||||
<< output_func_body.str();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -183,7 +183,7 @@ public:
|
|||
void writeParamsDerivativesFile(const string &basename, bool julia) const;
|
||||
|
||||
//! Writes LaTeX file with the equations of the static model
|
||||
void writeLatexFile(const string &basename) const;
|
||||
void writeLatexFile(const string &basename, const bool write_equation_tags) const;
|
||||
|
||||
//! Writes initializations in oo_.steady_state or steady state file for the auxiliary variables
|
||||
void writeAuxVarInitval(ostream &output, ExprNodeOutputType output_type) const;
|
||||
|
|
Loading…
Reference in New Issue