2017-05-16 12:42:01 +02:00
|
|
|
function model_info(varargin)
|
2009-12-16 18:17:34 +01:00
|
|
|
%function model_info;
|
|
|
|
|
2017-10-10 10:05:59 +02:00
|
|
|
% Copyright (C) 2008-2018 Dynare Team
|
2009-12-16 18:17:34 +01: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/>.
|
|
|
|
|
|
|
|
global M_;
|
2012-06-06 16:36:56 +02:00
|
|
|
if sum(strcmp(varargin,'static')) > 0
|
2012-06-07 15:33:04 +02:00
|
|
|
static_ = 1;
|
2012-06-06 16:36:56 +02:00
|
|
|
else
|
2012-06-07 15:33:04 +02:00
|
|
|
static_ = 0;
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2012-06-06 16:36:56 +02:00
|
|
|
if sum(strcmp(varargin,'incidence')) > 0
|
|
|
|
incidence = 1;
|
|
|
|
else
|
|
|
|
incidence = 0;
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2012-06-07 15:33:04 +02:00
|
|
|
if static_
|
2017-05-16 15:10:20 +02:00
|
|
|
fprintf(' Informations about %s (static model)\n',M_.fname);
|
|
|
|
block_structre_str = 'block_structure_stat';
|
|
|
|
nb_leadlag = 1;
|
|
|
|
else
|
|
|
|
fprintf(' Informations about %s (dynamic model)\n',M_.fname);
|
|
|
|
block_structre_str = 'block_structure';
|
|
|
|
nb_leadlag = 3;
|
|
|
|
end
|
2012-06-06 16:36:56 +02:00
|
|
|
if(isfield(M_,block_structre_str))
|
2012-06-11 10:32:44 +02:00
|
|
|
if static_
|
|
|
|
block_structure = M_.block_structure_stat;
|
|
|
|
else
|
|
|
|
block_structure = M_.block_structure;
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2012-06-11 10:32:44 +02:00
|
|
|
fprintf(strcat(' ===================',char(ones(1,length(M_.fname))*'='),'\n\n'));
|
2012-06-06 16:36:56 +02:00
|
|
|
nb_blocks=length(block_structure.block);
|
2009-12-16 18:17:34 +01:00
|
|
|
fprintf('The model has %d equations and is decomposed in %d blocks as follow:\n',M_.endo_nbr,nb_blocks);
|
|
|
|
fprintf('===============================================================================================================\n');
|
|
|
|
fprintf('| %10s | %10s | %30s | %14s | %31s |\n','Block no','Size','Block Type',' Equation','Dependent variable');
|
|
|
|
fprintf('|============|============|================================|================|=================================|\n');
|
|
|
|
for i=1:nb_blocks
|
2012-06-06 16:36:56 +02:00
|
|
|
size_block=length(block_structure.block(i).equation);
|
2009-12-16 18:17:34 +01:00
|
|
|
if(i>1)
|
|
|
|
fprintf('|------------|------------|--------------------------------|----------------|---------------------------------|\n');
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
for j=1:size_block
|
|
|
|
if(j==1)
|
2017-10-10 10:05:59 +02:00
|
|
|
fprintf('| %10d | %10d | %30s | %14d | %-6d %24s |\n',i,size_block,Sym_type(block_structure.block(i).Simulation_Type),block_structure.block(i).equation(j),block_structure.block(i).variable(j),M_.endo_names{block_structure.block(i).variable(j)});
|
2009-12-16 18:17:34 +01:00
|
|
|
else
|
2017-10-10 10:05:59 +02:00
|
|
|
fprintf('| %10s | %10s | %30s | %14d | %-6d %24s |\n','','','',block_structure.block(i).equation(j),block_structure.block(i).variable(j),M_.endo_names{block_structure.block(i).variable(j)});
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
fprintf('===============================================================================================================\n');
|
|
|
|
fprintf('\n');
|
2012-06-07 15:33:04 +02:00
|
|
|
if static_
|
2012-06-06 16:36:56 +02:00
|
|
|
fprintf('%-30s %s','the variable','is used in equations Contemporaneously');
|
|
|
|
if(size(block_structure.incidence.sparse_IM,1)>0)
|
|
|
|
IM=sortrows(block_structure.incidence.sparse_IM,2);
|
2009-12-16 18:17:34 +01:00
|
|
|
else
|
|
|
|
IM=[];
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
size_IM=size(IM,1);
|
2010-06-02 14:21:30 +02:00
|
|
|
last=99999999;
|
2009-12-16 18:17:34 +01:00
|
|
|
for i=1:size_IM
|
|
|
|
if(last~=IM(i,2))
|
2017-10-10 10:05:59 +02:00
|
|
|
fprintf('\n%-30s',M_.endo_names{IM(i,2)});
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
fprintf(' %5d',IM(i,1));
|
|
|
|
last=IM(i,2);
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
fprintf('\n\n');
|
2012-06-06 16:36:56 +02:00
|
|
|
else
|
|
|
|
for k=1:M_.maximum_endo_lag+M_.maximum_endo_lead+1
|
|
|
|
if(k==M_.maximum_endo_lag+1)
|
|
|
|
fprintf('%-30s %s','the variable','is used in equations Contemporaneously');
|
|
|
|
elseif(k<M_.maximum_endo_lag+1)
|
|
|
|
fprintf('%-30s %s %d','the variable','is used in equations with lag ',M_.maximum_endo_lag+1-k);
|
|
|
|
else
|
|
|
|
fprintf('%-30s %s %d','the variable','is used in equations with lead ',k-(M_.maximum_endo_lag+1));
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2012-06-06 16:36:56 +02:00
|
|
|
if(size(block_structure.incidence(k).sparse_IM,1)>0)
|
|
|
|
IM=sortrows(block_structure.incidence(k).sparse_IM,2);
|
|
|
|
else
|
|
|
|
IM=[];
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2012-06-06 16:36:56 +02:00
|
|
|
size_IM=size(IM,1);
|
|
|
|
last=99999999;
|
|
|
|
for i=1:size_IM
|
|
|
|
if(last~=IM(i,2))
|
2017-10-10 10:05:59 +02:00
|
|
|
fprintf('\n%-30s',M_.endo_names{IM(i,2)});
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2012-06-06 16:36:56 +02:00
|
|
|
fprintf(' %5d',IM(i,1));
|
|
|
|
last=IM(i,2);
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2012-06-06 16:36:56 +02:00
|
|
|
fprintf('\n\n');
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
|
2011-09-11 14:48:09 +02:00
|
|
|
%printing the gross incidence matrix
|
2011-09-16 17:24:11 +02:00
|
|
|
IM_star = char([kron(ones(M_.endo_nbr, M_.endo_nbr-1), double(blanks(3))) double(blanks(M_.endo_nbr)')]);
|
2012-06-06 16:36:56 +02:00
|
|
|
for i = 1:nb_leadlag
|
|
|
|
n = size(block_structure.incidence(i).sparse_IM,1);
|
2011-09-11 14:48:09 +02:00
|
|
|
for j = 1:n
|
2012-06-06 16:36:56 +02:00
|
|
|
if ismember(block_structure.incidence(i).sparse_IM(j,2), M_.state_var)
|
|
|
|
IM_star(block_structure.incidence(i).sparse_IM(j,1), 3 * (block_structure.incidence(i).sparse_IM(j,2) - 1) + 1) = 'X';
|
2011-09-11 14:48:09 +02:00
|
|
|
else
|
2012-06-06 16:36:56 +02:00
|
|
|
IM_star(block_structure.incidence(i).sparse_IM(j,1), 3 * (block_structure.incidence(i).sparse_IM(j,2) - 1) + 1) = '1';
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-09-11 14:48:09 +02:00
|
|
|
seq = 1: M_.endo_nbr;
|
2017-10-10 10:05:59 +02:00
|
|
|
blank = [ blanks(cellofchararraymaxlength(M_.endo_names)); blanks(cellofchararraymaxlength(M_.endo_names))];
|
2011-09-11 14:48:09 +02:00
|
|
|
for i = 1:M_.endo_nbr
|
|
|
|
if i == 1
|
2017-10-10 10:05:59 +02:00
|
|
|
var_names = char(blank, M_.endo_names{i});
|
2011-09-11 14:48:09 +02:00
|
|
|
else
|
2017-10-10 10:05:59 +02:00
|
|
|
var_names = char(var_names, blank, M_.endo_names{i});
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
|
|
|
end
|
2012-06-06 16:36:56 +02:00
|
|
|
if incidence
|
2017-10-10 10:05:59 +02:00
|
|
|
topp = [char(kron(double(blanks(ceil(log10(M_.endo_nbr)))),ones(cellofchararraymaxlength(M_.endo_names),1))) var_names' ];
|
2011-09-11 14:48:09 +02:00
|
|
|
bott = [int2str(seq') blanks(M_.endo_nbr)' blanks(M_.endo_nbr)' IM_star];
|
|
|
|
fprintf('\n Gross incidence matrix\n');
|
|
|
|
fprintf(' =======================\n');
|
|
|
|
disp([topp; bott]);
|
2017-05-16 15:10:20 +02:00
|
|
|
|
2011-09-11 14:48:09 +02:00
|
|
|
%printing the reordered incidence matrix
|
2011-09-16 17:24:11 +02:00
|
|
|
IM_star_reordered = char([kron(ones(M_.endo_nbr, M_.endo_nbr-1), double(blanks(3))) double(blanks(M_.endo_nbr)')]);
|
2012-06-06 16:36:56 +02:00
|
|
|
eq(block_structure.equation_reordered) = seq;
|
|
|
|
va(block_structure.variable_reordered) = seq;
|
2017-10-10 10:05:59 +02:00
|
|
|
barre_blank = [ barre(cellofchararraymaxlength(M_.endo_names)); blanks(cellofchararraymaxlength(M_.endo_names))];
|
2011-09-11 14:48:09 +02:00
|
|
|
cur_block = 1;
|
|
|
|
for i = 1:M_.endo_nbr
|
|
|
|
past_block = cur_block;
|
2017-05-16 12:42:01 +02:00
|
|
|
while ismember(block_structure.variable_reordered(i), block_structure.block(cur_block).variable) == 0
|
2011-09-11 14:48:09 +02:00
|
|
|
cur_block = cur_block + 1;
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2011-09-11 14:48:09 +02:00
|
|
|
if i == 1
|
2017-10-10 10:05:59 +02:00
|
|
|
var_names = [blank; M_.endo_names{block_structure.variable_reordered(i)}];
|
2011-09-11 14:48:09 +02:00
|
|
|
else
|
|
|
|
if past_block ~= cur_block
|
2017-10-10 10:05:59 +02:00
|
|
|
var_names = [var_names; barre_blank; M_.endo_names{block_structure.variable_reordered(i)}];
|
2011-09-11 14:48:09 +02:00
|
|
|
else
|
2017-10-10 10:05:59 +02:00
|
|
|
var_names = [var_names; blank; M_.endo_names{block_structure.variable_reordered(i)}];
|
2011-09-11 14:48:09 +02:00
|
|
|
end
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
|
|
|
end
|
2017-10-10 10:05:59 +02:00
|
|
|
topp = [char(kron(double(blanks(ceil(log10(M_.endo_nbr)))),ones(cellofchararraymaxlength(M_.endo_names),1))) var_names' ];
|
2011-09-11 14:48:09 +02:00
|
|
|
n_state_var = length(M_.state_var);
|
|
|
|
IM_state_var = zeros(n_state_var, n_state_var);
|
2012-06-06 16:36:56 +02:00
|
|
|
inv_variable_reordered(block_structure.variable_reordered) = 1:M_.endo_nbr;
|
|
|
|
state_equation = block_structure.equation_reordered(inv_variable_reordered(M_.state_var));
|
|
|
|
for i = 1:nb_leadlag
|
|
|
|
n = size(block_structure.incidence(i).sparse_IM,1);
|
2011-09-11 14:48:09 +02:00
|
|
|
for j = 1:n
|
2012-06-06 16:36:56 +02:00
|
|
|
[tf, loc] = ismember(block_structure.incidence(i).sparse_IM(j,2), M_.state_var);
|
2011-09-11 14:48:09 +02:00
|
|
|
if tf
|
2012-06-06 16:36:56 +02:00
|
|
|
IM_star_reordered(eq(block_structure.incidence(i).sparse_IM(j,1)), 3 * (va(block_structure.incidence(i).sparse_IM(j,2)) - 1) + 1) = 'X';
|
|
|
|
[tfi, loci] = ismember(block_structure.incidence(i).sparse_IM(j,1), state_equation);
|
2011-09-11 14:48:09 +02:00
|
|
|
if tfi
|
|
|
|
IM_state_var(loci, loc) = 1;
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2011-09-11 14:48:09 +02:00
|
|
|
else
|
2012-06-06 16:36:56 +02:00
|
|
|
IM_star_reordered(eq(block_structure.incidence(i).sparse_IM(j,1)), 3 * (va(block_structure.incidence(i).sparse_IM(j,2)) - 1) + 1) = '1';
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-09-11 14:48:09 +02:00
|
|
|
fprintf('1: non nul element, X: non nul element related to a state variable\n');
|
2017-05-16 15:10:20 +02:00
|
|
|
|
2011-09-11 14:48:09 +02:00
|
|
|
cur_block = 1;
|
|
|
|
i_last = 0;
|
|
|
|
block = {};
|
2017-05-16 12:42:01 +02:00
|
|
|
for i = 1:n_state_var
|
2011-09-11 14:48:09 +02:00
|
|
|
past_block = cur_block;
|
2017-05-16 12:42:01 +02:00
|
|
|
while ismember(M_.state_var(i), block_structure.block(cur_block).variable) == 0
|
2011-09-11 14:48:09 +02:00
|
|
|
cur_block = cur_block + 1;
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2011-09-11 14:48:09 +02:00
|
|
|
if (past_block ~= cur_block) || (past_block == cur_block && i == n_state_var)
|
|
|
|
block(past_block).IM_state_var(1:(i - 1 - i_last), 1:i - 1) = IM_state_var(i_last+1:i - 1, 1:i - 1);
|
|
|
|
i_last = i - 1;
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
|
|
|
end
|
2011-09-11 14:48:09 +02:00
|
|
|
cur_block = 1;
|
|
|
|
for i = 1:M_.endo_nbr
|
|
|
|
past_block = cur_block;
|
2017-05-16 12:42:01 +02:00
|
|
|
while ismember(block_structure.variable_reordered(i), block_structure.block(cur_block).variable) == 0
|
2011-09-11 14:48:09 +02:00
|
|
|
cur_block = cur_block + 1;
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2011-09-11 14:48:09 +02:00
|
|
|
if past_block ~= cur_block
|
|
|
|
for j = 1:i-1
|
2017-05-16 15:10:20 +02:00
|
|
|
IM_star_reordered(j, 3 * (i - 1) - 1) = '|';
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
|
|
|
end
|
2011-09-11 14:48:09 +02:00
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
|
2012-06-06 16:36:56 +02:00
|
|
|
bott = [int2str(block_structure.equation_reordered') blanks(M_.endo_nbr)' blanks(M_.endo_nbr)' IM_star_reordered];
|
2011-09-11 14:48:09 +02:00
|
|
|
fprintf('\n Reordered incidence matrix\n');
|
|
|
|
fprintf(' ==========================\n');
|
|
|
|
disp([topp; bott]);
|
|
|
|
fprintf('1: non nul element, X: non nul element related to a state variable\n');
|
2017-05-16 15:10:20 +02:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
else
|
|
|
|
fprintf('There is no block decomposition of the model.\nUse ''block'' model''s option.\n');
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
|
2011-09-11 14:48:09 +02:00
|
|
|
function ret=Sym_type(type)
|
2009-12-16 18:17:34 +01:00
|
|
|
UNKNOWN=0;
|
|
|
|
EVALUATE_FORWARD=1;
|
|
|
|
EVALUATE_BACKWARD=2;
|
|
|
|
SOLVE_FORWARD_SIMPLE=3;
|
|
|
|
SOLVE_BACKWARD_SIMPLE=4;
|
|
|
|
SOLVE_TWO_BOUNDARIES_SIMPLE=5;
|
|
|
|
SOLVE_FORWARD_COMPLETE=6;
|
|
|
|
SOLVE_BACKWARD_COMPLETE=7;
|
|
|
|
SOLVE_TWO_BOUNDARIES_COMPLETE=8;
|
|
|
|
EVALUATE_FORWARD_R=9;
|
|
|
|
EVALUATE_BACKWARD_R=10;
|
|
|
|
switch (type)
|
2017-05-16 12:42:01 +02:00
|
|
|
case (UNKNOWN)
|
2009-12-16 18:17:34 +01:00
|
|
|
ret='UNKNOWN ';
|
2017-05-16 12:42:01 +02:00
|
|
|
case {EVALUATE_FORWARD,EVALUATE_FORWARD_R}
|
2009-12-16 18:17:34 +01:00
|
|
|
ret='EVALUATE FORWARD ';
|
2017-05-16 12:42:01 +02:00
|
|
|
case {EVALUATE_BACKWARD,EVALUATE_BACKWARD_R}
|
2009-12-16 18:17:34 +01:00
|
|
|
ret='EVALUATE BACKWARD ';
|
2017-05-16 12:42:01 +02:00
|
|
|
case SOLVE_FORWARD_SIMPLE
|
2009-12-16 18:17:34 +01:00
|
|
|
ret='SOLVE FORWARD SIMPLE ';
|
2017-05-16 12:42:01 +02:00
|
|
|
case SOLVE_BACKWARD_SIMPLE
|
2009-12-16 18:17:34 +01:00
|
|
|
ret='SOLVE BACKWARD SIMPLE ';
|
2017-05-16 12:42:01 +02:00
|
|
|
case SOLVE_TWO_BOUNDARIES_SIMPLE
|
2009-12-16 18:17:34 +01:00
|
|
|
ret='SOLVE TWO BOUNDARIES SIMPLE ';
|
2017-05-16 12:42:01 +02:00
|
|
|
case SOLVE_FORWARD_COMPLETE
|
2009-12-16 18:17:34 +01:00
|
|
|
ret='SOLVE FORWARD COMPLETE ';
|
2017-05-16 12:42:01 +02:00
|
|
|
case SOLVE_BACKWARD_COMPLETE
|
2009-12-16 18:17:34 +01:00
|
|
|
ret='SOLVE BACKWARD COMPLETE ';
|
2017-05-16 12:42:01 +02:00
|
|
|
case SOLVE_TWO_BOUNDARIES_COMPLETE
|
2009-12-16 18:17:34 +01:00
|
|
|
ret='SOLVE TWO BOUNDARIES COMPLETE';
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
|
|
|
|
|
2011-09-11 14:48:09 +02:00
|
|
|
function ret = barre(n)
|
|
|
|
s = [];
|
2017-05-16 12:42:01 +02:00
|
|
|
for i=1:n
|
2011-09-11 14:48:09 +02:00
|
|
|
s = [s '|'];
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2011-09-11 14:48:09 +02:00
|
|
|
ret = s;
|