Commit f3c2a1bf authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

New var_expectation_model statement and re-design of var_expectation operator

Given a previously declared var_model, the var_expectation_model statement is
used to declare a way of forming expectations with this VAR (possibly using a
finite or infinite discounted sum). The var_expectation operator now takes a
single argument, the name of the var_expectation_model.

For the moment, this only works when the var_model is using equations
explicitly declared in the model block.
parent 8a03532c
......@@ -528,30 +528,6 @@ VarModelStatement::writeJsonOutput(ostream &output) const
<< "\"model_name\": \"" << name << "\"}";
}
void
VarModelStatement::createVarModelMFunction(ostream &output, const map<string, set<int>> &var_expectation_functions_to_write) const
{
if (var_expectation_functions_to_write.find(name) == var_expectation_functions_to_write.end())
return;
stringstream ss;
set<int> horizons = var_expectation_functions_to_write.find(name)->second;
for (auto it = horizons.begin(); it != horizons.end(); it++)
{
if (it != horizons.begin())
ss << " ";
ss << *it;
}
output << "writeVarExpectationFunction('" << name << "', ";
if (horizons.size() > 1)
output << "[";
output << ss.rdbuf();
if (horizons.size() > 1)
output << "]";
output << ");" << endl;
}
VarEstimationStatement::VarEstimationStatement(OptionsList options_list_arg) :
options_list(move(options_list_arg))
{
......@@ -5017,3 +4993,45 @@ GenerateIRFsStatement::writeJsonOutput(ostream &output) const
}
output << "}";
}
VarExpectationModelStatement::VarExpectationModelStatement(string model_name_arg, string variable_arg, string var_model_name_arg,
string horizon_arg, expr_t discount_arg, const SymbolTable &symbol_table_arg) :
model_name{move(model_name_arg)}, variable{move(variable_arg)},
var_model_name{move(var_model_name_arg)}, horizon{move(horizon_arg)},
discount{discount_arg}, symbol_table{symbol_table_arg}
{
}
void
VarExpectationModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
{
string mstruct = "M_.var_expectation." + model_name;
output << mstruct << ".var_model_name = '" << var_model_name << "';" << endl
<< mstruct << ".horizon = " << horizon << ';' << endl;
auto disc_var = dynamic_cast<const VariableNode *>(discount);
if (disc_var)
output << mstruct << ".discount_index = " << disc_var->get_symb_id() << ';' << endl;
else
{
output << mstruct << ".discount_value = ";
discount->writeOutput(output);
output << ';' << endl;
}
output << mstruct << ".param_indices = [ ";
for (int param_id : aux_params_ids)
output << symbol_table.getTypeSpecificID(param_id) << ' ';
output << "];" << endl;
}
void
VarExpectationModelStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"var_expectation_model\","
<< "\"model_name\": \"" << model_name << "\", "
<< "\"variable\": \"" << variable << "\", "
<< "\"var_model_name\": \"" << var_model_name << "\", "
<< "\"horizon\": \"" << horizon << "\", "
<< "\"discount\": \"";
discount->writeOutput(output);
output << "\"}";
}
......@@ -145,10 +145,11 @@ public:
class VarModelStatement : public Statement
{
private:
public:
const SymbolList symbol_list;
const OptionsList options_list;
const string name;
private:
const SymbolTable &symbol_table;
vector<int> eqnumber, lhs, orig_diff_var;
vector<set<pair<int, int>>> rhs_by_eq; // rhs by equation
......@@ -170,7 +171,6 @@ public:
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
void createVarModelMFunction(ostream &output, const map<string, set<int>> &var_expectation_functions_to_write) const;
};
class VarRestrictionsStatement : public Statement
......@@ -1209,4 +1209,20 @@ public:
void writeJsonOutput(ostream &output) const override;
};
class VarExpectationModelStatement : public Statement
{
public:
const string model_name, variable, var_model_name, horizon;
const expr_t discount;
const SymbolTable &symbol_table;
// List of generated auxiliary param ids, in variable-major order
vector<int> aux_params_ids; // TODO: move this to some new VarModelTable object
public:
VarExpectationModelStatement(string model_name_arg, string variable_arg, string var_model_name_arg,
string horizon_arg, expr_t discount_arg, const SymbolTable &symbol_table_arg);
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
#endif
......@@ -505,15 +505,13 @@ DataTree::AddExpectation(int iArg1, expr_t iArg2)
}
expr_t
DataTree::AddVarExpectation(const int symb_id, const int forecast_horizon, const string &model_name)
DataTree::AddVarExpectation(const string &model_name)
{
assert(symbol_table.getType(symb_id) == SymbolType::endogenous);
auto it = var_expectation_node_map.find({ model_name, symb_id, forecast_horizon });
auto it = var_expectation_node_map.find(model_name);
if (it != var_expectation_node_map.end())
return it->second;
return new VarExpectationNode(*this, symb_id, forecast_horizon, model_name);
return new VarExpectationNode(*this, model_name);
}
expr_t
......
......@@ -82,7 +82,7 @@ protected:
external_function_node_map_t external_function_node_map;
// (model_name, symb_id, forecast_horizon) -> VarExpectationNode
using var_expectation_node_map_t = map<tuple<string, int, int>, VarExpectationNode *>;
using var_expectation_node_map_t = map<string, VarExpectationNode *>;
var_expectation_node_map_t var_expectation_node_map;
// model_name -> PacExpectationNode
......@@ -242,8 +242,8 @@ public:
expr_t AddSteadyStateParam2ndDeriv(expr_t iArg1, int param1_symb_id, int param2_symb_id);
//! Adds "arg1=arg2" to model tree
expr_t AddEqual(expr_t iArg1, expr_t iArg2);
//! Adds "var_expectation(arg1, arg2, model_name=arg3)" to model tree
expr_t AddVarExpectation(const int symb_id, const int forecast_horizon, const string &model_name);
//! Adds "var_expectation(model_name)" to model tree
expr_t AddVarExpectation(const string &model_name);
//! Adds pac_expectation command to model tree
expr_t AddPacExpectation(const string &model_name);
//! Adds a model local variable with its value
......
......@@ -1515,34 +1515,6 @@ DynamicModel::writeDynamicMFile(const string &basename) const
writeDynamicModel(basename, false, false);
}
void
DynamicModel::fillVarExpectationFunctionsToWrite()
{
for (auto &it : var_expectation_node_map)
var_expectation_functions_to_write[get<0>(it.first)].insert(get<2>(it.first));
}
map<string, set<int>>
DynamicModel::getVarExpectationFunctionsToWrite() const
{
return var_expectation_functions_to_write;
}
void
DynamicModel::writeVarExpectationCalls(ostream &output) const
{
for (const auto & it : var_expectation_functions_to_write)
{
int i = 0;
output << "dynamic_var_forecast_" << it.first << " = "
<< "var_forecast_" << it.first << "(y);" << endl;
for (auto it1 = it.second.begin(); it1 != it.second.end(); it1++)
output << "dynamic_var_forecast_" << it.first << "_" << *it1 << " = "
<< "dynamic_var_forecast_" << it.first << "(" << ++i << ", :);" << endl;
}
}
void
DynamicModel::writeDynamicJuliaFile(const string &basename) const
{
......@@ -3628,13 +3600,6 @@ DynamicModel::getVarLhsDiffAndInfo(vector<int> &eqnumber, vector<bool> &diff,
}
}
void
DynamicModel::setVarExpectationIndices(map<string, pair<SymbolList, int>> &var_model_info)
{
for (auto & equation : equations)
equation->setVarExpectationIndex(var_model_info);
}
void
DynamicModel::addEquationsForVar(map<string, pair<SymbolList, int>> &var_model_info)
{
......@@ -6220,3 +6185,10 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
<< ", " << third_derivs1_output.str()
<< "}";
}
void
DynamicModel::substituteVarExpectation(const map<string, expr_t> &subst_table)
{
for (auto & equation : equations)
equation = dynamic_cast<BinaryOpNode *>(equation->substituteVarExpectation(subst_table));
}
......@@ -100,8 +100,6 @@ private:
void writeDynamicMFile(const string &basename) const;
//! Writes dynamic model file (Julia version)
void writeDynamicJuliaFile(const string &dynamic_basename) const;
//! Write Var Expectation calls
void writeVarExpectationCalls(ostream &output) const;
//! Writes dynamic model file (C version)
/*! \todo add third derivatives handling */
void writeDynamicCFile(const string &basename, const int order) const;
......@@ -320,8 +318,6 @@ public:
void getVarLhsDiffAndInfo(vector<int> &eqnumber, vector<bool> &diff,
vector<int> &orig_diff_var) const;
//! Set indices for var expectation in dynamic model file
void setVarExpectationIndices(map<string, pair<SymbolList, int>> &var_model_info);
//! Add aux equations (and aux variables) for variables declared in var_model at max order if they don't already exist
void addEquationsForVar(map<string, pair<SymbolList, int>> &var_model_info);
//! Get Pac equation parameter info
......@@ -435,16 +431,13 @@ public:
//! Substitutes diff operator
void substituteDiff(StaticModel &static_model, ExprNode::subst_table_t &diff_subst_table);
//! Substitute VarExpectation operators
void substituteVarExpectation(const map<string, expr_t> &subst_table);
//! Table to undiff LHS variables for pac vector z
void getUndiffLHSForPac(vector<int> &lhs, vector<expr_t> &lhs_expr_t, vector<bool> &diff, vector<int> &orig_diff_var,
vector<int> &eqnumber, map<string, int> &undiff, ExprNode::subst_table_t &diff_subst_table);
//! Fill var_expectation_functions_to_write
void fillVarExpectationFunctionsToWrite();
//! Get var_expectation_functions_to_write
map<string, set<int>> getVarExpectationFunctionsToWrite() const;
//! Transforms the model by replacing trend variables with a 1
void removeTrendVariableFromEquations();
......
......@@ -118,7 +118,7 @@ class ParsingDriver;
%token TEX RAMSEY_MODEL RAMSEY_POLICY RAMSEY_CONSTRAINTS PLANNER_DISCOUNT DISCRETIONARY_POLICY DISCRETIONARY_TOL
%token <string> 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 MODEL_LOCAL_VARIABLE
%token VALUES VAR VAREXO VAREXO_DET VARIABLE VAROBS VAREXOBS PREDETERMINED_VARIABLES VAR_EXPECTATION VAR_EXPECTATION_MODEL PLOT_SHOCK_DECOMPOSITION MODEL_LOCAL_VARIABLE
%token WRITE_LATEX_DYNAMIC_MODEL WRITE_LATEX_STATIC_MODEL WRITE_LATEX_ORIGINAL_MODEL CROSSEQUATIONS COVARIANCE WRITE_LATEX_STEADY_STATE_MODEL
%token XLS_SHEET XLS_RANGE LMMCP OCCBIN BANDPASS_FILTER COLORMAP VAR_MODEL PAC_MODEL QOQ YOY AOA UNDIFF PAC_EXPECTATION
%left EQUAL_EQUAL EXCLAMATION_EQUAL
......@@ -175,8 +175,9 @@ class ParsingDriver;
%type <string> filename symbol vec_of_vec_value vec_value_list date_expr number
%type <string> vec_value_1 vec_value signed_inf signed_number_w_inf
%type <string> range vec_value_w_inf vec_value_1_w_inf
%type <string> integer_range signed_integer_range sub_sampling_options list_sub_sampling_option
%type <pair<string,string>> named_var_elem subsamples_eq_opt calibration_range
%type <string> integer_range signed_integer_range
%type <string> sub_sampling_options list_sub_sampling_option
%type <pair<string,string>> named_var_elem subsamples_eq_opt calibration_range integer_range_w_inf
%type <vector<pair<string,string>>> named_var named_var_1
%type <SymbolType> change_type_arg
%type <vector<string>> vec_str vec_str_1
......@@ -298,6 +299,7 @@ statement : parameters
| gmm_estimation
| smm_estimation
| shock_groups
| var_expectation_model
;
dsample : DSAMPLE INT_NUMBER ';'
......@@ -386,6 +388,29 @@ pac_model_options : o_pac_name
{ driver.pac_model_undiff($3, $5); }
;
var_expectation_model : VAR_EXPECTATION_MODEL '(' var_expectation_model_options_list ')' ';'
{ driver.var_expectation_model(); }
;
var_expectation_model_options_list : var_expectation_model_option
| var_expectation_model_options_list COMMA var_expectation_model_option
;
var_expectation_model_option : VARIABLE EQUAL symbol
{ driver.option_str("variable", $3); }
| VAR_MODEL_NAME EQUAL symbol
{ driver.option_str("var_model_name", $3); }
| HORIZON EQUAL INT_NUMBER
{ driver.option_num("horizon", $3); }
| HORIZON EQUAL integer_range_w_inf
{ driver.option_num("horizon", "[ " + $3.first + ' ' + $3.second + " ]"); }
| MODEL_NAME EQUAL symbol
{ driver.option_str("model_name", $3); }
| DISCOUNT EQUAL expression
{ driver.var_expectation_model_discount = $3; }
;
restrictions : RESTRICTIONS '(' symbol ')' ';' { driver.begin_VAR_restrictions(); }
restrictions_list END ';' { driver.end_VAR_restrictions($3); }
;
......@@ -912,10 +937,8 @@ hand_side : '(' hand_side ')'
{ $$ = driver.add_power($1, $3); }
| EXPECTATION '(' signed_integer ')''(' hand_side ')'
{ $$ = driver.add_expectation($3, $6); }
| VAR_EXPECTATION '(' symbol COMMA MODEL_NAME EQUAL NAME ')'
{ $$ = driver.add_var_expectation($3, "1", $7); }
| VAR_EXPECTATION '(' symbol COMMA INT_NUMBER COMMA MODEL_NAME EQUAL NAME ')'
{ $$ = driver.add_var_expectation($3, $5, $9); }
| VAR_EXPECTATION '(' symbol ')'
{ $$ = driver.add_var_expectation($3); }
| PAC_EXPECTATION '(' symbol ')'
{ $$ = driver.add_pac_expectation($3); }
| MINUS hand_side %prec UMINUS
......@@ -3650,6 +3673,12 @@ range : symbol ':' symbol
integer_range : INT_NUMBER ':' INT_NUMBER
{ $$ = $1 + ':' + $3; }
integer_range_w_inf : INT_NUMBER ':' INT_NUMBER
{ $$ = make_pair($1, $3); }
| INT_NUMBER ':' INF_CONSTANT
{ $$ = make_pair($1, "Inf"); }
;
signed_integer_range : signed_integer ':' signed_integer
{ $$ = $1 + ':' + $3; }
| MINUS '(' signed_integer ':' signed_integer ')'
......
......@@ -141,6 +141,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>simul {BEGIN DYNARE_STATEMENT; return token::SIMUL;}
<INITIAL>stoch_simul {BEGIN DYNARE_STATEMENT; return token::STOCH_SIMUL;}
<INITIAL>var_model {BEGIN DYNARE_STATEMENT; return token::VAR_MODEL;}
<INITIAL>var_expectation_model {BEGIN DYNARE_STATEMENT; return token::VAR_EXPECTATION_MODEL;}
<INITIAL>pac_model {BEGIN DYNARE_STATEMENT; return token::PAC_MODEL;}
<INITIAL>dsample {BEGIN DYNARE_STATEMENT; return token::DSAMPLE;}
<INITIAL>Sigma_e {BEGIN DYNARE_STATEMENT; sigma_e = 1; return token::SIGMA_E;}
......@@ -675,6 +676,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
<DYNARE_STATEMENT>emas_drop {return token::EMAS_DROP; }
<DYNARE_STATEMENT>emas_tolf {return token::EMAS_TOLF; }
<DYNARE_STATEMENT>emas_max_iter {return token::EMAS_MAX_ITER; }
<DYNARE_STATEMENT>variable {return token::VARIABLE;}
<DYNARE_STATEMENT>[\$][^$]*[\$] {
strtok(yytext+1, "$");
......
......@@ -547,6 +547,12 @@ NumConstNode::substituteAdl() const
return const_cast<NumConstNode *>(this);
}
expr_t
NumConstNode::substituteVarExpectation(const map<string, expr_t> &subst_table) const
{
return const_cast<NumConstNode *>(this);
}
void
NumConstNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const
{
......@@ -643,11 +649,6 @@ NumConstNode::isInStaticForm() const
return true;
}
void
NumConstNode::setVarExpectationIndex(map<string, pair<SymbolList, int>> &var_model_info)
{
}
void
NumConstNode::walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int>>> &ec_params_and_vars, set<pair<int, pair<int, int>>> &ar_params_and_vars) const
{
......@@ -1419,6 +1420,12 @@ VariableNode::substituteAdl() const
return const_cast<VariableNode *>(this);
}
expr_t
VariableNode::substituteVarExpectation(const map<string, expr_t> &subst_table) const
{
return const_cast<VariableNode *>(this);
}
void
VariableNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const
{
......@@ -1793,11 +1800,6 @@ VariableNode::isInStaticForm() const
return lag == 0;
}
void
VariableNode::setVarExpectationIndex(map<string, pair<SymbolList, int>> &var_model_info)
{
}
void
VariableNode::walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int>>> &ec_params_and_vars, set<pair<int, pair<int, int>>> &ar_params_and_vars) const
{
......@@ -3009,6 +3011,13 @@ UnaryOpNode::substituteAdl() const
return retval;
}
expr_t
UnaryOpNode::substituteVarExpectation(const map<string, expr_t> &subst_table) const
{
expr_t argsubst = arg->substituteVarExpectation(subst_table);
return buildSimilarUnaryOpNode(argsubst, datatree);
}
int
UnaryOpNode::countDiffs() const
{
......@@ -3390,12 +3399,6 @@ UnaryOpNode::isInStaticForm() const
return arg->isInStaticForm();
}
void
UnaryOpNode::setVarExpectationIndex(map<string, pair<SymbolList, int>> &var_model_info)
{
arg->setVarExpectationIndex(var_model_info);
}
void
UnaryOpNode::walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int>>> &ec_params_and_vars, set<pair<int, pair<int, int>>> &ar_params_and_vars) const
{
......@@ -4870,6 +4873,15 @@ BinaryOpNode::substituteAdl() const
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
}
expr_t
BinaryOpNode::substituteVarExpectation(const map<string, expr_t> &subst_table) const
{
expr_t arg1subst = arg1->substituteVarExpectation(subst_table);
expr_t arg2subst = arg2->substituteVarExpectation(subst_table);
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
}
void
BinaryOpNode::findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &nodes) const
{
......@@ -4991,13 +5003,6 @@ BinaryOpNode::isInStaticForm() const
return arg1->isInStaticForm() && arg2->isInStaticForm();
}
void
BinaryOpNode::setVarExpectationIndex(map<string, pair<SymbolList, int>> &var_model_info)
{
arg1->setVarExpectationIndex(var_model_info);
arg2->setVarExpectationIndex(var_model_info);
}
void
BinaryOpNode::walkPacParametersHelper(const expr_t arg1, const expr_t arg2,
pair<int, int> &lhs,
......@@ -5779,6 +5784,16 @@ TrinaryOpNode::substituteAdl() const
return buildSimilarTrinaryOpNode(arg1subst, arg2subst, arg3subst, datatree);
}
expr_t
TrinaryOpNode::substituteVarExpectation(const map<string, expr_t> &subst_table) const
{
expr_t arg1subst = arg1->substituteVarExpectation(subst_table);
expr_t arg2subst = arg2->substituteVarExpectation(subst_table);
expr_t arg3subst = arg3->substituteVarExpectation(subst_table);
return buildSimilarTrinaryOpNode(arg1subst, arg2subst, arg3subst, datatree);
}
void
TrinaryOpNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const
{
......@@ -5901,14 +5916,6 @@ TrinaryOpNode::isInStaticForm() const
return arg1->isInStaticForm() && arg2->isInStaticForm() && arg3->isInStaticForm();
}
void
TrinaryOpNode::setVarExpectationIndex(map<string, pair<SymbolList, int>> &var_model_info)
{
arg1->setVarExpectationIndex(var_model_info);
arg2->setVarExpectationIndex(var_model_info);
arg3->setVarExpectationIndex(var_model_info);
}
void
TrinaryOpNode::walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int>>> &ec_params_and_vars, set<pair<int, pair<int, int>>> &ar_params_and_vars) const
{
......@@ -6214,6 +6221,15 @@ AbstractExternalFunctionNode::substituteAdl() const
return buildSimilarExternalFunctionNode(arguments_subst, datatree);
}
expr_t
AbstractExternalFunctionNode::substituteVarExpectation(const map<string, expr_t> &subst_table) const
{
vector<expr_t> arguments_subst;
for (auto argument : arguments)
arguments_subst.push_back(argument->substituteVarExpectation(subst_table));
return buildSimilarExternalFunctionNode(arguments_subst, datatree);
}
void
AbstractExternalFunctionNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const
{
......@@ -6398,13 +6414,6 @@ AbstractExternalFunctionNode::isInStaticForm() const
return true;
}
void
AbstractExternalFunctionNode::setVarExpectationIndex(map<string, pair<SymbolList, int>> &var_model_info)
{
for (auto argument : arguments)
argument->setVarExpectationIndex(var_model_info);
}
void
AbstractExternalFunctionNode::walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int>>> &ec_params_and_vars, set<pair<int, pair<int, int>>> &ar_params_and_vars) const
{
......@@ -7564,16 +7573,11 @@ SecondDerivExternalFunctionNode::sameTefTermPredicate() const
}
VarExpectationNode::VarExpectationNode(DataTree &datatree_arg,
int symb_id_arg,
int forecast_horizon_arg,
const string &model_name_arg) :
string model_name_arg) :
ExprNode(datatree_arg),
symb_id(symb_id_arg),
forecast_horizon(forecast_horizon_arg),
model_name(model_name_arg),
yidx(-1)
model_name{move(model_name_arg)}
{
datatree.var_expectation_node_map[{ model_name, symb_id, forecast_horizon }] = this;
datatree.var_expectation_node_map[model_name] = this;
}
void
......@@ -7581,7 +7585,8 @@ VarExpectationNode::computeTemporaryTerms(map<expr_t, pair<int, NodeTreeReferenc
map<NodeTreeReference, temporary_terms_t> &temp_terms_map,
bool is_matlab, NodeTreeReference tr) const
{
temp_terms_map[tr].insert(const_cast<VarExpectationNode *>(this));
cerr << "VarExpectationNode::computeTemporaryTerms not implemented." << endl;
exit(EXIT_FAILURE);
}
void
......@@ -7592,22 +7597,21 @@ VarExpectationNode::computeTemporaryTerms(map<expr_t, int> &reference_count,
vector< vector<temporary_terms_t>> &v_temporary_terms,
int equation) const
{
expr_t this2 = const_cast<VarExpectationNode *>(this);
temporary_terms.insert(this2);
first_occurence[this2] = { Curr_block, equation };
v_temporary_terms[Curr_block][equation].insert(this2);
cerr << "VarExpectationNode::computeTemporaryTerms not implemented." << endl;
exit(EXIT_FAILURE);
}
expr_t
VarExpectationNode::toStatic(DataTree &static_datatree) const
{
return static_datatree.AddVariable(symb_id);
cerr << "VarExpectationNode::toStatic not implemented." << endl;
exit(EXIT_FAILURE);
}
expr_t
VarExpectationNode::cloneDynamic(DataTree &dynamic_datatree) const
{
return dynamic_datatree.AddVarExpectation(symb_id, forecast_horizon, model_name);
return dynamic_datatree.AddVarExpectation(model_name);
}
void
......@@ -7620,101 +7624,110 @@ VarExpectationNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
if (IS_LATEX(output_type))
{
output << "VAR_" << model_name << LEFT_PAR(output_type)
<< datatree.symbol_table.getTeXName(symb_id)
<< "_{t+" << forecast_horizon << "}" << RIGHT_PAR(output_type);
output << "VAR_EXPECTATION(" << model_name << ')';
return;
}
if (checkIfTemporaryTermThenWrite(output, output_type, temporary_terms, temporary_terms_idxs))
return;
output << "dynamic_var_forecast_" << model_name << "_" << forecast_horizon << "(" << yidx + 1 << ")";
cerr << "VarExpectationNode::writeOutput not implemented for non-LaTeX." << endl;
exit(EXIT_FAILURE);
}
int
VarExpectationNode::maxEndoLead() const
{
return 0;
cerr << "VarExpectationNode::maxEndoLead not implemented." << endl;
exit(EXIT_FAILURE);
}
int
VarExpectationNode::maxExoLead() const
{
return 0;
cerr << "VarExpectationNode::maxExoLead not implemented." << endl;
exit(EXIT_FAILURE);
}
int
VarExpectationNode::maxEndoLag() const
{
return 0;
cerr << "VarExpectationNode::maxEndoLead not implemented." << endl;
exit(EXIT_FAILURE);
}
int
VarExpectationNode::maxExoLag() const
{
return 0;
cerr << "VarExpectationNode::maxExoLead not implemented." << endl;
exit(EXIT_FAILURE);
}
int
VarExpectationNode::maxLead() const
{
return 0;
cerr << "VarExpectationNode::maxLead not implemented." << endl;
exit(EXIT_FAILURE);
}
int