Merge pull request #384 from JohannesPfeifer/master

Remove mexErrorCheck from k_order_pert to make it obey the noprint-option
time-shift
Sébastien Villemot 2013-05-03 02:37:25 -07:00
commit 67e245934f
6 changed files with 29 additions and 25 deletions

View File

@ -180,7 +180,7 @@ if ~isequal(DynareOptions.mode_compute,1) && any(xparam1<BayesInfo.lb)
k = find(xparam1<BayesInfo.lb); k = find(xparam1<BayesInfo.lb);
fval = objective_function_penalty_base+sum((BayesInfo.lb(k)-xparam1(k)).^2); fval = objective_function_penalty_base+sum((BayesInfo.lb(k)-xparam1(k)).^2);
exit_flag = 0; exit_flag = 0;
info = [41 k']; info = 41;
if analytic_derivation, if analytic_derivation,
DLIK=ones(length(xparam1),1); DLIK=ones(length(xparam1),1);
end end
@ -192,7 +192,7 @@ if ~isequal(DynareOptions.mode_compute,1) && any(xparam1>BayesInfo.ub)
k = find(xparam1>BayesInfo.ub); k = find(xparam1>BayesInfo.ub);
fval = objective_function_penalty_base+sum((xparam1(k)-BayesInfo.ub(k)).^2); fval = objective_function_penalty_base+sum((xparam1(k)-BayesInfo.ub(k)).^2);
exit_flag = 0; exit_flag = 0;
info = [42 k']; info = 42;
if analytic_derivation, if analytic_derivation,
DLIK=ones(length(xparam1),1); DLIK=ones(length(xparam1),1);
end end

View File

@ -1,7 +1,7 @@
function [dr,info] = k_order_pert(dr,M,options,oo) function [dr,info] = k_order_pert(dr,M,options)
% Compute decision rules using the k-order DLL from Dynare++ % Compute decision rules using the k-order DLL from Dynare++
% Copyright (C) 2009-2012 Dynare Team % Copyright (C) 2009-2013 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -30,11 +30,17 @@ nspred = M.nspred;
switch(order) switch(order)
case 1 case 1
[err, g_1] = k_order_perturbation(dr,M,options); [err, g_1] = k_order_perturbation(dr,M,options);
mexErrCheck('k_order_perturbation', err); if err
info(1)=9;
return;
end
dr.g_1 = g_1; dr.g_1 = g_1;
case 2 case 2
[err, g_0, g_1, g_2] = k_order_perturbation(dr,M,options); [err, g_0, g_1, g_2] = k_order_perturbation(dr,M,options);
mexErrCheck('k_order_perturbation', err); if err
info(1)=9;
return;
end
dr.g_0 = g_0; dr.g_0 = g_0;
dr.g_1 = g_1; dr.g_1 = g_1;
dr.g_2 = g_2; dr.g_2 = g_2;
@ -42,6 +48,10 @@ switch(order)
if options.pruning if options.pruning
[err, g_0, g_1, g_2, g_3, derivs] = k_order_perturbation(dr, ... [err, g_0, g_1, g_2, g_3, derivs] = k_order_perturbation(dr, ...
M,options); M,options);
if err
info(1)=9;
return;
end
dr.ghx = derivs.gy; dr.ghx = derivs.gy;
dr.ghu = derivs.gu; dr.ghu = derivs.gu;
dr.ghxx = unfold2(derivs.gyy,nspred); dr.ghxx = unfold2(derivs.gyy,nspred);
@ -57,8 +67,11 @@ switch(order)
else else
[err, g_0, g_1, g_2, g_3] = k_order_perturbation(dr, ... [err, g_0, g_1, g_2, g_3] = k_order_perturbation(dr, ...
M,options); M,options);
if err
info(1)=9;
return;
end
end end
mexErrCheck('k_order_perturbation', err);
dr.g_0 = g_0; dr.g_0 = g_0;
dr.g_1 = g_1; dr.g_1 = g_1;
dr.g_2 = g_2; dr.g_2 = g_2;

View File

@ -145,7 +145,7 @@ if (DynareOptions.mode_compute~=1) && any(xparam1<BayesInfo.lb)
k = find(xparam1(:) < BayesInfo.lb); k = find(xparam1(:) < BayesInfo.lb);
fval = objective_function_penalty_base+sum((BayesInfo.lb(k)-xparam1(k)).^2); fval = objective_function_penalty_base+sum((BayesInfo.lb(k)-xparam1(k)).^2);
exit_flag = 0; exit_flag = 0;
info = [41 k']; info = 41;
return return
end end
@ -154,7 +154,7 @@ if (DynareOptions.mode_compute~=1) && any(xparam1>BayesInfo.ub)
k = find(xparam1(:)>BayesInfo.ub); k = find(xparam1(:)>BayesInfo.ub);
fval = objective_function_penalty_base+sum((xparam1(k)-BayesInfo.ub(k)).^2); fval = objective_function_penalty_base+sum((xparam1(k)-BayesInfo.ub(k)).^2);
exit_flag = 0; exit_flag = 0;
info = [42 k']; info = 42;
return return
end end

View File

@ -48,7 +48,7 @@ for indPC=1:length(Parallel),
end end
if ischar(NamFileInput0), if ischar(NamFileInput0),
for j=1:size(NamFileInput0,1), for j=1:size(NamFileInput0,1),
NamFile(j,:)={pwd filesep,deblank(NamFileInput0(j,:))}; NamFile(j,:)={['./'],deblank(NamFileInput0(j,:))};
end end
NamFileInput = NamFile; NamFileInput = NamFile;
end end

View File

@ -63,7 +63,8 @@ if ~noprint
else else
error(['The Jacobian contains NaNs']) error(['The Jacobian contains NaNs'])
end end
case 9
error(['k_order_pert was unable to compute the solution'])
case 19 case 19
error('The steadystate file did not compute the steady state') error('The steadystate file did not compute the steady state')
case 20 case 20
@ -83,19 +84,9 @@ if ~noprint
case 30 case 30
error('Variance can''t be computed') error('Variance can''t be computed')
case 41 case 41
global bayestopt_; error('one (many) parameter(s) do(es) not satisfy the lower bound');
disp_string=deblank(bayestopt_.name{info(2),1});
for ii=1:length(info)-2
disp_string=[disp_string,', ',deblank(bayestopt_.name{info(2+ii),:})];
end
error(['The following parameter(s) do(es) not satisfy the lower bound: ' disp_string]);
case 42 case 42
global bayestopt_; error('one (many) parameter(s) do(es) not satisfy the upper bound');
disp_string=deblank(bayestopt_.name{info(2),1});
for ii=1:length(info)-2
disp_string=[disp_string,', ',deblank(bayestopt_.name{info(2+ii),:})];
end
error(['The following parameter(s) do(es) not satisfy the upper bound: ' disp_string]);
case 43 case 43
error('Covariance matrix of structural shocks is not positive definite') error('Covariance matrix of structural shocks is not positive definite')
case 44 %DsgeLikelihood_hh / dsge_likelihood case 44 %DsgeLikelihood_hh / dsge_likelihood

View File

@ -21,7 +21,7 @@ function [dr,info] = stochastic_solvers(dr,task,M_,options_,oo_)
% indeterminacy. % indeterminacy.
% info=5: BK rank condition not satisfied. % info=5: BK rank condition not satisfied.
% info=6: The jacobian matrix evaluated at the steady state is complex. % info=6: The jacobian matrix evaluated at the steady state is complex.
% % info=9: k_order_pert was unable to compute the solution
% ALGORITHM % ALGORITHM
% ... % ...
% %
@ -62,7 +62,7 @@ if options_.k_order_solver;
options_,oo_); options_,oo_);
else else
dr = set_state_space(dr,M_,options_); dr = set_state_space(dr,M_,options_);
[dr,info] = k_order_pert(dr,M_,options_,oo_); [dr,info] = k_order_pert(dr,M_,options_);
end end
return; return;
end end