Removed remnants of calib commands
parent
ca73c1bd88
commit
091c7961a2
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2003-2010 Dynare Team
|
* Copyright (C) 2003-2011 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -615,131 +615,6 @@ ObservationTrendsStatement::writeOutput(ostream &output, const string &basename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CalibVarStatement::CalibVarStatement(const calib_var_t &calib_var_arg,
|
|
||||||
const calib_covar_t &calib_covar_arg,
|
|
||||||
const calib_ac_t &calib_ac_arg,
|
|
||||||
const SymbolTable &symbol_table_arg) :
|
|
||||||
calib_var(calib_var_arg),
|
|
||||||
calib_covar(calib_covar_arg),
|
|
||||||
calib_ac(calib_ac_arg),
|
|
||||||
symbol_table(symbol_table_arg)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
CalibVarStatement::writeOutput(ostream &output, const string &basename) const
|
|
||||||
{
|
|
||||||
|
|
||||||
output << "%" << endl
|
|
||||||
<< "% CALIB_VAR" << endl
|
|
||||||
<< "%" << endl;
|
|
||||||
|
|
||||||
for (int i = 1; i < 4; i++)
|
|
||||||
{
|
|
||||||
output << "calib_var_index{" << i << "} = [];\n";
|
|
||||||
output << "calib_targets{" << i << "} = [];\n";
|
|
||||||
output << "calib_weights{" << i << "}=[];\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print calibration variances
|
|
||||||
for (calib_var_t::const_iterator it = calib_var.begin();
|
|
||||||
it != calib_var.end(); it++)
|
|
||||||
{
|
|
||||||
const string &name = it->first;
|
|
||||||
const string &weight = it->second.first;
|
|
||||||
const expr_t expression = it->second.second;
|
|
||||||
|
|
||||||
int id = symbol_table.getTypeSpecificID(name) + 1;
|
|
||||||
if (symbol_table.getType(name) == eEndogenous)
|
|
||||||
{
|
|
||||||
output << "calib_var_index{1} = [calib_var_index{1};" << id << "," << id << "];\n";
|
|
||||||
output << "calib_weights{1} = [calib_weights{1}; " << weight << "];\n";
|
|
||||||
output << "calib_targets{1} =[calib_targets{1}; ";
|
|
||||||
expression->writeOutput(output);
|
|
||||||
output << "];\n";
|
|
||||||
}
|
|
||||||
else if (symbol_table.getType(name) == eExogenous)
|
|
||||||
{
|
|
||||||
output << "calib_var_index{3} = [calib_var_index{3};" << id << "," << id << "];\n";
|
|
||||||
output << "calib_weights{3} = [calib_weights{3}; " << weight << "];\n";
|
|
||||||
output << "calib_targets{3} =[calib_targets{3}; ";
|
|
||||||
expression->writeOutput(output);
|
|
||||||
output << "];\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print calibration covariances
|
|
||||||
for (calib_covar_t::const_iterator it = calib_covar.begin();
|
|
||||||
it != calib_covar.end(); it++)
|
|
||||||
{
|
|
||||||
const string &name1 = it->first.first;
|
|
||||||
const string &name2 = it->first.second;
|
|
||||||
const string &weight = it->second.first;
|
|
||||||
const expr_t expression = it->second.second;
|
|
||||||
|
|
||||||
int id1 = symbol_table.getTypeSpecificID(name1) + 1;
|
|
||||||
int id2 = symbol_table.getTypeSpecificID(name2) + 1;
|
|
||||||
if (symbol_table.getType(name1) == eEndogenous)
|
|
||||||
{
|
|
||||||
output << "calib_var_index{1} = [calib_var_index{1};" << id1 << "," << id2 << "];\n";
|
|
||||||
output << "calib_weights{1} = [calib_weights{1}; " << weight << "];\n";
|
|
||||||
output << "calib_targets{1} =[calib_targets{1}; ";
|
|
||||||
expression->writeOutput(output);
|
|
||||||
output << "];\n";
|
|
||||||
}
|
|
||||||
else if (symbol_table.getType(name1) == eExogenous)
|
|
||||||
{
|
|
||||||
output << "calib_var_index{3} = [calib_var_index{3};" << id1 << "," << id2 << "];\n";
|
|
||||||
output << "calib_weights{3} = [calib_weights{3}; " << weight << "];\n";
|
|
||||||
output << "calib_targets{3} =[calib_targets{3}; ";
|
|
||||||
expression->writeOutput(output);
|
|
||||||
output << "];\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print calibration autocorrelations
|
|
||||||
int max_iar = 3;
|
|
||||||
|
|
||||||
for (calib_ac_t::const_iterator it = calib_ac.begin();
|
|
||||||
it != calib_ac.end(); it++)
|
|
||||||
{
|
|
||||||
const string &name = it->first.first;
|
|
||||||
int iar = it->first.second + 3;
|
|
||||||
const string &weight = it->second.first;
|
|
||||||
const expr_t expression = it->second.second;
|
|
||||||
|
|
||||||
int id = symbol_table.getTypeSpecificID(name) + 1;
|
|
||||||
|
|
||||||
if (iar > max_iar)
|
|
||||||
{
|
|
||||||
// Create new variables
|
|
||||||
for (int i = max_iar + 1; i <= iar; i++)
|
|
||||||
{
|
|
||||||
output << "calib_var_index{" << i << "} = [];\n";
|
|
||||||
output << "calib_targets{" << i << "} = [];\n";
|
|
||||||
output << "calib_weights{" << i << "}=[];\n";
|
|
||||||
}
|
|
||||||
max_iar = iar;
|
|
||||||
}
|
|
||||||
|
|
||||||
output << "calib_var_index{" << iar << "} = [calib_var_index{" << iar << "};" << id << "];\n";
|
|
||||||
output << "calib_weights{" << iar << "} = [calib_weights{" << iar << "}; " << weight << "];\n";
|
|
||||||
output << "calib_targets{" << iar << "} =[calib_targets{" << iar << "}; ";
|
|
||||||
expression->writeOutput(output);
|
|
||||||
output << "];\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CalibStatement::CalibStatement(int covar_arg) : covar(covar_arg)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
CalibStatement::writeOutput(ostream &output, const string &basename) const
|
|
||||||
{
|
|
||||||
output << "M_.Sigma_e=calib(calib_var_index,calib_targets,calib_weights,options_.ar," << covar << ",M_.Sigma_e);\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
OsrParamsStatement::OsrParamsStatement(const SymbolList &symbol_list_arg) :
|
OsrParamsStatement::OsrParamsStatement(const SymbolList &symbol_list_arg) :
|
||||||
symbol_list(symbol_list_arg)
|
symbol_list(symbol_list_arg)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2003-2010 Dynare Team
|
* Copyright (C) 2003-2011 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -311,37 +311,6 @@ public:
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CalibStatement : public Statement
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
const int covar;
|
|
||||||
public:
|
|
||||||
CalibStatement(int covar_arg);
|
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CalibVarStatement : public Statement
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Maps a variable to a pair (weight, expression)
|
|
||||||
typedef map<string, pair<string, expr_t> > calib_var_t;
|
|
||||||
//! Maps a pair of variables to a pair (weight, expression)
|
|
||||||
typedef map<pair<string, string>, pair<string, expr_t> > calib_covar_t;
|
|
||||||
//! Maps a pair (variable, autocorr) to a pair (weight, expression)
|
|
||||||
typedef map<pair<string, int>, pair<string, expr_t> > calib_ac_t;
|
|
||||||
private:
|
|
||||||
const calib_var_t calib_var;
|
|
||||||
const calib_covar_t calib_covar;
|
|
||||||
const calib_ac_t calib_ac;
|
|
||||||
const SymbolTable &symbol_table;
|
|
||||||
public:
|
|
||||||
CalibVarStatement(const calib_var_t &calib_var_arg,
|
|
||||||
const calib_covar_t &calib_covar_arg,
|
|
||||||
const calib_ac_t &calib_ac_arg,
|
|
||||||
const SymbolTable &symbol_table_arg);
|
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*! \todo Make model_tree a member instead of a pointer */
|
/*! \todo Make model_tree a member instead of a pointer */
|
||||||
class PlannerObjectiveStatement : public Statement
|
class PlannerObjectiveStatement : public Statement
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2003-2010 Dynare Team
|
* Copyright (C) 2003-2011 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -1136,85 +1136,6 @@ ParsingDriver::run_osr()
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ParsingDriver::set_calib_var(string *name, string *weight, expr_t expression)
|
|
||||||
{
|
|
||||||
check_symbol_existence(*name);
|
|
||||||
if (mod_file->symbol_table.getType(*name) != eEndogenous
|
|
||||||
&& mod_file->symbol_table.getType(*name) != eExogenous)
|
|
||||||
error("calib_var: " + *name + " isn't an endogenous or exogenous variable");
|
|
||||||
|
|
||||||
if (calib_var.find(*name) != calib_var.end())
|
|
||||||
error("calib_var: " + *name + " declared twice");
|
|
||||||
|
|
||||||
calib_var[*name] = make_pair(*weight, expression);
|
|
||||||
|
|
||||||
delete name;
|
|
||||||
delete weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ParsingDriver::set_calib_covar(string *name1, string *name2,
|
|
||||||
string *weight, expr_t expression)
|
|
||||||
{
|
|
||||||
check_symbol_existence(*name1);
|
|
||||||
check_symbol_existence(*name2);
|
|
||||||
if (mod_file->symbol_table.getType(*name1) != mod_file->symbol_table.getType(*name2))
|
|
||||||
error("calib_var: " + *name1 + " and " + *name2 + "dont't have the same type");
|
|
||||||
if (mod_file->symbol_table.getType(*name1) != eEndogenous
|
|
||||||
&& mod_file->symbol_table.getType(*name1) != eExogenous)
|
|
||||||
error("calib_var: " + *name1 + " and " + *name2 + "aren't endogenous or exogenous variables");
|
|
||||||
|
|
||||||
pair<string, string> covar_key(*name1, *name2);
|
|
||||||
|
|
||||||
if (calib_covar.find(covar_key) != calib_covar.end())
|
|
||||||
error("calib_var: pair of variables (" + *name1 + ", " + *name2
|
|
||||||
+ ") declared twice");
|
|
||||||
|
|
||||||
calib_covar[covar_key] = make_pair(*weight, expression);
|
|
||||||
|
|
||||||
delete name1;
|
|
||||||
delete name2;
|
|
||||||
delete weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ParsingDriver::set_calib_ac(string *name, string *ar,
|
|
||||||
string *weight, expr_t expression)
|
|
||||||
{
|
|
||||||
check_symbol_existence(*name);
|
|
||||||
if (mod_file->symbol_table.getType(*name) != eEndogenous)
|
|
||||||
error("calib_var: " + *name + "isn't an endogenous variable");
|
|
||||||
|
|
||||||
int iar = atoi(ar->c_str());
|
|
||||||
pair<string, int> ac_key(*name, iar);
|
|
||||||
|
|
||||||
if (calib_ac.find(ac_key) != calib_ac.end())
|
|
||||||
error("calib_var: autocorr " + *name + "(" + *ar + ") declared twice");
|
|
||||||
|
|
||||||
calib_ac[ac_key] = make_pair(*weight, expression);
|
|
||||||
|
|
||||||
delete name;
|
|
||||||
delete ar;
|
|
||||||
delete weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ParsingDriver::run_calib_var()
|
|
||||||
{
|
|
||||||
mod_file->addStatement(new CalibVarStatement(calib_var, calib_covar, calib_ac,
|
|
||||||
mod_file->symbol_table));
|
|
||||||
calib_var.clear();
|
|
||||||
calib_covar.clear();
|
|
||||||
calib_ac.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ParsingDriver::run_calib(int covar)
|
|
||||||
{
|
|
||||||
mod_file->addStatement(new CalibStatement(covar));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::run_dynatype(string *filename)
|
ParsingDriver::run_dynatype(string *filename)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2003-2010 Dynare Team
|
* Copyright (C) 2003-2011 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -116,12 +116,6 @@ private:
|
||||||
OptimWeightsStatement::var_weights_t var_weights;
|
OptimWeightsStatement::var_weights_t var_weights;
|
||||||
//! Temporary storage of covariances from optim_weights
|
//! Temporary storage of covariances from optim_weights
|
||||||
OptimWeightsStatement::covar_weights_t covar_weights;
|
OptimWeightsStatement::covar_weights_t covar_weights;
|
||||||
//! Temporary storage of variances from calib_var
|
|
||||||
CalibVarStatement::calib_var_t calib_var;
|
|
||||||
//! Temporary storage of covariances from calib_var
|
|
||||||
CalibVarStatement::calib_covar_t calib_covar;
|
|
||||||
//! Temporary storage of autocorrelations from calib_var
|
|
||||||
CalibVarStatement::calib_ac_t calib_ac;
|
|
||||||
//! Temporary storage for deterministic shocks
|
//! Temporary storage for deterministic shocks
|
||||||
ShocksStatement::det_shocks_t det_shocks;
|
ShocksStatement::det_shocks_t det_shocks;
|
||||||
//! Temporary storage for periods of deterministic shocks
|
//! Temporary storage for periods of deterministic shocks
|
||||||
|
@ -371,11 +365,6 @@ public:
|
||||||
void set_optim_weights(string *name1, string *name2, expr_t value);
|
void set_optim_weights(string *name1, string *name2, expr_t value);
|
||||||
void set_osr_params();
|
void set_osr_params();
|
||||||
void run_osr();
|
void run_osr();
|
||||||
void run_calib_var();
|
|
||||||
void set_calib_var(string *name, string *weight, expr_t expression);
|
|
||||||
void set_calib_covar(string *name1, string *name2, string *weight, expr_t expression);
|
|
||||||
void set_calib_ac(string *name, string *ar, string *weight, expr_t expression);
|
|
||||||
void run_calib(int covar);
|
|
||||||
void run_dynasave(string *filename);
|
void run_dynasave(string *filename);
|
||||||
void run_dynatype(string *filename);
|
void run_dynatype(string *filename);
|
||||||
void run_load_params_and_steady_state(string *filename);
|
void run_load_params_and_steady_state(string *filename);
|
||||||
|
|
Loading…
Reference in New Issue