Home > matlab > model_info.m

model_info

PURPOSE ^

function model_info;

SYNOPSIS ^

function model_info(varargin);

DESCRIPTION ^

function model_info;

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function model_info(varargin);
0002 %function model_info;
0003 
0004 % Copyright (C) 2008-2010 Dynare Team
0005 %
0006 % This file is part of Dynare.
0007 %
0008 % Dynare is free software: you can redistribute it and/or modify
0009 % it under the terms of the GNU General Public License as published by
0010 % the Free Software Foundation, either version 3 of the License, or
0011 % (at your option) any later version.
0012 %
0013 % Dynare is distributed in the hope that it will be useful,
0014 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0015 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016 % GNU General Public License for more details.
0017 %
0018 % You should have received a copy of the GNU General Public License
0019 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0020 
0021 global M_;
0022 fprintf('                                          Informations about %s\n',M_.fname);
0023 fprintf(strcat('                                          ===================',char(ones(1,length(M_.fname))*'='),'\n\n'));
0024 if(isfield(M_,'block_structure'))
0025     nb_blocks=length(M_.block_structure.block);
0026     fprintf('The model has %d equations and is decomposed in %d blocks as follow:\n',M_.endo_nbr,nb_blocks);
0027     fprintf('===============================================================================================================\n');
0028     fprintf('| %10s | %10s | %30s | %14s | %31s |\n','Block no','Size','Block Type','   Equation','Dependent variable');
0029     fprintf('|============|============|================================|================|=================================|\n');
0030     for i=1:nb_blocks
0031         size_block=length(M_.block_structure.block(i).equation);
0032         if(i>1)
0033             fprintf('|------------|------------|--------------------------------|----------------|---------------------------------|\n');
0034         end;
0035         for j=1:size_block
0036             if(j==1)
0037                 fprintf('| %10d | %10d | %30s | %14d | %-6d %24s |\n',i,size_block,Sym_type(M_.block_structure.block(i).Simulation_Type),M_.block_structure.block(i).equation(j),M_.block_structure.block(i).variable(j),M_.endo_names(M_.block_structure.block(i).variable(j),:));
0038             else
0039                 fprintf('| %10s | %10s | %30s | %14d | %-6d %24s |\n','','','',M_.block_structure.block(i).equation(j),M_.block_structure.block(i).variable(j),M_.endo_names(M_.block_structure.block(i).variable(j),:));
0040             end;
0041         end;
0042     end;
0043     fprintf('===============================================================================================================\n');
0044     fprintf('\n');
0045     for k=1:M_.maximum_endo_lag+M_.maximum_endo_lead+1
0046         if(k==M_.maximum_endo_lag+1)
0047             fprintf('%-30s %s','the variable','is used in equations Contemporaneously');
0048         elseif(k<M_.maximum_endo_lag+1)
0049             fprintf('%-30s %s %d','the variable','is used in equations with lag ',M_.maximum_endo_lag+1-k);
0050         else
0051             fprintf('%-30s %s %d','the variable','is used in equations with lead ',k-(M_.maximum_endo_lag+1));
0052         end;
0053         if(size(M_.block_structure.incidence(k).sparse_IM,1)>0)
0054             IM=sortrows(M_.block_structure.incidence(k).sparse_IM,2);
0055         else
0056             IM=[];
0057         end;
0058         size_IM=size(IM,1);
0059         last=99999999;
0060         for i=1:size_IM
0061             if(last~=IM(i,2))
0062                 fprintf('\n%-30s',M_.endo_names(IM(i,2),:));
0063             end;
0064             fprintf(' %5d',IM(i,1));
0065             last=IM(i,2);
0066         end;
0067         fprintf('\n\n');
0068     end;
0069     
0070     %printing the gross incidence matrix
0071     IM_star = char([kron(ones(M_.endo_nbr, M_.endo_nbr-1), double(blanks(3))) double(blanks(M_.endo_nbr)')]);
0072     for i = 1:3
0073         n = size(M_.block_structure.incidence(i).sparse_IM,1);
0074         for j = 1:n
0075             if ismember(M_.block_structure.incidence(i).sparse_IM(j,2), M_.state_var)
0076                 IM_star(M_.block_structure.incidence(i).sparse_IM(j,1), 3 * (M_.block_structure.incidence(i).sparse_IM(j,2) - 1) + 1) = 'X';
0077             else
0078                 IM_star(M_.block_structure.incidence(i).sparse_IM(j,1), 3 * (M_.block_structure.incidence(i).sparse_IM(j,2) - 1) + 1) = '1';
0079             end;
0080         end;
0081     end;
0082     seq = 1: M_.endo_nbr;
0083     blank = [ blanks(size(M_.endo_names,2)); blanks(size(M_.endo_names,2))];
0084     for i = 1:M_.endo_nbr
0085         if i == 1
0086             var_names = [blank; M_.endo_names(i,:)];
0087         else
0088             var_names = [var_names; blank; M_.endo_names(i,:)];
0089         end;
0090     end;
0091     if nargin == 1 && strcmp(varargin{1},'incidence')
0092         topp = [char(kron(double(blanks(ceil(log10(M_.endo_nbr)))),ones(size(M_.endo_names,2),1))) var_names' ];
0093         bott = [int2str(seq') blanks(M_.endo_nbr)' blanks(M_.endo_nbr)' IM_star];
0094         fprintf('\n                                          Gross incidence matrix\n');
0095         fprintf('                                          =======================\n');
0096         disp([topp; bott]);
0097     
0098         %printing the reordered incidence matrix
0099         IM_star_reordered = char([kron(ones(M_.endo_nbr, M_.endo_nbr-1), double(blanks(3))) double(blanks(M_.endo_nbr)')]);
0100         eq(M_.block_structure.equation_reordered) = seq;
0101         va(M_.block_structure.variable_reordered) = seq;
0102         barre_blank = [ barre(size(M_.endo_names,2)); blanks(size(M_.endo_names,2))];
0103         cur_block = 1;
0104         for i = 1:M_.endo_nbr
0105             past_block = cur_block;
0106             while ismember(M_.block_structure.variable_reordered(i), M_.block_structure.block(cur_block).variable) == 0;
0107                 cur_block = cur_block + 1;
0108             end;
0109             if i == 1
0110                 var_names = [blank; M_.endo_names(M_.block_structure.variable_reordered(i),:)];
0111             else
0112                 if past_block ~= cur_block
0113                     var_names = [var_names; barre_blank; M_.endo_names(M_.block_structure.variable_reordered(i),:)];
0114                 else
0115                     var_names = [var_names; blank; M_.endo_names(M_.block_structure.variable_reordered(i),:)];
0116                 end
0117             end;
0118         end;
0119         topp = [char(kron(double(blanks(ceil(log10(M_.endo_nbr)))),ones(size(M_.endo_names,2),1))) var_names' ];
0120         n_state_var = length(M_.state_var);
0121         IM_state_var = zeros(n_state_var, n_state_var);
0122         inv_variable_reordered(M_.block_structure.variable_reordered) = 1:M_.endo_nbr;
0123         state_equation = M_.block_structure.equation_reordered(inv_variable_reordered(M_.state_var));
0124         for i = 1:3
0125             n = size(M_.block_structure.incidence(i).sparse_IM,1);
0126             for j = 1:n
0127                 [tf, loc] = ismember(M_.block_structure.incidence(i).sparse_IM(j,2), M_.state_var);
0128                 if tf
0129                     IM_star_reordered(eq(M_.block_structure.incidence(i).sparse_IM(j,1)), 3 * (va(M_.block_structure.incidence(i).sparse_IM(j,2)) - 1) + 1) = 'X';
0130                     [tfi, loci] = ismember(M_.block_structure.incidence(i).sparse_IM(j,1), state_equation);
0131                     if tfi
0132                         IM_state_var(loci, loc) = 1;
0133                     end;
0134                 else
0135                     IM_star_reordered(eq(M_.block_structure.incidence(i).sparse_IM(j,1)), 3 * (va(M_.block_structure.incidence(i).sparse_IM(j,2)) - 1) + 1) = '1';
0136                 end;
0137             end;
0138         end;
0139         fprintf('1: non nul element, X: non nul element related to a state variable\n');
0140         
0141         cur_block = 1;
0142         i_last = 0;
0143         block = {};
0144         for i = 1:n_state_var;
0145             past_block = cur_block;
0146             while ismember(M_.state_var(i), M_.block_structure.block(cur_block).variable) == 0;
0147                 cur_block = cur_block + 1;
0148             end;
0149             if (past_block ~= cur_block) || (past_block == cur_block && i == n_state_var)
0150                 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);
0151                 i_last = i - 1;
0152             end;
0153         end;
0154         cur_block = 1;
0155         for i = 1:M_.endo_nbr
0156             past_block = cur_block;
0157             while ismember(M_.block_structure.variable_reordered(i), M_.block_structure.block(cur_block).variable) == 0;
0158                 cur_block = cur_block + 1;
0159             end;
0160             if past_block ~= cur_block
0161                 for j = 1:i-1
0162                    IM_star_reordered(j, 3 * (i - 1) - 1) = '|';
0163                 end;
0164             end;
0165         end
0166         
0167         bott = [int2str(M_.block_structure.equation_reordered') blanks(M_.endo_nbr)' blanks(M_.endo_nbr)' IM_star_reordered];
0168         fprintf('\n                                          Reordered incidence matrix\n');
0169         fprintf('                                          ==========================\n');
0170         disp([topp; bott]);
0171         fprintf('1: non nul element, X: non nul element related to a state variable\n');
0172      end;
0173 else
0174     fprintf('There is no block decomposition of the model.\nUse ''block'' model''s option.\n');
0175 end;
0176 
0177 function ret=Sym_type(type)
0178 UNKNOWN=0;
0179 EVALUATE_FORWARD=1;
0180 EVALUATE_BACKWARD=2;
0181 SOLVE_FORWARD_SIMPLE=3;
0182 SOLVE_BACKWARD_SIMPLE=4;
0183 SOLVE_TWO_BOUNDARIES_SIMPLE=5;
0184 SOLVE_FORWARD_COMPLETE=6;
0185 SOLVE_BACKWARD_COMPLETE=7;
0186 SOLVE_TWO_BOUNDARIES_COMPLETE=8;
0187 EVALUATE_FORWARD_R=9;
0188 EVALUATE_BACKWARD_R=10;
0189 switch (type)
0190   case (UNKNOWN),
0191     ret='UNKNOWN                     ';
0192   case {EVALUATE_FORWARD,EVALUATE_FORWARD_R},
0193     ret='EVALUATE FORWARD            ';
0194   case {EVALUATE_BACKWARD,EVALUATE_BACKWARD_R},
0195     ret='EVALUATE BACKWARD            ';
0196   case SOLVE_FORWARD_SIMPLE,
0197     ret='SOLVE FORWARD SIMPLE        ';
0198   case SOLVE_BACKWARD_SIMPLE,
0199     ret='SOLVE BACKWARD SIMPLE        ';
0200   case SOLVE_TWO_BOUNDARIES_SIMPLE,
0201     ret='SOLVE TWO BOUNDARIES SIMPLE  ';
0202   case SOLVE_FORWARD_COMPLETE,
0203     ret='SOLVE FORWARD COMPLETE      ';
0204   case SOLVE_BACKWARD_COMPLETE,
0205     ret='SOLVE BACKWARD COMPLETE      ';
0206   case SOLVE_TWO_BOUNDARIES_COMPLETE,
0207     ret='SOLVE TWO BOUNDARIES COMPLETE';
0208 end;
0209 
0210 
0211 function ret = barre(n)
0212 s = [];
0213 for i=1:n;
0214     s = [s '|'];
0215 end;
0216 ret = s;
0217 
0218 
0219

Generated on Tue 22-May-2012 02:40:23 by m2html © 2005