function [ys,check] = aa2016_nonlinear_level_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

int = 1/bet;
sdf = bet;
% delta_delta= (1 /alph/lam^(sig+omg))^alph*(1/(1-alph)/(1-lam)^(sig+omg))^(1-alph); 
% delta_lam = delta_delta*lam^(sig*alph)*(1-lam)^(sig*(1-alph));
mc = 1- 1/thet;
Lu_Lc = (lam*(1 - alph)/(1-lam)/alph)^(1/(1+omg)); %under equal consumption
Y_Lc = lam^alph*(1-lam)^(1-alph)*Lu_Lc^(1-alph);
Cc = (mc/delta_lam/Y_Lc^omg)^((1+omg)/(omg+sig));
Lc = Cc^((1-sig)/(1+omg));
Lu = Lu_Lc*Lc;
Y = Y_Lc*Lc;
C = Cc;
G = Y - C;
Cu = Cc;
Wu  = Cu^sig*Lu^omg;
Wc = Cc^sig*Lc^omg;
Yf = Y;
deltat = lam*Cc/C;
g = lam - deltat;
x1 = mc*Y/(1-xi*bet);
x2 = Y/(1-xi*bet);
A = 1;
dpt = 1;
x=0;
infl =1;
inflstar=1;
ints = 1/bet;
%% end own model equations

for iter = 1:length(M_.params) %update parameters set in this steady state file, this is very important
  eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names(iter,:) ';' ])
end

%load steady states we calculated above to ys vector. We just used the
%variable name to calculate the steady states.
NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables
  varname = deblank(M_.endo_names(ii,:));
  eval(['ys(' int2str(ii) ') = log(' varname ');']); % we use log-level in model block;
end
