Correct logic of orig_eq_nbr

discretionary_policy_initialization.m uses

instr_nbr=M_.orig_endo_nbr-M_.orig_eq_nbr;

to check whether sufficient equations have been left out for instruments. But M_.orig_endo_nbr conforms to the originally declared endogenous variables before creating any auxiliary variables. In contrast M_.orig_eq_nbr seems to refer to the number of equations before introducing Ramsey equations, but after substituting out other auxiliaries. dyn_ramsey_static avoids that issue by checking the number of auxiliary variables introduced before the first Lagrange multiplier:

orig_endo_aux_nbr = orig_endo_nbr + min(find(aux_vars_type == 6)) - 1;

But that does not work for discretionary_policy, where such a cutoff in the auxiliaries is not defined. nkm_diagnostic_ramsey.mod