Commit bc83fbd8 authored by stepan's avatar stepan
Browse files

* Allow the use of a *_steadystate.m file with options block and bytecode.

* Added the possibility to use resid when the the options block *and* bytecode
are used.

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2986 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 033c321b
......@@ -29,43 +29,47 @@ function resid(period)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global M_ options_ oo_ it_ z
if M_.exo_nbr > 0
oo_.exo_simul = ones(M_.maximum_lag+M_.maximum_lead+period,1)* ...
oo_.exo_steady_state';
end
n = size(M_.lead_lag_incidence,2);
% if ~ options_.initval_file | size(oo_.endo_simul,2) ~= period+M_.maximum_lag+M_.maximum_lead
if ~ options_.initval_file
if size(oo_.steady_state,1) == 1 & oo_.steady_state == 0
oo_.steady_state = zeros(size(oo_.steady_state,1),1) ;
end
oo_.endo_simul = oo_.steady_state*ones(1,period+M_.maximum_lag+M_.maximum_lead) ;
end
i = M_.lead_lag_incidence';
iyr0 = find(i(:));
y =oo_.endo_simul(:);
z = zeros(n,period);
fh = str2func([M_.fname '_dynamic']);
for it_=M_.maximum_lag+1:period+M_.maximum_lag
z(:,it_-M_.maximum_lag) = feval(fh,y(iyr0),oo_.exo_simul, M_.params, it_);
iyr0 = iyr0 + n;
if options_.block && ~options_.bytecode
error('CHECK: incompatibility with "block" without "bytecode" option')
elseif options_.block && options_.bytecode
[z,check] = bytecode('evaluate','static');
else
if M_.exo_nbr > 0
oo_.exo_simul = ones(M_.maximum_lag+M_.maximum_lead+period,1)* ...
oo_.exo_steady_state';
end
n = size(M_.lead_lag_incidence,2);
% if ~ options_.initval_file | size(oo_.endo_simul,2) ~= period+M_.maximum_lag+M_.maximum_lead
if ~ options_.initval_file
if size(oo_.steady_state,1) == 1 & oo_.steady_state == 0
oo_.steady_state = zeros(size(oo_.steady_state,1),1) ;
end
oo_.endo_simul = oo_.steady_state*ones(1,period+M_.maximum_lag+M_.maximum_lead) ;
end
i = M_.lead_lag_incidence';
iyr0 = find(i(:));
y =oo_.endo_simul(:);
z = zeros(n,period);
fh = str2func([M_.fname '_dynamic']);
for it_=M_.maximum_lag+1:period+M_.maximum_lag
z(:,it_-M_.maximum_lag) = feval(fh,y(iyr0),oo_.exo_simul, M_.params, it_);
iyr0 = iyr0 + n;
end
end
for i = 1:4
disp(' ')
disp(' ')
end
for i=1:length(z)
if abs(z(i)) < options_.dynatol/100
tmp = 0;
else
tmp = z(i);
end
disp(['Residual for equation number ' int2str(i) ' is equal to ' num2str(tmp)])
end
if abs(z(i)) < options_.dynatol/100
tmp = 0;
else
tmp = z(i);
end
disp(['Residual for equation number ' int2str(i) ' is equal to ' num2str(tmp)])
end
for i = 1:2
disp(' ')
disp(' ')
end
\ No newline at end of file
......@@ -28,7 +28,7 @@ function steady_()
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global M_ oo_ it_ options_
if options_.bytecode && options_.solve_algo ~= 5
error('STEADY: for the moment, you must use solve_algo=5 with bytecode option')
end
......@@ -38,24 +38,47 @@ function steady_()
if options_.steadystate_flag
[oo_.steady_state,check] = feval([M_.fname '_steadystate'],...
oo_.steady_state,...
[oo_.exo_steady_state; ...
oo_.exo_det_steady_state]);
% Check if the steady state obtained from the _steadystate file is a
% steady state.
oo_.steady_state,...
[oo_.exo_steady_state; ...
oo_.exo_det_steady_state]);
% Check if the steady state obtained from the _steadystate file is a steady state.
check1 = 0;
if isfield(options_,'unit_root_vars')
if isempty(options_.unit_root_vars)
check1 = max(abs(feval([M_.fname '_static'],...
oo_.steady_state,...
[oo_.exo_steady_state; ...
oo_.exo_det_steady_state], M_.params))) > options_.dynatol ;
if check1
if isempty(options_.unit_root_vars)
if options_.block && ~options_.bytecode
check2 = zeros(size(M_.blocksMFS,1),1);
for b = 1:size(M_.blocksMFS,1)
n = size(M_.blocksMFS{b}, 1);
ss = oo_.steady_state;
if n
check2(b) = max(abs(feval([M_.fname '_static'], b, ss, ...
[oo_.exo_steady_state; oo_.exo_det_steady_state], M_.params))) > options_.dynatol;
else
[r, g1, ssss] = feval([M_.fname '_static'], b, ss, ...
[oo_.exo_steady_state; oo_.exo_det_steady_state], M_.params);
end
end
check1 = any(check2);
idx = find(abs(ssss-oo_.steady_state)>10*options_.dynatol);
if ~isempty(idx)
check1 = 1;
end
elseif options_.block && options_.bytecode
residuals = bytecode('evaluate','static');
check1 = 1;
else
check1 = 0;
check1 = max(abs(feval([M_.fname '_static'],...
oo_.steady_state,...
[oo_.exo_steady_state; ...
oo_.exo_det_steady_state], M_.params))) > options_.dynatol ;
end
end
if check1
if ~options_.block && ~options_.bytecode
resid(1);
error(['The seadystate values returned by ' M_.fname ...
'_steadystate.m don''t solve the static model!' ])
end
end
end
error(['The seadystate values returned by ' M_.fname ...
'_steadystate.m don''t solve the static model!' ])
end
if ~isempty(options_.steadystate_partial)
ssvar = options_.steadystate_partial.ssvar;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment