diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index 9e890aa0398d073440c012149cc68503907ab9f8..4198b2d7586820b3e9a6b9b19ce56beb848ffddf 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -487,6 +487,10 @@ void ParsingDriver::add_stderr_shock(string *var, NodeID value) { check_symbol_existence(*var); + + if (mod_file->symbol_table.getType(*var) != eExogenous) + error("shocks: stderr can only be set for an exogenous variable"); + if (var_shocks.find(*var) != var_shocks.end() || std_shocks.find(*var) != std_shocks.end()) error("shocks: variance or stderr of shock on " + *var + " declared twice"); @@ -500,6 +504,10 @@ void ParsingDriver::add_var_shock(string *var, NodeID value) { check_symbol_existence(*var); + + if (mod_file->symbol_table.getType(*var) != eExogenous) + error("shocks: variance can only be set for an exogenous variable"); + if (var_shocks.find(*var) != var_shocks.end() || std_shocks.find(*var) != std_shocks.end()) error("shocks: variance or stderr of shock on " + *var + " declared twice"); @@ -515,6 +523,10 @@ ParsingDriver::add_covar_shock(string *var1, string *var2, NodeID value) check_symbol_existence(*var1); check_symbol_existence(*var2); + if (mod_file->symbol_table.getType(*var1) != eExogenous + || mod_file->symbol_table.getType(*var2) != eExogenous) + error("shocks: covariance can only be set for exogenous variables"); + pair<string, string> key(*var1, *var2), key_inv(*var2, *var1); if (covar_shocks.find(key) != covar_shocks.end() @@ -536,6 +548,10 @@ ParsingDriver::add_correl_shock(string *var1, string *var2, NodeID value) check_symbol_existence(*var1); check_symbol_existence(*var2); + if (mod_file->symbol_table.getType(*var1) != eExogenous + || mod_file->symbol_table.getType(*var2) != eExogenous) + error("shocks: correlation can only be set for exogenous variables"); + pair<string, string> key(*var1, *var2), key_inv(*var2, *var1); if (covar_shocks.find(key) != covar_shocks.end()