From 4d6daa46065c52bc7b2ecd4cdf32f01b66ebb6f4 Mon Sep 17 00:00:00 2001 From: Michel Juillard <michel@michel-zen3.home> Date: Sun, 8 Oct 2017 12:39:54 +0200 Subject: [PATCH] fix bug when there are constraints both on ramsey policy instrument and on other variables (cherry picked from commit b1fc34ef991ff9aff3177f2f1dcf97db7e80d8fe) --- matlab/lmmcp/get_complementarity_conditions.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/matlab/lmmcp/get_complementarity_conditions.m b/matlab/lmmcp/get_complementarity_conditions.m index fb48ece9a..cbfa01092 100644 --- a/matlab/lmmcp/get_complementarity_conditions.m +++ b/matlab/lmmcp/get_complementarity_conditions.m @@ -52,6 +52,10 @@ end etags = M.equations_tags; for i=1:size(etags,1) if strcmp(etags{i,2},'mcp') + eq_nbr = etags{i,1}; + if ramsey_policy + eq_nbr = eq_nbr + M.ramsey_eq_nbr; + end str = etags{i,3}; kop = strfind(etags{i,3},'<'); if ~isempty(kop) @@ -61,8 +65,8 @@ for i=1:size(etags,1) 'not recognized'],etags{i,3},strtrim(str(1:kop-1)))) end ub(k) = str2num(str(kop+1:end)); - eq_index(etags{i,1}) = k; - eq_index(k) = etags{i,1}; + eq_index(eq_nbr) = k; + eq_index(k) = eq_nbr; else kop = strfind(etags{i,3},'>'); if ~isempty(kop) @@ -72,8 +76,8 @@ for i=1:size(etags,1) 'not recognized'],etags{i,3},strtrim(str(1:kop-1)))) end lb(k) = str2num(str(kop+1:end)); - eq_index(etags{i,1}) = k; - eq_index(k) = etags{i,1}; + eq_index(eq_nbr) = k; + eq_index(k) = eq_nbr; else error(sprintf(['Complementarity condition %s can''t be ' ... 'parsed'],etags{i,3})) -- GitLab