estimation: add subsamples for std / corr, prior / options statements & simplify code
parent
5f707cc795
commit
ad8096edb8
|
@ -1693,18 +1693,32 @@ BasicPriorStatement::writePriorIndex(ostream &output, const string &lhs_field) c
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BasicPriorStatement::writeVarianceOption(ostream &output, const string &lhs_field) const
|
BasicPriorStatement::writeCommonOutput(ostream &output, const string &lhs_field) const
|
||||||
{
|
{
|
||||||
if (variance)
|
writeShape(output, lhs_field);
|
||||||
{
|
writeCommonOutputHelper(output, "mean", lhs_field);
|
||||||
output << "estimation_info" << lhs_field << "(prior_indx).variance = ";
|
writeCommonOutputHelper(output, "mode", lhs_field);
|
||||||
variance->writeOutput(output);
|
writeCommonOutputHelper(output, "stdev", lhs_field);
|
||||||
output << ";" << endl;
|
writeCommonOutputHelper(output, "shape", lhs_field);
|
||||||
}
|
writeCommonOutputHelper(output, "shift", lhs_field);
|
||||||
|
writeCommonOutputHelper(output, "date1", lhs_field);
|
||||||
|
writeCommonOutputHelper(output, "date2", lhs_field);
|
||||||
|
writeCommonOutputHelper(output, "domain", lhs_field);
|
||||||
|
writeCommonOutputHelper(output, "median", lhs_field);
|
||||||
|
writeCommonOutputHelper(output, "truncate", lhs_field);
|
||||||
|
writeCommonOutputHelper(output, "interval", lhs_field);
|
||||||
|
writeVarianceOption(output, lhs_field);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BasicPriorStatement::writeOutputHelper(ostream &output, const string &field, const string &lhs_field) const
|
BasicPriorStatement::writeShape(ostream &output, const string &lhs_field) const
|
||||||
|
{
|
||||||
|
assert(prior_shape != eNoShape);
|
||||||
|
output << "estimation_info" << lhs_field << "(prior_indx).shape = " << prior_shape << ";" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BasicPriorStatement::writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const
|
||||||
{
|
{
|
||||||
OptionsList::num_options_t::const_iterator itn = options_list.num_options.find(field);
|
OptionsList::num_options_t::const_iterator itn = options_list.num_options.find(field);
|
||||||
if (itn != options_list.num_options.end())
|
if (itn != options_list.num_options.end())
|
||||||
|
@ -1718,10 +1732,14 @@ BasicPriorStatement::writeOutputHelper(ostream &output, const string &field, con
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BasicPriorStatement::writeShape(ostream &output, const string &lhs_field) const
|
BasicPriorStatement::writeVarianceOption(ostream &output, const string &lhs_field) const
|
||||||
{
|
{
|
||||||
assert(prior_shape != eNoShape);
|
if (variance)
|
||||||
output << "estimation_info" << lhs_field << "(prior_indx).shape = " << prior_shape << ";" << endl;
|
{
|
||||||
|
output << "estimation_info" << lhs_field << "(prior_indx).variance = ";
|
||||||
|
variance->writeOutput(output);
|
||||||
|
output << ";" << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PriorStatement::PriorStatement(const string &name_arg,
|
PriorStatement::PriorStatement(const string &name_arg,
|
||||||
|
@ -1749,19 +1767,8 @@ PriorStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
writePriorIndex(output, lhs_field);
|
writePriorIndex(output, lhs_field);
|
||||||
output << "estimation_info" << lhs_field << "_index(prior_indx) = {'" << name << "'};" << endl
|
output << "estimation_info" << lhs_field << "_index(prior_indx) = {'" << name << "'};" << endl
|
||||||
<< "estimation_info" << lhs_field <<"(prior_indx).name = '" << name << "';" << endl;
|
<< "estimation_info" << lhs_field <<"(prior_indx).name = '" << name << "';" << endl;
|
||||||
writeShape(output, lhs_field);
|
|
||||||
writeOutputHelper(output, "mean", lhs_field);
|
writeCommonOutput(output, lhs_field);
|
||||||
writeOutputHelper(output, "mode", lhs_field);
|
|
||||||
writeOutputHelper(output, "stdev", lhs_field);
|
|
||||||
writeOutputHelper(output, "shape", lhs_field);
|
|
||||||
writeOutputHelper(output, "shift", lhs_field);
|
|
||||||
writeOutputHelper(output, "date1", lhs_field);
|
|
||||||
writeOutputHelper(output, "date2", lhs_field);
|
|
||||||
writeOutputHelper(output, "domain", lhs_field);
|
|
||||||
writeOutputHelper(output, "median", lhs_field);
|
|
||||||
writeOutputHelper(output, "truncate", lhs_field);
|
|
||||||
writeOutputHelper(output, "interval", lhs_field);
|
|
||||||
writeVarianceOption(output, lhs_field);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StdPriorStatement::StdPriorStatement(const string &name_arg,
|
StdPriorStatement::StdPriorStatement(const string &name_arg,
|
||||||
|
@ -1794,17 +1801,7 @@ StdPriorStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
output << "estimation_info" << lhs_field << "_index(prior_indx) = {'" << name << "'};" << endl;
|
output << "estimation_info" << lhs_field << "_index(prior_indx) = {'" << name << "'};" << endl;
|
||||||
output << "estimation_info" << lhs_field << "(prior_indx).name = '" << name << "';" << endl;
|
output << "estimation_info" << lhs_field << "(prior_indx).name = '" << name << "';" << endl;
|
||||||
|
|
||||||
writeShape(output, lhs_field);
|
writeCommonOutput(output, lhs_field);
|
||||||
writeOutputHelper(output, "mean", lhs_field);
|
|
||||||
writeOutputHelper(output, "mode", lhs_field);
|
|
||||||
writeOutputHelper(output, "stdev", lhs_field);
|
|
||||||
writeOutputHelper(output, "shape", lhs_field);
|
|
||||||
writeOutputHelper(output, "shift", lhs_field);
|
|
||||||
writeOutputHelper(output, "domain", lhs_field);
|
|
||||||
writeOutputHelper(output, "median", lhs_field);
|
|
||||||
writeOutputHelper(output, "truncate", lhs_field);
|
|
||||||
writeOutputHelper(output, "interval", lhs_field);
|
|
||||||
writeVarianceOption(output, lhs_field);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CorrPriorStatement::CorrPriorStatement(const string &name_arg1, const string &name_arg2,
|
CorrPriorStatement::CorrPriorStatement(const string &name_arg1, const string &name_arg2,
|
||||||
|
@ -1846,17 +1843,7 @@ CorrPriorStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
output << "estimation_info" << lhs_field << "(prior_indx).name1 = '" << name << "';" << endl;
|
output << "estimation_info" << lhs_field << "(prior_indx).name1 = '" << name << "';" << endl;
|
||||||
output << "estimation_info" << lhs_field << "(prior_indx).name2 = '" << name1 << "';" << endl;
|
output << "estimation_info" << lhs_field << "(prior_indx).name2 = '" << name1 << "';" << endl;
|
||||||
|
|
||||||
writeShape(output, lhs_field);
|
writeCommonOutput(output, lhs_field);
|
||||||
writeOutputHelper(output, "mean", lhs_field);
|
|
||||||
writeOutputHelper(output, "mode", lhs_field);
|
|
||||||
writeOutputHelper(output, "stdev", lhs_field);
|
|
||||||
writeOutputHelper(output, "shape", lhs_field);
|
|
||||||
writeOutputHelper(output, "shift", lhs_field);
|
|
||||||
writeOutputHelper(output, "domain", lhs_field);
|
|
||||||
writeOutputHelper(output, "median", lhs_field);
|
|
||||||
writeOutputHelper(output, "truncate", lhs_field);
|
|
||||||
writeOutputHelper(output, "interval", lhs_field);
|
|
||||||
writeVarianceOption(output, lhs_field);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicOptionsStatement::~BasicOptionsStatement()
|
BasicOptionsStatement::~BasicOptionsStatement()
|
||||||
|
@ -1899,7 +1886,17 @@ BasicOptionsStatement::get_base_name(const SymbolType symb_type, string &lhs_fie
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BasicOptionsStatement::writeOutputHelper(ostream &output, const string &field, const string &lhs_field) const
|
BasicOptionsStatement::writeCommonOutput(ostream &output, const string &lhs_field) const
|
||||||
|
{
|
||||||
|
writeCommonOutputHelper(output, "init", lhs_field);
|
||||||
|
writeCommonOutputHelper(output, "bounds", lhs_field);
|
||||||
|
writeCommonOutputHelper(output, "jscale", lhs_field);
|
||||||
|
writeCommonOutputHelper(output, "date1", lhs_field);
|
||||||
|
writeCommonOutputHelper(output, "date2", lhs_field);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BasicOptionsStatement::writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const
|
||||||
{
|
{
|
||||||
OptionsList::num_options_t::const_iterator itn = options_list.num_options.find(field);
|
OptionsList::num_options_t::const_iterator itn = options_list.num_options.find(field);
|
||||||
if (itn != options_list.num_options.end())
|
if (itn != options_list.num_options.end())
|
||||||
|
@ -1936,11 +1933,7 @@ OptionsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
output << "estimation_info" << lhs_field <<"_index(options_indx) = {'" << name << "'};" << endl
|
output << "estimation_info" << lhs_field <<"_index(options_indx) = {'" << name << "'};" << endl
|
||||||
<< "estimation_info" << lhs_field << "(options_indx).name = '" << name << "';" << endl;
|
<< "estimation_info" << lhs_field << "(options_indx).name = '" << name << "';" << endl;
|
||||||
|
|
||||||
writeOutputHelper(output, "init", lhs_field);
|
writeCommonOutput(output, lhs_field);
|
||||||
writeOutputHelper(output, "bounds", lhs_field);
|
|
||||||
writeOutputHelper(output, "jscale", lhs_field);
|
|
||||||
writeOutputHelper(output, "date1", lhs_field);
|
|
||||||
writeOutputHelper(output, "date2", lhs_field);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StdOptionsStatement::StdOptionsStatement(const string &name_arg,
|
StdOptionsStatement::StdOptionsStatement(const string &name_arg,
|
||||||
|
@ -1971,11 +1964,7 @@ StdOptionsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
output << "estimation_info" << lhs_field << "_index(options_indx) = {'" << name << "'};" << endl;
|
output << "estimation_info" << lhs_field << "_index(options_indx) = {'" << name << "'};" << endl;
|
||||||
output << "estimation_info" << lhs_field << "(options_indx).name = '" << name << "';" << endl;
|
output << "estimation_info" << lhs_field << "(options_indx).name = '" << name << "';" << endl;
|
||||||
|
|
||||||
writeOutputHelper(output, "init", lhs_field);
|
writeCommonOutput(output, lhs_field);
|
||||||
writeOutputHelper(output, "bounds", lhs_field);
|
|
||||||
writeOutputHelper(output, "jscale", lhs_field);
|
|
||||||
writeOutputHelper(output, "date1", lhs_field);
|
|
||||||
writeOutputHelper(output, "date2", lhs_field);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CorrOptionsStatement::CorrOptionsStatement(const string &name_arg1, const string &name_arg2,
|
CorrOptionsStatement::CorrOptionsStatement(const string &name_arg1, const string &name_arg2,
|
||||||
|
@ -2015,9 +2004,5 @@ CorrOptionsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
output << "estimation_info" << lhs_field << "(options_indx).name1 = '" << name << "';" << endl;
|
output << "estimation_info" << lhs_field << "(options_indx).name1 = '" << name << "';" << endl;
|
||||||
output << "estimation_info" << lhs_field << "(options_indx).name2 = '" << name1 << "';" << endl;
|
output << "estimation_info" << lhs_field << "(options_indx).name2 = '" << name1 << "';" << endl;
|
||||||
|
|
||||||
writeOutputHelper(output, "init", lhs_field);
|
writeCommonOutput(output, lhs_field);
|
||||||
writeOutputHelper(output, "bounds", lhs_field);
|
|
||||||
writeOutputHelper(output, "jscale", lhs_field);
|
|
||||||
writeOutputHelper(output, "date1", lhs_field);
|
|
||||||
writeOutputHelper(output, "date2", lhs_field);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -597,7 +597,8 @@ protected:
|
||||||
void get_base_name(const SymbolType symb_type, string &lhs_field) const;
|
void get_base_name(const SymbolType symb_type, string &lhs_field) const;
|
||||||
void writePriorIndex(ostream &output, const string &lhs_field) const;
|
void writePriorIndex(ostream &output, const string &lhs_field) const;
|
||||||
void writeVarianceOption(ostream &output, const string &lhs_field) const;
|
void writeVarianceOption(ostream &output, const string &lhs_field) const;
|
||||||
void writeOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
|
void writeCommonOutput(ostream &output, const string &lhs_field) const;
|
||||||
|
void writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
|
||||||
void writeShape(ostream &output, const string &lhs_field) const;
|
void writeShape(ostream &output, const string &lhs_field) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -655,7 +656,8 @@ protected:
|
||||||
void get_base_name(const SymbolType symb_type, string &lhs_field) const;
|
void get_base_name(const SymbolType symb_type, string &lhs_field) const;
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||||
void writeOptionsIndex(ostream &output, const string &lhs_field) const;
|
void writeOptionsIndex(ostream &output, const string &lhs_field) const;
|
||||||
void writeOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
|
void writeCommonOutput(ostream &output, const string &lhs_field) const;
|
||||||
|
void writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OptionsStatement : public BasicOptionsStatement
|
class OptionsStatement : public BasicOptionsStatement
|
||||||
|
|
|
@ -182,7 +182,7 @@ class ParsingDriver;
|
||||||
%type <string_val> vec_value_1 vec_value signed_inf signed_number_w_inf
|
%type <string_val> vec_value_1 vec_value signed_inf signed_number_w_inf
|
||||||
%type <string_val> range vec_value_w_inf vec_value_1_w_inf
|
%type <string_val> range vec_value_w_inf vec_value_1_w_inf
|
||||||
%type <symbol_type_val> change_type_arg
|
%type <symbol_type_val> change_type_arg
|
||||||
%type <vector_string_val> change_type_var_list
|
%type <vector_string_val> change_type_var_list subsamples_eq_opt
|
||||||
%type <vector_int_val> vec_int_elem vec_int_1 vec_int vec_int_number
|
%type <vector_int_val> vec_int_elem vec_int_1 vec_int vec_int_number
|
||||||
%type <prior_distributions_val> prior_pdf prior_distribution
|
%type <prior_distributions_val> prior_pdf prior_distribution
|
||||||
%%
|
%%
|
||||||
|
@ -1213,12 +1213,36 @@ data_options : o_file
|
||||||
| o_xls_range
|
| o_xls_range
|
||||||
;
|
;
|
||||||
|
|
||||||
subsamples : symbol '.' SUBSAMPLES '(' subsamples_name_list ')' ';'
|
subsamples : subsamples_eq_opt '(' subsamples_name_list ')' ';'
|
||||||
{ driver.set_subsamples($1); }
|
{ driver.set_subsamples($1->at(0), $1->at(1)); }
|
||||||
;
|
;
|
||||||
|
|
||||||
subsamples_eq : symbol '.' SUBSAMPLES EQUAL symbol '.' SUBSAMPLES ';'
|
subsamples_eq : subsamples_eq_opt EQUAL subsamples_eq_opt ';'
|
||||||
{ driver.copy_subsamples($1, $5); }
|
{
|
||||||
|
driver.copy_subsamples($1->at(0), $1->at(1), $3->at(0), $3->at(1));
|
||||||
|
delete $1;
|
||||||
|
delete $3;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
subsamples_eq_opt : symbol '.' SUBSAMPLES
|
||||||
|
{
|
||||||
|
$$ = new vector<string *>();
|
||||||
|
$$->push_back($1);
|
||||||
|
$$->push_back(new string (""));
|
||||||
|
}
|
||||||
|
| STD '(' symbol ')' '.'SUBSAMPLES
|
||||||
|
{
|
||||||
|
$$ = new vector<string *>();
|
||||||
|
$$->push_back($3);
|
||||||
|
$$->push_back(new string (""));
|
||||||
|
}
|
||||||
|
| CORR '(' symbol COMMA symbol ')' '.' SUBSAMPLES
|
||||||
|
{
|
||||||
|
$$ = new vector<string *>();
|
||||||
|
$$->push_back($3);
|
||||||
|
$$->push_back($5);
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
subsamples_name_list : subsamples_name_list COMMA o_subsample_name
|
subsamples_name_list : subsamples_name_list COMMA o_subsample_name
|
||||||
|
@ -1229,13 +1253,23 @@ prior : symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNo
|
||||||
{ driver.set_prior($1); }
|
{ driver.set_prior($1); }
|
||||||
| symbol '.' symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
| symbol '.' symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||||
{
|
{
|
||||||
driver.add_subsample_range(new string (*$1), $3);
|
driver.add_subsample_range(new string (*$1), new string (""), $3);
|
||||||
driver.set_prior($1);
|
driver.set_prior($1);
|
||||||
}
|
}
|
||||||
| STD '(' symbol ')' '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
| STD '(' symbol ')' '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||||
{ driver.set_std_prior($3); }
|
{ driver.set_std_prior($3); }
|
||||||
| CORR '(' symbol COMMA symbol')' '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
| STD '(' symbol ')' '.' symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||||
|
{
|
||||||
|
driver.add_subsample_range(new string (*$3), new string (""), $6);
|
||||||
|
driver.set_std_prior($3);
|
||||||
|
}
|
||||||
|
| CORR '(' symbol COMMA symbol ')' '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||||
{ driver.set_corr_prior($3, $5); }
|
{ driver.set_corr_prior($3, $5); }
|
||||||
|
| CORR '(' symbol COMMA symbol ')' '.' symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||||
|
{
|
||||||
|
driver.add_subsample_range(new string (*$3), new string (*$5), $8);
|
||||||
|
driver.set_corr_prior($3, $5);
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
prior_options_list : prior_options_list COMMA prior_options
|
prior_options_list : prior_options_list COMMA prior_options
|
||||||
|
@ -1258,13 +1292,23 @@ options : symbol '.' OPTIONS '(' options_options_list ')' ';'
|
||||||
{ driver.set_options($1); }
|
{ driver.set_options($1); }
|
||||||
| symbol '.' symbol '.' OPTIONS '(' options_options_list ')' ';'
|
| symbol '.' symbol '.' OPTIONS '(' options_options_list ')' ';'
|
||||||
{
|
{
|
||||||
driver.add_subsample_range(new string (*$1), $3);
|
driver.add_subsample_range(new string (*$1), new string (""), $3);
|
||||||
driver.set_options($1);
|
driver.set_options($1);
|
||||||
}
|
}
|
||||||
| STD '(' symbol ')' '.' OPTIONS '(' options_options_list ')' ';'
|
| STD '(' symbol ')' '.' OPTIONS '(' options_options_list ')' ';'
|
||||||
{ driver.set_std_options($3); }
|
{ driver.set_std_options($3); }
|
||||||
| CORR '(' symbol COMMA symbol')' '.' OPTIONS '(' options_options_list ')' ';'
|
| STD '(' symbol ')' '.' symbol '.' OPTIONS '(' options_options_list ')' ';'
|
||||||
|
{
|
||||||
|
driver.add_subsample_range(new string (*$3), new string (""), $6);
|
||||||
|
driver.set_std_options($3);
|
||||||
|
}
|
||||||
|
| CORR '(' symbol COMMA symbol ')' '.' OPTIONS '(' options_options_list ')' ';'
|
||||||
{ driver.set_corr_options($3, $5); }
|
{ driver.set_corr_options($3, $5); }
|
||||||
|
| CORR '(' symbol COMMA symbol ')' '.' symbol '.' OPTIONS '(' options_options_list ')' ';'
|
||||||
|
{
|
||||||
|
driver.add_subsample_range(new string (*$3), new string (*$5), $8);
|
||||||
|
driver.set_corr_options($3, $5);
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
options_options_list : options_options_list COMMA options_options
|
options_options_list : options_options_list COMMA options_options
|
||||||
|
|
|
@ -248,6 +248,7 @@ string eofbuff;
|
||||||
<DYNARE_STATEMENT>relative_irf {return token::RELATIVE_IRF;}
|
<DYNARE_STATEMENT>relative_irf {return token::RELATIVE_IRF;}
|
||||||
<DYNARE_STATEMENT>tex {return token::TEX;}
|
<DYNARE_STATEMENT>tex {return token::TEX;}
|
||||||
<DYNARE_STATEMENT>nomoments {return token::NOMOMENTS;}
|
<DYNARE_STATEMENT>nomoments {return token::NOMOMENTS;}
|
||||||
|
<DYNARE_STATEMENT>std {return token::STD;}
|
||||||
<DYNARE_STATEMENT>corr {return token::CORR;}
|
<DYNARE_STATEMENT>corr {return token::CORR;}
|
||||||
<DYNARE_STATEMENT>nocorr {return token::NOCORR;}
|
<DYNARE_STATEMENT>nocorr {return token::NOCORR;}
|
||||||
<DYNARE_STATEMENT>optim {return token::OPTIM;}
|
<DYNARE_STATEMENT>optim {return token::OPTIM;}
|
||||||
|
|
|
@ -1236,30 +1236,60 @@ ParsingDriver::estimation_data()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::copy_subsamples(string *to_parameter, string *from_parameter)
|
ParsingDriver::set_subsamples(string *name1, string *name2)
|
||||||
{
|
{
|
||||||
check_symbol_is_parameter(to_parameter);
|
check_symbol_existence(*name1);
|
||||||
check_symbol_is_parameter(from_parameter);
|
if (!name2->empty())
|
||||||
if (subsample_declarations.find(*to_parameter) != subsample_declarations.end())
|
check_symbol_existence(*name2);
|
||||||
error("Parameter " + *to_parameter + " has more than one subsample statement." +
|
|
||||||
"You may only have one subsample statement per parameter.");
|
if (subsample_declarations.find(make_pair(*name1,*name2)) != subsample_declarations.end())
|
||||||
if (subsample_declarations.find(*from_parameter) == subsample_declarations.end())
|
{
|
||||||
error("Parameter " + *from_parameter + " does not have an associated subsample statement.");
|
string err = *name1;
|
||||||
subsample_declarations[*to_parameter] = subsample_declarations[*from_parameter];
|
if (!name2->empty())
|
||||||
delete to_parameter;
|
err.append(",").append(*name2);
|
||||||
delete from_parameter;
|
error(err + " has more than one subsample statement." +
|
||||||
|
"You may only have one subsample statement per variable.");
|
||||||
|
}
|
||||||
|
|
||||||
|
subsample_declarations[make_pair(*name1, *name2)] = subsample_declaration_map;
|
||||||
|
subsample_declaration_map.clear();
|
||||||
|
delete name1;
|
||||||
|
delete name2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::set_subsamples(string *name)
|
ParsingDriver::copy_subsamples(string *to_name1, string *to_name2, string *from_name1, string *from_name2)
|
||||||
{
|
{
|
||||||
check_symbol_is_parameter(name);
|
check_symbol_existence(*to_name1);
|
||||||
if (subsample_declarations.find(*name) != subsample_declarations.end())
|
check_symbol_existence(*from_name1);
|
||||||
error("Parameter " + *name + " has more than one subsample statement." +
|
if (!to_name2->empty())
|
||||||
"You may only have one subsample statement per parameter.");
|
check_symbol_existence(*to_name2);
|
||||||
subsample_declarations[*name] = subsample_declaration_map;
|
if (!from_name2->empty())
|
||||||
subsample_declaration_map.clear();
|
check_symbol_existence(*from_name2);
|
||||||
delete name;
|
|
||||||
|
if (subsample_declarations.find(make_pair(*to_name1,*to_name2)) != subsample_declarations.end())
|
||||||
|
{
|
||||||
|
string err = *to_name1;
|
||||||
|
if (!to_name2->empty())
|
||||||
|
err.append(",").append(*to_name2);
|
||||||
|
error(err + " has more than one subsample statement." +
|
||||||
|
"You may only have one subsample statement per symbol (or pair thereof).");
|
||||||
|
}
|
||||||
|
if (subsample_declarations.find(make_pair(*from_name1,*from_name2)) == subsample_declarations.end())
|
||||||
|
{
|
||||||
|
string err = *from_name1;
|
||||||
|
if (!from_name2->empty())
|
||||||
|
err.append(",").append(*from_name2);
|
||||||
|
error(err + " does not have an associated subsample statement.");
|
||||||
|
}
|
||||||
|
|
||||||
|
subsample_declarations[make_pair(*to_name1, *to_name2)] =
|
||||||
|
subsample_declarations[make_pair(*from_name1, *from_name2)];
|
||||||
|
|
||||||
|
delete to_name1;
|
||||||
|
delete to_name2;
|
||||||
|
delete from_name1;
|
||||||
|
delete from_name2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1284,19 +1314,31 @@ ParsingDriver::set_subsample_name_equal_to_date_range(string *name, string *date
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::add_subsample_range(string *parameter, string *subsample_name)
|
ParsingDriver::add_subsample_range(string *name1, string *name2, string *subsample_name)
|
||||||
{
|
{
|
||||||
check_symbol_is_parameter(parameter);
|
check_symbol_existence(*name1);
|
||||||
|
if (!name2->empty())
|
||||||
|
check_symbol_existence(*name2);
|
||||||
check_symbol_is_statement_variable(subsample_name);
|
check_symbol_is_statement_variable(subsample_name);
|
||||||
subsample_declarations_t::const_iterator it = subsample_declarations.find(*parameter);
|
|
||||||
|
subsample_declarations_t::const_iterator it = subsample_declarations.find(make_pair(*name1, *name2));
|
||||||
if (it == subsample_declarations.end())
|
if (it == subsample_declarations.end())
|
||||||
error("A subsample statement has not been issued for " + *parameter);
|
{
|
||||||
|
string err = *name1;
|
||||||
|
if (!name2->empty())
|
||||||
|
err.append(",").append(*name2);
|
||||||
|
error("A subsample statement has not been issued for " + err);
|
||||||
|
}
|
||||||
|
|
||||||
subsample_declaration_map_t tmp_map = it->second;
|
subsample_declaration_map_t tmp_map = it->second;
|
||||||
if (tmp_map.find(*subsample_name) == tmp_map.end())
|
if (tmp_map.find(*subsample_name) == tmp_map.end())
|
||||||
error("The subsample name " + *subsample_name + " was not previously declared in a subsample statement.");
|
error("The subsample name " + *subsample_name + " was not previously declared in a subsample statement.");
|
||||||
|
|
||||||
option_date("date1", tmp_map[*subsample_name].first);
|
option_date("date1", tmp_map[*subsample_name].first);
|
||||||
option_date("date2", tmp_map[*subsample_name].second);
|
option_date("date2", tmp_map[*subsample_name].second);
|
||||||
delete parameter;
|
|
||||||
|
delete name1;
|
||||||
|
delete name2;
|
||||||
delete subsample_name;
|
delete subsample_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,8 +192,8 @@ private:
|
||||||
//! Temporary storage for declaring subsamples: map<statement_local_var, <date1, date2 >
|
//! Temporary storage for declaring subsamples: map<statement_local_var, <date1, date2 >
|
||||||
typedef map<string, pair<string, string> > subsample_declaration_map_t;
|
typedef map<string, pair<string, string> > subsample_declaration_map_t;
|
||||||
subsample_declaration_map_t subsample_declaration_map;
|
subsample_declaration_map_t subsample_declaration_map;
|
||||||
//! Temporary storage for subsample statement: map<parameter, subsample_declaration_map >
|
//! Temporary storage for subsample statement: map<pair<var_name1, var_name2>>, subsample_declaration_map >
|
||||||
typedef map<string, subsample_declaration_map_t > subsample_declarations_t;
|
typedef map<pair<string, string >, subsample_declaration_map_t > subsample_declarations_t;
|
||||||
subsample_declarations_t subsample_declarations;
|
subsample_declarations_t subsample_declarations;
|
||||||
//! reset the values for temporary storage
|
//! reset the values for temporary storage
|
||||||
void reset_current_external_function_options();
|
void reset_current_external_function_options();
|
||||||
|
@ -254,13 +254,13 @@ public:
|
||||||
//! Declares a statement local variable
|
//! Declares a statement local variable
|
||||||
void declare_statement_local_variable(string *name);
|
void declare_statement_local_variable(string *name);
|
||||||
//! Completes a subsample statement
|
//! Completes a subsample statement
|
||||||
void set_subsamples(string *name);
|
void set_subsamples(string *name1, string *name2);
|
||||||
//! Declares a subsample, assigning the value to name
|
//! Declares a subsample, assigning the value to name
|
||||||
void set_subsample_name_equal_to_date_range(string *name, string *date1, string *date2);
|
void set_subsample_name_equal_to_date_range(string *name, string *date1, string *date2);
|
||||||
//! Adds a subsample range to the list of options for the prior statement
|
//! Adds a subsample range to the list of options for the prior statement
|
||||||
void add_subsample_range(string *parameter, string *subsample_name);
|
void add_subsample_range(string *name1, string *name2, string *subsample_name);
|
||||||
//! Copies the set of subsamples from_parameter to_parameter
|
//! Copies the set of subsamples from_name to_name
|
||||||
void copy_subsamples(string *to_parameter, string *from_parameter);
|
void copy_subsamples(string *to_name1, string *to_name2, string *from_name1, string *from_name2);
|
||||||
//! Declares declare_optimal_policy_discount_factor as a parameter and initializes it to exprnode
|
//! Declares declare_optimal_policy_discount_factor as a parameter and initializes it to exprnode
|
||||||
void declare_optimal_policy_discount_factor_parameter(expr_t exprnode);
|
void declare_optimal_policy_discount_factor_parameter(expr_t exprnode);
|
||||||
//! Adds a predetermined_variable
|
//! Adds a predetermined_variable
|
||||||
|
|
Loading…
Reference in New Issue