Cosmetic changes.

time-shift
Stéphane Adjemian (Charybdis) 2019-10-23 16:15:14 +02:00
parent e04ccd9b01
commit 9f5f4b6981
1 changed files with 10 additions and 17 deletions

View File

@ -27,10 +27,10 @@ ny = pfm.ny;
periods = pfm.periods; periods = pfm.periods;
dynamic_model = pfm.dynamic_model; dynamic_model = pfm.dynamic_model;
lead_lag_incidence = pfm.lead_lag_incidence; lead_lag_incidence = pfm.lead_lag_incidence;
lead_lag_incidence_t = transpose(lead_lag_incidence);
nyp = pfm.nyp; nyp = pfm.nyp;
nyf = pfm.nyf; nyf = pfm.nyf;
i_cols_1 = pfm.i_cols_1; i_cols_1 = pfm.i_cols_1;
i_cols_A1 = pfm.i_cols_A1;
i_cols_j = pfm.i_cols_j; i_cols_j = pfm.i_cols_j;
i_cols_T = nonzeros(lead_lag_incidence(1:2,:)'); i_cols_T = nonzeros(lead_lag_incidence(1:2,:)');
@ -45,7 +45,7 @@ number_of_shocks = size(exo_simul,2);
if number_of_shocks>1 if number_of_shocks>1
nodes = repmat(nodes,1,number_of_shocks)*chol(pfm.Sigma); nodes = repmat(nodes,1,number_of_shocks)*chol(pfm.Sigma);
% to be fixed for Sigma ~= I % to be fixed for Sigma ~= I
for i=1:number_of_shocks for i=number_of_shocks:-1:1
rr(i) = {nodes(:,i)}; rr(i) = {nodes(:,i)};
ww(i) = {weights}; ww(i) = {weights};
end end
@ -56,16 +56,14 @@ else
nodes = nodes*sqrt(pfm.Sigma); nodes = nodes*sqrt(pfm.Sigma);
end end
innovations = zeros(periods+2,number_of_shocks);
if verbose if verbose
disp ([' -----------------------------------------------------']); disp (' -----------------------------------------------------');
disp (['MODEL SIMULATION :']); disp ('MODEL SIMULATION :');
fprintf('\n'); fprintf('\n');
end end
z = endo_simul(find(lead_lag_incidence')); z = endo_simul(lead_lag_incidence_t(:)>0);
[d1,jacobian] = dynamic_model(z,exo_simul,params,steady_state,2); [~, jacobian] = dynamic_model(z, exo_simul, params,steady_state, 2);
% Each column of Y represents a different world % Each column of Y represents a different world
% The upper right cells are unused % The upper right cells are unused
@ -92,7 +90,6 @@ else
n1 = ny+1; n1 = ny+1;
n2 = 2*ny; n2 = 2*ny;
for i=2:periods for i=2:periods
k = n1:n2;
for j=1:nnodes^min(i-1,order) for j=1:nnodes^min(i-1,order)
i_upd_r(i1:i2) = (n1:n2)+(j-1)*ny*periods; i_upd_r(i1:i2) = (n1:n2)+(j-1)*ny*periods;
i_upd_y(i1:i2) = (n1:n2)+ny+(j-1)*ny*(periods+2); i_upd_y(i1:i2) = (n1:n2)+ny+(j-1)*ny*(periods+2);
@ -115,7 +112,6 @@ else
end end
h1 = clock; h1 = clock;
for iter = 1:maxit for iter = 1:maxit
h2 = clock;
A1 = sparse([],[],[],ny*(sum(nnodes.^(0:order-1),2)+1),dimension,(order+1)*world_nbr*nnz(jacobian)); A1 = sparse([],[],[],ny*(sum(nnodes.^(0:order-1),2)+1),dimension,(order+1)*world_nbr*nnz(jacobian));
res = zeros(ny,periods,world_nbr); res = zeros(ny,periods,world_nbr);
i_rows = 1:ny; i_rows = 1:ny;
@ -123,7 +119,6 @@ for iter = 1:maxit
i_cols_p = i_cols(1:nyp); i_cols_p = i_cols(1:nyp);
i_cols_s = i_cols(nyp+(1:ny)); i_cols_s = i_cols(nyp+(1:ny));
i_cols_f = i_cols(nyp+ny+(1:nyf)); i_cols_f = i_cols(nyp+ny+(1:nyf));
i_cols_A = i_cols;
i_cols_Ap = i_cols_p; i_cols_Ap = i_cols_p;
i_cols_As = i_cols_s; i_cols_As = i_cols_s;
i_cols_Af = i_cols_f - ny; i_cols_Af = i_cols_f - ny;
@ -212,13 +207,11 @@ for iter = 1:maxit
fprintf('\n') ; fprintf('\n') ;
disp([' Total time of simulation :' num2str(etime(clock,h1))]) ; disp([' Total time of simulation :' num2str(etime(clock,h1))]) ;
fprintf('\n') ; fprintf('\n') ;
disp([' Convergency obtained.']) ; disp(' Convergency obtained.') ;
fprintf('\n') ; fprintf('\n') ;
end end
flag = 0;% Convergency obtained. flag = 0;% Convergency obtained.
endo_simul = reshape(Y(:,1),ny,periods+2);%Y(ny+(1:ny),1); endo_simul = reshape(Y(:,1),ny,periods+2);
% figure;plot(Y(16:ny:(periods+2)*ny,:))
% pause
break break
end end
A2 = [nzA{:}]'; A2 = [nzA{:}]';
@ -232,12 +225,12 @@ if ~stop
fprintf('\n') ; fprintf('\n') ;
disp([' Total time of simulation :' num2str(etime(clock,h1))]) ; disp([' Total time of simulation :' num2str(etime(clock,h1))]) ;
fprintf('\n') ; fprintf('\n') ;
disp(['WARNING : maximum number of iterations is reached (modify options_.simul.maxit).']) ; disp('WARNING : maximum number of iterations is reached (modify options_.simul.maxit).') ;
fprintf('\n') ; fprintf('\n') ;
end end
flag = 1;% more iterations are needed. flag = 1;% more iterations are needed.
endo_simul = 1; endo_simul = 1;
end end
if verbose if verbose
disp (['-----------------------------------------------------']) ; disp ('-----------------------------------------------------') ;
end end