1function steady()
2% function steady()
3% computes and prints the steady state calculations
4%
5% INPUTS
6%   none
7%
8% OUTPUTS
9%   none
10%
11% SPECIAL REQUIREMENTS
12%   none
13
14% Copyright (C) 2001-2019 Dynare Team
15%
16% This file is part of Dynare.
17%
18% Dynare is free software: you can redistribute it and/or modify
19% it under the terms of the GNU General Public License as published by
20% the Free Software Foundation, either version 3 of the License, or
21% (at your option) any later version.
22%
23% Dynare is distributed in the hope that it will be useful,
24% but WITHOUT ANY WARRANTY; without even the implied warranty of
25% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26% GNU General Public License for more details.
27%
28% You should have received a copy of the GNU General Public License
29% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
30
31global M_ oo_ options_
32
33test_for_deep_parameters_calibration(M_);
34
35if options_.steadystate_flag && options_.homotopy_mode
36    error('STEADY: Can''t use homotopy when providing a steady state external file');
37end
38
39% Keep of a copy of M_.Sigma_e
40Sigma_e = M_.Sigma_e;
41
42% Set M_.Sigma_e=0 (we compute the *deterministic* steady state)
43M_.Sigma_e(:,:) = 0;
44
45info = 0;
46switch options_.homotopy_mode
47  case 1
48    [M_,oo_,info,ip,ix,ixd] = homotopy1(options_.homotopy_values,options_.homotopy_steps,M_,options_,oo_);
49  case 2
50    homotopy2(options_.homotopy_values, options_.homotopy_steps);
51  case 3
52    [M_,oo_,info,ip,ix,ixd] = homotopy3(options_.homotopy_values,options_.homotopy_steps,M_,options_,oo_);
53end
54
55if info(1)
56    hv = options_.homotopy_values;
57    skipline()
58    disp('WARNING: homotopy step was not completed')
59    disp('The last values for which a solution was found are:')
60    for i=1:length(ip)
61        fprintf('%12s %12.6f\n',char(M_.param_names(hv(ip(i),2))), ...
62                M_.params(hv(ip(i),2)))
63    end
64    for i=1:length(ix)
65        fprintf('%12s %12.6f\n',char(M_.exo_names(hv(ix(i),2))), ...
66                oo_.exo_steady_state(hv(ix(i),2)))
67    end
68    for i=1:length(ixd)
69        fprintf('%12s %12.6f\n',char(M_.exo_det_names(hv(ixd(i),2))), ...
70                oo_.exo_det_steady_state(hv(ixd(i),2)))
71    end
72
73    if options_.homotopy_force_continue
74        disp('Option homotopy_continue is set, so I continue ...')
75    else
76        error('Homotopy step failed')
77    end
78end
79
80[oo_.steady_state,M_.params,info] = steady_(M_,options_,oo_);
81
82if info(1) == 0
83    if ~options_.noprint
84        disp_steady_state(M_,oo_);
85    end
86else
87    if ~options_.noprint
88        if ~isempty(oo_.steady_state)
89            resid;
90        else
91            skipline()
92            disp('Residuals of the static equations cannot be computed because the steady state routine returned an empty vector.')
93            skipline()
94        end
95    end
96    if options_.debug
97        fprintf('\nThe steady state computation failed. It terminated with the following values:\n')
98        for i=1:M_.orig_endo_nbr
99            fprintf('%s \t\t %g\n', M_.endo_names{i}, oo_.steady_state(i));
100        end
101    end
102    print_info(info,options_.noprint, options_);
103end
104
105M_.Sigma_e = Sigma_e;
106