function [ys,params,check] = Model_151221_test_steadystate(ys,exo,M_,options_)% for dynare 4.5.6

 
%% DO NOT CHANGE THIS PART.
%%
%% Here we load the values of the deep parameters in a loop.
%%
NumberOfParameters = M_.param_nbr;
for ii = 1:NumberOfParameters
  paramname = M_.param_names{ii};
  eval([ paramname ' = M_.params(' int2str(ii) ');']);
end
% initialize indicator
check = 0;
%
%%


%% THIS BLOCK IS MODEL SPECIFIC.
%%
%% Here the user has to define the steady state.
%%

%normalizations 
p1p = 1; 
p2p = 1; 
pie = 1; 
pie1 = 1; 
pie2 = 1;
mc1 = 1;
mc2 = 1;
q = 1;
f1 = 0;
f2 = 0; 
f = 0;

R = 1/c_betas;
c_betabhat = c_kappa*c_betas + (1-c_kappa)*c_betab;
j = c_j;
kappa = c_kappa; 

hbaovery = ((c_alpha1ba*c_zeta + c_alpha2ba*(1-c_zeta))/c_gammaba)*(((1-c_betabhat)/c_j + (1-c_betas)*c_kappa)^(-1));
hbnovery = ((c_alpha1bn*c_zeta + c_alpha2bn*(1-c_zeta))/c_gammabn)*(((1-c_betabhat)/c_j + (1-c_betas)*c_kappa)^(-1));
bbaovery = c_kappa*c_betas*hbaovery; 
bbnovery = c_kappa*c_betas*hbnovery; 
cbaovery = ((c_alpha1ba*c_zeta + c_alpha2ba*(1-c_zeta))/c_gammaba)-(1/c_betas-1)*bbaovery; 
cbnovery = ((c_alpha1bn*c_zeta + c_alpha2bn*(1-c_zeta))/c_gammabn)-(1/c_betas-1)*bbnovery; 

bsovery = (c_gammaba*bbaovery + c_gammabn*bbnovery)/(c_gammasa+c_gammasn);
bsaovery = bsovery; 
bsnovery = bsovery; 

csaovery = ((c_alpha1sa*c_zeta + c_alpha2sa*(1-c_zeta))/c_gammasa)+ (1/c_betas-1)*bsaovery; 
csnovery = ((c_alpha1sn*c_zeta + c_alpha2sn*(1-c_zeta))/c_gammasn)+ (1/c_betas-1)*bsnovery; 
hsaovery = csaovery*c_j/(1-c_betas); 
hsnovery = csnovery*c_j/(1-c_betas); 
hovery = c_gammaba*hbaovery + c_gammabn*hbnovery + c_gammasa*hsaovery + c_gammasn*hsnovery;

n1ba = (cbaovery^(-1/(1+c_eta)))*((c_alpha1ba*c_zeta/c_gammaba)^(1/(1+c_eta)));
n1bn = (cbnovery^(-1/(1+c_eta)))*((c_alpha1bn*c_zeta/c_gammabn)^(1/(1+c_eta)));
n1sa = (csaovery^(-1/(1+c_eta)))*((c_alpha1sa*c_zeta/c_gammasa)^(1/(1+c_eta)));
n1sn = (csnovery^(-1/(1+c_eta)))*((c_alpha1sn*c_zeta/c_gammasn)^(1/(1+c_eta)));
n2ba = (cbaovery^(-1/(1+c_eta)))*((c_alpha2ba*(1-c_zeta)/c_gammaba)^(1/(1+c_eta)));
n2bn = (cbnovery^(-1/(1+c_eta)))*((c_alpha2bn*(1-c_zeta)/c_gammabn)^(1/(1+c_eta)));
n2sa = (csaovery^(-1/(1+c_eta)))*((c_alpha2sa*(1-c_zeta)/c_gammasa)^(1/(1+c_eta)));
n2sn = (csnovery^(-1/(1+c_eta)))*((c_alpha2sn*(1-c_zeta)/c_gammasn)^(1/(1+c_eta)));

%productivity and output
a1 = 1; 
y1 = (n1ba^c_alpha1ba)*(n1bn^c_alpha1bn)*(n1sa^c_alpha1sa)*(n1sn^c_alpha1sn);
y = y1/c_zeta;
y2 = (1-c_zeta)*y;
a2 = y2/((n2ba^c_alpha2ba)*(n2bn^c_alpha2bn)*(n2sa^c_alpha2sa)*(n2sn^c_alpha2sn));

%borrowing, consumption, housing
bsaovery = bsovery; 
bsnovery = bsovery;
bba= y*bbaovery;
bbn= y*bbnovery;
bsa= y*bsaovery;
bsn= y*bsnovery;
bb = (c_gammabn*bbn + c_gammaba*bba)/(c_gammabn + c_gammaba);
cba= y*cbaovery;
cbn= y*cbnovery;
csa= y*csaovery;
csn= y*csnovery;
hba= y*hbaovery;
hbn= y*hbnovery;
hsa= y*hsaovery;
hsn= y*hsnovery;
h = y*hovery;

%wages
w1ba = c_alpha1ba*(y1/(c_gammaba*n1ba));
w2ba = c_alpha2ba*(y2/(c_gammaba*n2ba));
w1bn = c_alpha1bn*(y1/(c_gammabn*n1bn));
w2bn = c_alpha2bn*(y2/(c_gammabn*n2bn));
w1sa = c_alpha1sa*(y1/(c_gammasa*n1sa));
w2sa = c_alpha2sa*(y2/(c_gammasa*n2sa));
w1sn = c_alpha1sn*(y1/(c_gammasn*n1sn));
w2sn = c_alpha2sn*(y2/(c_gammasn*n2sn));

%sectoral consumption
c1 = y1;
c2 = y2;
c1ba = c_zeta*cba; 
c2ba = (1-c_zeta)*cba;
c1bn = c_zeta*cbn; 
c2bn = (1-c_zeta)*cbn; 
c1sa = c_zeta*csa; 
c2sa = (1-c_zeta)*csa;
c1sn = c_zeta*csn; 
c2sn = (1-c_zeta)*csn;

%Lagrange multiplier on borrowing constraint
deltaba = (1-c_betab/c_betas)*c_betas/cba; 
deltabn = (1-c_betab/c_betas)*c_betas/cbn; 

%welfare
uba = log(cba) + j*log(hba) - (n1ba^(1+c_eta))/(1+c_eta)- (n2ba^(1+c_eta))/(1+c_eta);
ubn = log(cbn) + j*log(hbn) - (n1bn^(1+c_eta))/(1+c_eta)- (n2bn^(1+c_eta))/(1+c_eta);
usa = log(csa) + j*log(hsa) - (n1sa^(1+c_eta))/(1+c_eta)- (n2sa^(1+c_eta))/(1+c_eta);
usn = log(csn) + j*log(hsn) - (n1sn^(1+c_eta))/(1+c_eta)- (n2sn^(1+c_eta))/(1+c_eta);
vba = uba/(1-c_betab);
vbn = ubn/(1-c_betab);
vsa = usa/(1-c_betas);
vsn = usn/(1-c_betas);
v = c_deltavba*vba + c_deltavbn*vbn + c_deltavsa*vsa + c_deltavsn*vsn;


%% 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.
%%
% %%
params=NaN(NumberOfParameters,1);
for iter = 1:length(M_.params) %update parameters set in the file
  eval([ 'params(' num2str(iter) ') = ' M_.param_names{iter} ';' ])
end

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

                                                           % End of the loop.
%%