% computes the steady state of MSF.mod. 
% Taken from an example file by Kevin Moran
% December 2013, Abdellah Manadir

function [ys,check] = MSF_steadystate(ys,exe)
global M_

%% 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.
%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% steady-state computations:

P_ss = 1;

Pstar_ss = P_ss;

Rh_ss = 1/bet -1 + delta ;

R_ss = 1/bet ;

Rn_ss = R_ss ;

q_ss = 1

Mp_ss = elas/(elas-1) ;

Mw_ss = elasw/(elasw -1) ;

pi_ss = 1;

G_ss = 0 ;

lx_ss = 0 ;

luw_ss = 0 ;

lup_ss = 0 ;

la_ss = 0 ;

fi_ss = 1/Mp_ss ;

W_ss = (((Rh_ss^alfa)/ fi_ss)*(alfa^-alfa)*((1-alfa)^(alfa-1)))^(1/(alfa-1)) ;

Wstar_ss = W_ss ;

Wh_ss = W_ss/Mw_ss ;

KL = (alfa/(1-alfa))*(W_ss/P_ss)*(1/Rh_ss) ;

L_ss = ((Wh_ss/P_ss)/((1-h)*((KL^alfa) -delta*KL)))^(1/(1+phi));

K_ss =KL*L_ss ;

I_ss = delta*K_ss ;

CL= (KL^alfa) -delta*KL;

C_ss= CL*L_ss ;

Y_ss = C_ss + I_ss ;

lambda_ss = 1/((1-h)*C_ss) ;

S1_ss = lambda_ss*L_ss*(W_ss^elasw)*(P_ss^(((1-elasw)*indexw)-1))*(1/(1-bet*probaw));

S2_ss = Wstar_ss*S1_ss/(P_ss^indexw);

S3_ss = lambda_ss*Y_ss*(P_ss^((1-elasw)*(indexp-1)))*(1/(1-bet*probap));

S4_ss = Pstar_ss*S3_ss/(P_ss^indexp) ;

U_ss = 1;


% Now ready to assign these "*_ss values to all variables


lambda = lambda_ss

C     = C_ss ;

R     = R_ss ; 
 
L    = L_ss  ;   

Wh   = Wh_ss ;

P    = P_ss ;

I     = I_ss ;

Rh         = Rh_ss ;

U          = U_ss ;

K          = K_ss ;

q          = q_ss ;


S1         = S1_ss ;


S2         = S2_ss ;

S3        = S3_ss ;

S4        = S4_ss ;

W         = W_ss ;

Wstar      =Wstar_ss

Mw         = Mw_ss ;


Y          = Y_ss ;

Mp         = Mp_ss ;

fi         = fi_ss ;


Pstar     = Pstar_ss ;

Rn        = Rn_ss ;

pi         =pi_ss ;

luw        = luw_ss ;

lup        = lup_ss ;

la         = la_ss ;

G          = G_ss ;

lx         = lx_ss ;       



%%
%% 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.