% computes the steady state of dog.mod (growthless deterministic growth model). 
% stephane [DOT] adjemian [AT] ens [DOT] fr [25-06-2009] (version 2)

function [ys,check] = dog_steadystate(ys,exe)
global M_

%% /!\ DO NOT CHANGE THIS PART /!\
%%
%% Here I load the values of the deep parameters in a loop.
%%
NumberOfParameters = M_.param_nbr;                            % Number of deep parameters.
for i = 1:NumberOfParameters                                  % Loop...
  paramname = deblank(M_.param_names(i,:));                   %    Get the name of parameter i. 
  eval([ paramname ' = M_.params(' int2str(i) ');']);         %    Get the value of parameter i.
end                                                           % End of the loop.  
check = 0;
%%
%% END OF THE FIRST MODEL INDEPENDENT BLOCK.
%%

%% THIS BLOCK IS MODEL SPECIFIC.
%%
%% Here the user has to define some parameters and the steady state.
%%

%% First I compute the values of parameters A and PSI. 
A = (1/betta+delta-1)/alfa ;  % A is such that the steady state level of physical capital is one.
PSI = (epsil-1)/epsil ;       % CES parameter.
%% Second I compute the long run levels.
kstar = ((1-alfa)^(1/PSI))*((1/betta+delta-1)/(alfa*A*effstar)-alfa)^(-1/PSI); % Should be equal to one!
ystar =  A*effstar*( alfa*kstar^PSI + 1-alfa)^(1/PSI) ;
cstar = ystar-delta*kstar;
%% Thrird I assign long run levels (Xstars) to the endogenous variables.
k = kstar;
c = cstar;
eff = effstar;

%%
%% END OF THE MODEL SPECIFIC BLOCK.
%%

%% DO NOT CHANGE THIS PART.
%%
%% Here I put the steady state levels in the vector ys 
%%
NumberOfEndogenousVariables = M_.endo_nbr;                    % Number of endogenous variables.
ys = zeros(NumberOfEndogenousVariables,1);                    % Initialization of ys (steady state).
for i = 1:NumberOfEndogenousVariables                         % Loop...
  varname = deblank(M_.endo_names(i,:));                      %    Get the name of endogenous variable i.                     
  eval(['ys(' int2str(i) ') = ' varname ';']);                %    Get the steady state value of this variable.
end                                                           % End of the loop.
%%
%% Finally I update parameters A and PSI in the global workspace  
%%
id1 = strmatch('A',M_.param_names,'exact');                    % Get the index of A in M_.params
id2 = strmatch('PSI',M_.param_names,'exact');                  % Get the index of A in M_.params
M_.params(id1) = A;
M_.params(id2) = PSI;
%%
%% END OF THE SECOND MODEL INDEPENDENT BLOCK.
%%
