% computes the steady state of dog.mod (growthless deterministic growth model). 
% stephane [DOT] adjemian [AT] ens [DOT] fr

function [ys,check] = ndiss_steadystate(ys,exo,M_,options_)

%% DO NOT CHANGE THIS PART.
%%
%% Here we 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 the steady state.
%%
q = 1;
bp = (1+rpb)^(-1) * w * np;
cp = -dp - (1+rpb)*bp + w*np + (1+rpd)*dp + bp;
LAMP = 1/(cp^THETAA) ;
np = (LAMP * w + LAMPBC * w)^(1/PHII);
rpd = 1/BETAP  - 1;
LAMPBC = (1/(1+rpb))*(LAMP - BETAP*LAMP*((1+rpb)));
cr = -dr + w*nr + (1+rrd)*dr;
LAMR = 1/(cr^THETAA) ;
nr = (LAMR * w)^(1/PHII);
LAMR = LAMR * ((1+rrd));
y  = (A) * (k^ALPHAA) * (ne^(1-ALPHAA)); 
ce = y/x + be + q*(1-DELTA)*k - w*ne + (1+reb)*be;
be = MUE*q*(1-DELTA)*k*(1/reb);
LAME = ce^(-THETAA);
q  = (1/LAME)*((ALPHAA*LAME*y)/(x*k) + VE*MUE*q*(1-DELTA) + BETAE*LAME*q*(1-DELTA));
LAME = VE * (1+reb) + BETAE*LAME*(1+reb);
w = (1-ALPHAA)*y*(1/(x*ne));
bf = dr + kb;
kb = (1-DELTAB)*kb + OMEGA*jb;
jb = (1+rb)*bf - (1+rd)*dr - kb - CHIKB/2*((kb/bf)-VB)^2 * kb;
rb = rd - CHIKB*((kb/bf)-VB)*(kb/bf)^2;
EPSE = 1 + EPSE*(bp/be) + EPSE*(rb/reb);
EPSDR = 1 + (dp/dr) + EPSDR*(rd/rrd);
reb = rpb * (1/EPSBP) * (EPSBP-1);
rrd = rpd * (1/EPSDP) * (EPSDP-1);
EPSY = 1 + EPSY/x;
k = (1-DELTAE)*k + (1- CHIK/2 * ((i/i) - 1 )^2 * i);
y = G*cp + V*cr + (1-V)*ce + i;
ne=nr+np;   
bf = z*be + (1-z)*bp;
rd= MUR * RSS ;
log(MUR) = RHOR      *log(MUR(-1))    + exR;
log(A)   = RHOA      *log(A(-1))        + exA;        
log(MUE) = RHOMUE    *log(MUE(-1))      + exMUE;
%%
%% END OF THE MODEL SPECIFIC BLOCK.


%% DO NOT CHANGE THIS PART.
%%
%% Here we define the steady state values of the endogenous variables of
%% the model.
%%
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.
%%
%% END OF THE SECOND MODEL INDEPENDENT BLOCK.