Perfect foresight: remove unused nnzJ argument in several stacked problem functions

time-shift
Sébastien Villemot 2019-05-07 18:31:47 +02:00
parent 088826a332
commit 5a36d57b90
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
7 changed files with 18 additions and 23 deletions

View File

@ -1,6 +1,6 @@
function [residuals,JJacobian] = linear_perfect_foresight_problem(y, dynamicjacobian, Y0, YT, ...
exo_simul, params, steady_state, maximum_lag, T, ny, i_cols, ...
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, i_cols_0, i_cols_J0, nnzJ, jendo, jexog)
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, i_cols_0, i_cols_J0, jendo, jexog)
% Computes the residuals and the Jacobian matrix for a linear perfect foresight problem over T periods.
%
@ -76,4 +76,4 @@ end
if nargout == 2
iJacobian = cat(1,iJacobian{:});
JJacobian = sparse(iJacobian(:,1), iJacobian(:,2), iJacobian(:,3), T*ny, T*ny);
end
end

View File

@ -2,12 +2,12 @@ function [residuals,JJacobian] = perfect_foresight_mcp_problem(y, dynamic_functi
exo_simul, params, steady_state, ...
maximum_lag, T, ny, i_cols, ...
i_cols_J1, i_cols_1, i_cols_T, ...
i_cols_j, i_cols_0,i_cols_J0, nnzJ,eq_index)
i_cols_j, i_cols_0,i_cols_J0, eq_index)
% function [residuals,JJacobian] = perfect_foresight_mcp_problem(y, dynamic_function, Y0, YT, ...
% exo_simul, params, steady_state, ...
% maximum_lag, T, ny, i_cols, ...
% i_cols_J1, i_cols_1, i_cols_T, ...
% i_cols_j,nnzJ,eq_index)
% i_cols_j,eq_index)
% Computes the residuals and the Jacobian matrix for a perfect foresight problem over T periods
% in a mixed complementarity problem context
%
@ -33,7 +33,6 @@ function [residuals,JJacobian] = perfect_foresight_mcp_problem(y, dynamic_functi
% variables (relevant in last period)
% i_cols_j [double] indices of variables in M.lead_lag_incidence
% in dynamic Jacobian (relevant in intermediate periods)
% nnzJ [scalar] number of non-zero elements in Jacobian
% eq_index [double] N*1 array, index vector describing residual mapping resulting
% from complementarity setup
% OUTPUTS
@ -45,7 +44,7 @@ function [residuals,JJacobian] = perfect_foresight_mcp_problem(y, dynamic_functi
% SPECIAL REQUIREMENTS
% None.
% Copyright (C) 1996-2017 Dynare Team
% Copyright (C) 1996-2019 Dynare Team
%
% This file is part of Dynare.
%
@ -106,4 +105,4 @@ end
if nargout == 2
iJacobian = cat(1,iJacobian{:});
JJacobian = sparse(iJacobian(:,1),iJacobian(:,2),iJacobian(:,3),T*ny,T*ny);
end
end

View File

@ -2,7 +2,7 @@ function [residuals,JJacobian] = perfect_foresight_problem(y, dynamic_function,
exo_simul, params, steady_state, ...
maximum_lag, T, ny, i_cols, ...
i_cols_J1, i_cols_1, i_cols_T, ...
i_cols_j, i_cols_0, i_cols_J0, nnzJ)
i_cols_j, i_cols_0, i_cols_J0)
% Computes the residuals and the Jacobian matrix for a perfect foresight problem over T periods.
%
@ -31,7 +31,6 @@ function [residuals,JJacobian] = perfect_foresight_problem(y, dynamic_function,
% - i_cols_0 [double] indices of contemporaneous variables in M.lead_lag_incidence in dynamic
% Jacobian (relevant in problems with periods=1)
% - i_cols_J0 [double] indices of contemporaneous variables appearing in M.lead_lag_incidence (relevant in problems with periods=1)
% - nnzJ [scalar] number of non-zero elements in Jacobian
%
% OUTPUTS
% - residuals [double] (N*T)*1 array, residuals of the stacked problem
@ -100,4 +99,4 @@ end
if nargout == 2
iJacobian = cat(1,iJacobian{:});
JJacobian = sparse(iJacobian(:,1), iJacobian(:,2), iJacobian(:,3), T*ny, T*ny);
end
end

View File

@ -12,7 +12,7 @@ function perfect_foresight_solver()
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 1996-2018 Dynare Team
% Copyright (C) 1996-2019 Dynare Team
%
% This file is part of Dynare.
%
@ -195,8 +195,7 @@ if ~isreal(oo_.endo_simul(:)) % can only happen without bytecode
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
oo_.exo_simul,M_.params,oo_.steady_state, ...
M_.maximum_lag, periods, M_.endo_nbr, i_cols, ...
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, i_cols_0, i_cols_J0, ...
M_.NNZDerivatives(1));
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, i_cols_0, i_cols_J0);
if max(abs(residuals))< options_.dynatol.f
oo_.deterministic_simulation.status = 1;
oo_.endo_simul=real(oo_.endo_simul);
@ -223,4 +222,4 @@ else
end
ts = dseries(transpose(oo_.endo_simul), initial_period, M_.endo_names);
assignin('base', 'Simulated_time_series', ts);
assignin('base', 'Simulated_time_series', ts);

View File

@ -144,8 +144,7 @@ if nargout>1
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
oo_.exo_simul,M_.params,oo_.steady_state, ...
M_.maximum_lag, periods,M_.endo_nbr,i_cols, ...
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, i_cols_0, i_cols_J0, ...
M_.NNZDerivatives(1));
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, i_cols_0, i_cols_J0);
end
maxerror = max(max(abs(residuals)));
end

View File

@ -1,6 +1,6 @@
function [endogenousvariables, info] = solve_stacked_linear_problem(endogenousvariables, exogenousvariables, steadystate_y, steadystate_x, M, options)
% Copyright (C) 2015-2017 Dynare Team
% Copyright (C) 2015-2019 Dynare Team
%
% This file is part of Dynare.
%
@ -46,7 +46,7 @@ x = bsxfun(@minus, exogenousvariables, steadystate_x');
x, M.params, steadystate_y, ...
M.maximum_lag, options.periods, M.endo_nbr, i_cols, ...
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, i_cols_0, i_cols_J0, ...
M.NNZDerivatives(1), jendo, jexog);
jendo, jexog);
if all(imag(y)<.1*options.dynatol.x)
if ~isreal(y)
@ -62,4 +62,4 @@ if check
info.status = false;
else
info.status = true;
end
end

View File

@ -51,14 +51,13 @@ if (options.solve_algo == 10 || options.solve_algo == 11)% mixed complementarity
exogenousvariables, M.params, steadystate, ...
M.maximum_lag, options.periods, M.endo_nbr, i_cols, ...
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, i_cols_0, i_cols_J0, ...
M.NNZDerivatives(1),eq_index);
eq_index);
else
[y, check] = dynare_solve(@perfect_foresight_problem,z(:),options, ...
dynamicmodel, y0, yT, ...
exogenousvariables, M.params, steadystate, ...
M.maximum_lag, options.periods, M.endo_nbr, i_cols, ...
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, i_cols_0, i_cols_J0, ...
M.NNZDerivatives(1));
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, i_cols_0, i_cols_J0);
end
if all(imag(y)<.1*options.dynatol.x)
@ -75,4 +74,4 @@ if check
info.status = false;
else
info.status = true;
end
end