New option “overwrite” to “estimated_params” block
This option provides the same behaviour as before the change in
60ef6bbdbd
.
It is typically useful when doing several estimations in the same .mod file.
pac-components
parent
5ffbc5bad3
commit
ea44aa19d6
|
@ -1320,8 +1320,10 @@ AbstractEstimatedParamsStatement::commonCheckPass() const
|
|||
}
|
||||
|
||||
EstimatedParamsStatement::EstimatedParamsStatement(vector<EstimationParams> estim_params_list_arg,
|
||||
const SymbolTable &symbol_table_arg) :
|
||||
AbstractEstimatedParamsStatement(move(estim_params_list_arg), symbol_table_arg)
|
||||
const SymbolTable &symbol_table_arg,
|
||||
bool overwrite_arg) :
|
||||
AbstractEstimatedParamsStatement(move(estim_params_list_arg), symbol_table_arg),
|
||||
overwrite{overwrite_arg}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1361,15 +1363,19 @@ EstimatedParamsStatement::checkPass(ModFileStructure &mod_file_struct, WarningCo
|
|||
void
|
||||
EstimatedParamsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||
{
|
||||
/* Multiple estimated_params statements are allowed, so make sure we don’t
|
||||
overwrite previous ones. */
|
||||
output << "if isempty(estim_params_)" << endl
|
||||
<< " estim_params_.var_exo = zeros(0, 10);" << endl
|
||||
<< " estim_params_.var_endo = zeros(0, 10);" << endl
|
||||
<< " estim_params_.corrx = zeros(0, 11);" << endl
|
||||
<< " estim_params_.corrn = zeros(0, 11);" << endl
|
||||
<< " estim_params_.param_vals = zeros(0, 10);" << endl
|
||||
<< "end" << endl;
|
||||
string indent;
|
||||
if (!overwrite)
|
||||
{
|
||||
output << "if isempty(estim_params_)" << endl;
|
||||
indent = " ";
|
||||
}
|
||||
output << indent << "estim_params_.var_exo = zeros(0, 10);" << endl
|
||||
<< indent << "estim_params_.var_endo = zeros(0, 10);" << endl
|
||||
<< indent << "estim_params_.corrx = zeros(0, 11);" << endl
|
||||
<< indent << "estim_params_.corrn = zeros(0, 11);" << endl
|
||||
<< indent << "estim_params_.param_vals = zeros(0, 10);" << endl;
|
||||
if (!overwrite)
|
||||
output << "end" << endl;
|
||||
|
||||
for (const auto &it : estim_params_list)
|
||||
{
|
||||
|
|
|
@ -504,9 +504,12 @@ protected:
|
|||
|
||||
class EstimatedParamsStatement : public AbstractEstimatedParamsStatement
|
||||
{
|
||||
private:
|
||||
const bool overwrite;
|
||||
public:
|
||||
EstimatedParamsStatement(vector<EstimationParams> estim_params_list_arg,
|
||||
const SymbolTable &symbol_table_arg);
|
||||
const SymbolTable &symbol_table_arg,
|
||||
bool overwrite_arg);
|
||||
string blockName() const override { return "estimated_params"; };
|
||||
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
|
||||
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
|
||||
|
|
|
@ -1738,7 +1738,11 @@ boolean : TRUE
|
|||
| FALSE
|
||||
;
|
||||
|
||||
estimated_params : ESTIMATED_PARAMS ';' estimated_list END ';' { driver.estimated_params(); };
|
||||
estimated_params : ESTIMATED_PARAMS ';' estimated_list END ';'
|
||||
{ driver.estimated_params(false); }
|
||||
| ESTIMATED_PARAMS '(' OVERWRITE ')' ';' estimated_list END ';'
|
||||
{ driver.estimated_params(true); }
|
||||
;
|
||||
|
||||
estimated_list : estimated_list estimated_elem
|
||||
{ driver.add_estimated_params_element(); }
|
||||
|
|
|
@ -1469,9 +1469,9 @@ ParsingDriver::add_estimated_params_element()
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::estimated_params()
|
||||
ParsingDriver::estimated_params(bool overwrite)
|
||||
{
|
||||
mod_file->addStatement(make_unique<EstimatedParamsStatement>(estim_params_list, mod_file->symbol_table));
|
||||
mod_file->addStatement(make_unique<EstimatedParamsStatement>(estim_params_list, mod_file->symbol_table, overwrite));
|
||||
estim_params_list.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -507,7 +507,7 @@ public:
|
|||
//! Writes model_info command
|
||||
void model_info();
|
||||
//! Writes estimated params command
|
||||
void estimated_params();
|
||||
void estimated_params(bool overwrite);
|
||||
//! Writes estimated params init command
|
||||
void estimated_params_init(bool use_calibration = false);
|
||||
//! Writes estimated params bound command
|
||||
|
|
Loading…
Reference in New Issue