2010-09-21 13:35:55 +02:00
|
|
|
function simul
|
|
|
|
% Computes deterministic simulations
|
2006-10-29 18:27:48 +01:00
|
|
|
%
|
|
|
|
% INPUTS
|
2010-09-21 13:35:55 +02:00
|
|
|
% None
|
2006-10-29 18:27:48 +01:00
|
|
|
%
|
|
|
|
% OUTPUTS
|
2010-11-17 17:09:39 +01:00
|
|
|
% none
|
|
|
|
%
|
2006-10-29 18:27:48 +01:00
|
|
|
% ALGORITHM
|
2010-11-17 17:09:39 +01:00
|
|
|
%
|
2006-10-29 18:27:48 +01:00
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none
|
2008-08-01 14:40:33 +02:00
|
|
|
|
2011-02-04 17:27:33 +01:00
|
|
|
% Copyright (C) 1996-2011 Dynare Team
|
2008-08-01 14:40:33 +02:00
|
|
|
%
|
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare is free software: you can redistribute it and/or modify
|
|
|
|
% it under the terms of the GNU General Public License as published by
|
|
|
|
% the Free Software Foundation, either version 3 of the License, or
|
|
|
|
% (at your option) any later version.
|
|
|
|
%
|
|
|
|
% Dynare is distributed in the hope that it will be useful,
|
|
|
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
% GNU General Public License for more details.
|
|
|
|
%
|
|
|
|
% You should have received a copy of the GNU General Public License
|
|
|
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
2005-02-18 20:54:39 +01:00
|
|
|
|
2010-09-21 13:35:55 +02:00
|
|
|
global M_ options_ oo_
|
2005-02-18 20:54:39 +01:00
|
|
|
|
2010-11-17 17:09:39 +01:00
|
|
|
test_for_deep_parameters_calibration(M_);
|
|
|
|
|
2010-10-22 12:09:53 +02:00
|
|
|
if options_.stack_solve_algo < 0 || options_.stack_solve_algo > 5
|
|
|
|
error('SIMUL: stack_solve_algo must be between 0 and 5')
|
|
|
|
end
|
|
|
|
|
|
|
|
if ~options_.block && ~options_.bytecode && options_.stack_solve_algo ~= 0
|
|
|
|
error('SIMUL: you must use stack_solve_algo=0 when not using block nor bytecode option')
|
|
|
|
end
|
|
|
|
|
|
|
|
if options_.block && ~options_.bytecode && options_.stack_solve_algo == 5
|
|
|
|
error('SIMUL: you can''t use stack_solve_algo = 5 without bytecode option')
|
|
|
|
end
|
|
|
|
|
|
|
|
if exist('OCTAVE_VERSION') && options_.stack_solve_algo == 2
|
|
|
|
error('SIMUL: you can''t use stack_solve_algo = 2 under Octave')
|
|
|
|
end
|
|
|
|
|
2006-10-29 18:27:48 +01:00
|
|
|
if size(M_.lead_lag_incidence,2)-nnz(M_.lead_lag_incidence(M_.maximum_endo_lag+1,:)) > 0
|
2010-09-21 13:35:55 +02:00
|
|
|
mess = ['SIMUL: error in model specification : variable ' M_.endo_names(find(M_.lead_lag_incidence(M_.maximum_lag+1,:)==0),:)] ;
|
2009-12-16 18:17:34 +01:00
|
|
|
mess = [mess ' doesn''t appear as current variable.'] ;
|
|
|
|
error (mess) ;
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
options_ = set_default_option(options_,'periods',0);
|
|
|
|
if options_.periods == 0
|
2009-12-16 18:17:34 +01:00
|
|
|
error('SIMUL: number of periods for the simulation isn''t specified')
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
|
|
|
|
2009-12-16 18:17:34 +01:00
|
|
|
if ~ options_.initval_file
|
|
|
|
if ~isfield(options_,'datafile')
|
2009-09-02 16:40:54 +02:00
|
|
|
make_ex_;
|
|
|
|
make_y_;
|
2009-12-16 18:17:34 +01:00
|
|
|
else
|
|
|
|
read_data_;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-02-10 15:54:23 +01:00
|
|
|
if isempty(options_.scalv) || options_.scalv == 0
|
2005-02-18 20:54:39 +01:00
|
|
|
options_.scalv = oo_.steady_state ;
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
options_.scalv= 1 ;
|
2005-02-18 20:54:39 +01:00
|
|
|
|
2009-12-16 18:17:34 +01:00
|
|
|
if(options_.block)
|
|
|
|
if(options_.bytecode)
|
2010-09-24 12:52:58 +02:00
|
|
|
[info, oo_.endo_simul] = bytecode('dynamic');
|
|
|
|
mexErrCheck('bytecode', info);
|
2009-12-16 18:17:34 +01:00
|
|
|
else
|
|
|
|
eval([M_.fname '_dynamic']);
|
|
|
|
end;
|
|
|
|
else
|
2010-01-22 11:03:29 +01:00
|
|
|
if(options_.bytecode)
|
2010-09-24 12:52:58 +02:00
|
|
|
[info, oo_.endo_simul]=bytecode('dynamic');
|
|
|
|
mexErrCheck('bytecode', info);
|
2009-12-16 18:17:34 +01:00
|
|
|
else
|
2010-07-23 11:02:03 +02:00
|
|
|
if M_.maximum_endo_lead == 0
|
2010-09-21 13:35:55 +02:00
|
|
|
error('SIMUL: purely backward models are not supported')
|
2010-07-23 11:02:03 +02:00
|
|
|
elseif M_.maximum_endo_lag == 1 && M_.maximum_endo_lead == 1
|
2011-02-04 17:17:48 +01:00
|
|
|
sim1 ;
|
2010-10-13 18:38:09 +02:00
|
|
|
else % For purely forward models
|
|
|
|
simk;
|
2010-01-22 11:03:29 +01:00
|
|
|
end;
|
|
|
|
end;
|
2009-12-16 18:17:34 +01:00
|
|
|
end;
|
2005-02-18 20:54:39 +01:00
|
|
|
|
2010-11-17 17:09:39 +01:00
|
|
|
dyn2vec;
|