evaluate_static_model.m: fix the block without bytecode case
The routine would not put elements at the right place in the residuals vector (it would use variable indices instead of equation indices). Also change the routine so that it computes a residual on evaluated equations (instead of systematically returning zero for those). Finally, simplify resid.m by calling this routine instead of embedding a similar code. Ref. #1823pac-components
parent
0bbf9f2d82
commit
4b76d76175
|
@ -53,18 +53,13 @@ else
|
|||
residuals = zeros(M.endo_nbr,1);
|
||||
T = NaN(M.block_structure_stat.tmp_nbr, 1);
|
||||
for b = 1:length(M.block_structure_stat.block)
|
||||
mfsb = M.block_structure_stat.block(b).variable;
|
||||
% blocks that can be directly evaluated (mfsb is empty)
|
||||
% have zero residuals by construction
|
||||
if M.block_structure_stat.block(b).Simulation_Type ~= 1 && ...
|
||||
M.block_structure_stat.block(b).Simulation_Type ~= 2
|
||||
[r, ~, T] = feval(fh_static,b,ys,exo_ss,params,T);
|
||||
residuals(mfsb) = r;
|
||||
else
|
||||
%need to evaluate the recursive blocks to compute the
|
||||
%temporary terms
|
||||
[~, ~, T] = feval(fh_static,b,ys,exo_ss,params,T);
|
||||
[r, yy, T] = feval(fh_static,b,ys,exo_ss,params,T);
|
||||
if M.block_structure_stat.block(b).Simulation_Type == 1 || ... % evaluateForward
|
||||
M.block_structure_stat.block(b).Simulation_Type == 2 % evaluateBackward
|
||||
vidx = M.block_structure_stat.block(b).variable;
|
||||
r = yy(vidx) - ys(vidx);
|
||||
end
|
||||
residuals(M.block_structure_stat.block(b).equation) = r;
|
||||
end
|
||||
if nargout==3
|
||||
jacob=NaN(length(ys));
|
||||
|
|
|
@ -67,31 +67,9 @@ if options_.steadystate_flag
|
|||
end
|
||||
|
||||
% Compute the residuals
|
||||
if options_.block && ~options_.bytecode
|
||||
z = zeros(M_.endo_nbr,1);
|
||||
T = NaN(M_.block_structure_stat.tmp_nbr, 1);
|
||||
for i = 1:length(M_.block_structure_stat.block)
|
||||
[r, yy, T, g] = feval([M_.fname '.static'],...
|
||||
i,...
|
||||
oo_.steady_state,...
|
||||
[oo_.exo_steady_state; ...
|
||||
oo_.exo_det_steady_state], M_.params, T);
|
||||
if M_.block_structure_stat.block(i).Simulation_Type == 1 || ... % evaluateForward
|
||||
M_.block_structure_stat.block(i).Simulation_Type == 2 % evaluateBackward
|
||||
vidx = M_.block_structure_stat.block(i).variable;
|
||||
r = yy(vidx) - oo_.steady_state(vidx);
|
||||
end
|
||||
idx = M_.block_structure_stat.block(i).equation;
|
||||
z(idx) = r;
|
||||
end
|
||||
elseif options_.bytecode
|
||||
z = bytecode('evaluate','static');
|
||||
else
|
||||
z = feval([M_.fname '.static'],...
|
||||
oo_.steady_state,...
|
||||
[oo_.exo_steady_state; ...
|
||||
oo_.exo_det_steady_state], M_.params);
|
||||
end
|
||||
z = evaluate_static_model(oo_.steady_state, [oo_.exo_steady_state; ...
|
||||
oo_.exo_det_steady_state], ...
|
||||
M_.params, M_, options_);
|
||||
|
||||
M_.Sigma_e = Sigma_e;
|
||||
|
||||
|
@ -123,4 +101,4 @@ if nargout == 0
|
|||
skipline(2)
|
||||
end
|
||||
|
||||
oo_.steady_state = steady_state_old;
|
||||
oo_.steady_state = steady_state_old;
|
||||
|
|
Loading…
Reference in New Issue