function [ys,check] = rethinking_steadystate(ys,exo)
% function [ys,check] = NK_baseline_steadystate(ys,exo)
% computes the steady state for the NK_baseline.mod and uses a numerical
% solver to do so
% Inputs: 
%   - ys        [vector] vector of initial values for the steady state of
%                   the endogenous variables
%   - exo       [vector] vector of values for the exogenous variables
%
% Output: 
%   - ys        [vector] vector of steady state values fpr the the endogenous variables
%   - check     [scalar] set to 0 if steady state computation worked and to
%                    1 of not (allows to impos restriction on parameters)

global M_ 

% read out parameters to access them with their name
NumberOfParameters = M_.param_nbr;
for ii = 1:NumberOfParameters
  paramname = deblank(M_.param_names(ii,:));
  eval([ paramname ' = M_.params(' int2str(ii) ');']);
end
% initialize indicator
check = 0;

%% Enter model equations here

options=optimset(); % set options for numerical solver



% the steady state computation follows FV (2006), section 4.1
a = 1;
sigma_m = 1;
cpi = 1; %zeros inflation steady state
R = cpi/betta-1; %nominal interest rate
q = 1;
%x_s means the steady state value of x;
mc = (epst-1)/epst;
r = (1-theta_1)/beta_se+(1+R)/cpi*theta_1-(1-deltta);
w = (1-alpha_s)*((alpha_s/r)^alpha_s*mc)^(1/(1-alpha_s));
%yk_sese_s = r/(mc*alpha_s);
n = ((1-h)*phi/(1-h*betta)*(1/((1-alpha_s)*mc))-deltta/r*alpha_s/(1-alpha_s))^(1/(-1-etta));
y = w*n/((1-alpha_s)*mc);
k = y/(r/(mc*alpha_s));
b = theta_1*k;
D = b;
invt = k*deltta;
c_se = y/mc-deltta*k-w*n+(1-(1+R)/cpi)*b;
c = y-c_se-invt;
lamt = (1-h*betta)/((1-h)*c);




%% end own model equations

for iter = 1:length(M_.params) %update parameters set in the file
  eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names(iter,:) ';' ])
end

NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables
  varname = deblank(M_.endo_names(ii,:));
  eval(['ys(' int2str(ii) ') = ' varname ';']);
end
