From 41a714ee2bba67d4d6532469f12d912aced983f4 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Wed, 10 Aug 2016 12:32:08 +0200
Subject: [PATCH] Move check for correct number of instruments to
 ramsey_policy.m

No reason to trigger the check in every iteration
---
 matlab/evaluate_steady_state.m | 11 -----------
 matlab/ramsey_policy.m         | 13 +++++++++++++
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/matlab/evaluate_steady_state.m b/matlab/evaluate_steady_state.m
index 136fe9776a..3b4499ba0c 100644
--- a/matlab/evaluate_steady_state.m
+++ b/matlab/evaluate_steady_state.m
@@ -54,17 +54,6 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
     end
 
     if options.ramsey_policy
-        %test whether specification matches
-        inst_nbr = size(options.instruments,1);
-        if inst_nbr~=0
-            orig_endo_aux_nbr = M.orig_endo_nbr + min(find([M.aux_vars.type] == 6)) - 1;
-            implied_inst_nbr = orig_endo_aux_nbr - M.orig_eq_nbr;
-            if inst_nbr>implied_inst_nbr
-                error('You have specified more instruments than there are omitted equations')
-            elseif inst_nbr<implied_inst_nbr
-                error('You have specified fewer instruments than there are omitted equations')
-            end
-        end
         if steadystate_flag
             % explicit steady state file
             [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, ...
diff --git a/matlab/ramsey_policy.m b/matlab/ramsey_policy.m
index 9e6523f6d2..7f932ab2eb 100644
--- a/matlab/ramsey_policy.m
+++ b/matlab/ramsey_policy.m
@@ -22,6 +22,19 @@ global options_ oo_ M_
 options_.ramsey_policy = 1;
 oldoptions = options_;
 options_.order = 1;
+
+%test whether specification matches
+inst_nbr = size(options_.instruments,1);
+if inst_nbr~=0
+    orig_endo_aux_nbr = M_.orig_endo_nbr + min(find([M_.aux_vars.type] == 6)) - 1;
+    implied_inst_nbr = orig_endo_aux_nbr - M_.orig_eq_nbr;
+    if inst_nbr>implied_inst_nbr
+        error('You have specified more instruments than there are omitted equations')
+    elseif inst_nbr<implied_inst_nbr
+        error('You have specified fewer instruments than there are omitted equations')
+    end
+end
+        
 info = stoch_simul(var_list);
 
 oo_.steady_state = oo_.dr.ys;
-- 
GitLab