Display equation names in “model_info” command

unit-tests
Sébastien Villemot 2022-10-25 12:27:20 +02:00
parent 417108643a
commit 5f6946a1b9
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 35 additions and 7 deletions

View File

@ -0,0 +1,28 @@
function eqname = get_equation_name_by_number(eqnumber, M_)
% Returns the name of an equation given its number
% Copyright © 2022 Dynare Team
%
% 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 <https://www.gnu.org/licenses/>.
idx_for_this_eq = find(cell2mat(M_.equations_tags(:,1)) == eqnumber);
eqname = cell2mat(M_.equations_tags(idx_for_this_eq(strmatch('name', M_.equations_tags(idx_for_this_eq, 2), 'exact')), 3));
if isempty(eqname)
eqname = '';
end
end

View File

@ -43,23 +43,23 @@ if isfield(M_,block_structre_str)
fprintf(strcat(' ===================',char(ones(1,length(M_.fname))*'='),'\n\n'));
nb_blocks=length(block_structure.block);
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');
fprintf('================================================================================================================================\n');
fprintf('| %10s | %10s | %30s | %31s | %31s |\n','Block no','Size','Block Type','Equation','Dependent variable');
fprintf('|============|============|================================|=================================|=================================|\n');
for i=1:nb_blocks
size_block=length(block_structure.block(i).equation);
if(i>1)
fprintf('|------------|------------|--------------------------------|----------------|---------------------------------|\n');
fprintf('|------------|------------|--------------------------------|---------------------------------|---------------------------------|\n');
end
for j=1:size_block
if(j==1)
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)});
fprintf('| %10d | %10d | %30s | %-6d %24s | %-6d %24s |\n',i,size_block,Sym_type(block_structure.block(i).Simulation_Type),block_structure.block(i).equation(j),get_equation_name_by_number(block_structure.block(i).equation(j), M_),block_structure.block(i).variable(j),M_.endo_names{block_structure.block(i).variable(j)});
else
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)});
fprintf('| %10s | %10s | %30s | %-6d %24s | %-6d %24s |\n','','','',block_structure.block(i).equation(j),get_equation_name_by_number(block_structure.block(i).equation(j), M_),block_structure.block(i).variable(j),M_.endo_names{block_structure.block(i).variable(j)});
end
end
end
fprintf('===============================================================================================================\n');
fprintf('================================================================================================================================\n');
fprintf('\n');
if static_
fprintf('%-30s %s','the variable','is used in the following equations contemporaneously');