Allow “learnt_in=1” for “shocks” and “endval”

In that case, the option has no effect.
fix-tolerance-parameters
Sébastien Villemot 2022-04-29 11:17:11 +02:00
parent 76a16a69a8
commit 6509bc7d36
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 14 additions and 4 deletions

View File

@ -751,8 +751,13 @@ void
ParsingDriver::end_endval_learnt_in(const string &learnt_in_period)
{
int learnt_in_period_int = stoi(learnt_in_period);
if (learnt_in_period_int < 2)
if (learnt_in_period_int < 1)
error("endval: value '" + learnt_in_period + "' is not allowed for 'learnt_in' option");
if (learnt_in_period_int == 1)
{
end_endval(false);
return;
}
for (auto [symb_id, value] : init_values)
if (mod_file->symbol_table.getType(symb_id) != SymbolType::exogenous)
error("endval(learnt_in=...): " + mod_file->symbol_table.getName(symb_id) + " is not an exogenous variable");
@ -842,9 +847,9 @@ ParsingDriver::end_shocks(bool overwrite)
covar_shocks, corr_shocks, mod_file->symbol_table));
det_shocks.clear();
if (!learnt_shocks_add.empty())
error("shocks: 'add' keyword not allowed unless 'learnt_in' option is passed");
error("shocks: 'add' keyword not allowed unless 'learnt_in' option with value >1 is passed");
if (!learnt_shocks_multiply.empty())
error("shocks: 'multiply' keyword not allowed unless 'learnt_in' option is passed");
error("shocks: 'multiply' keyword not allowed unless 'learnt_in' option with value >1 is passed");
var_shocks.clear();
std_shocks.clear();
covar_shocks.clear();
@ -877,8 +882,13 @@ void
ParsingDriver::end_shocks_learnt_in(const string &learnt_in_period, bool overwrite)
{
int learnt_in_period_int = stoi(learnt_in_period);
if (learnt_in_period_int < 2)
if (learnt_in_period_int < 1)
error("shocks: value '" + learnt_in_period + "' is not allowed for 'learnt_in' option");
if (learnt_in_period_int == 1)
{
end_shocks(overwrite);
return;
}
for (auto &[symb_id, vals] : det_shocks)
for (auto [period1, period2, expr] : vals)
if (period1 < learnt_in_period_int)