function [ys,check] = btl_old_ramsey_steadystate(ys,exe)
global M_ lgy_
global p_theta p_nu p_beta p_delta p_mu p_alpha xi p_epsilon p_phi p_sigma p_rho p_omega yi p_u p_phim

if isfield(M_,'param_nbr') == 1
NumberOfParameters = M_.param_nbr;
for i = 1:NumberOfParameters
  paramname = deblank(M_.param_names(i,:));
  eval([ paramname ' = M_.params(' int2str(i) ');']);
end
check = 0;
end


% Model equations to be entered here

global p_theta p_nu p_u p_beta p_delta p_mu p_alpha xi yi p_epsilon p_phi p_sigma p_omega
 
% p_theta = 0.99; % savers' discount rate
% 
% p_beta = 0.985; % borrowers' discount rate
% 
% p_delta = 0.01; %quarterly house depreciation rate
% 
% p_mu = 0.90; %share of durables which is used as collateral
% 
% p_alpha = 0.84; % share of consumables in consumption basket
% 
% xi = 0.7; %share of profits paid to savers
% 
% yi = 0.1; %share of profits paid to Hand to Mouth
% 
% p_epsilon =11; % %elast of substitution 6 - 11
% 
% p_sigma =  2; %intertemp elast 1-4
% 
% p_phi =  1/3; %elast of labor 1/3 - 3
% 
% p_omega = 0.75; % calvo parameter
% 
% p_nu = 0.3; %scaling of poor workers labor in production 
% 
% p_u  = 0.4; %scaling of Borrowers labor in production

 
x0 = [1, 1, 1, 1, 1, 1, 1, 0.5, 1, 1];
[x,fval,exitflag] = fsolve(@BTL_I_NSS,x0); % Solving the nonlinear system
if exitflag < 1
    check=1;
end
C_b0 = x(1);
H_b0 = x(2);
w_b0 = x(3);
C_s0 = x(4);
H_s0 = x(5);
w_s0 = x(6);
C_p0 = x(7);
H_r0 = x(8);
w_p0 = x(9);
q_r0 = x(10);

eta0 = ((p_epsilon-1)/p_epsilon);

Rate0 = 1/p_theta;

Y_c0 = C_b0 + C_s0 + C_p0;

Y_h0 = p_delta*(H_b0+H_s0);

real_lagrange1_b0 = p_alpha*C_b0^(p_alpha-1)*(H_b0-H_r0)^(1-p_alpha)*(C_b0^p_alpha*(H_b0-H_r0)^(1-p_alpha))^(-p_sigma);

real_lagrange2_b0 = real_lagrange1_b0*(1-p_beta*Rate0)/Rate0;

d_o0 = (p_mu*(H_b0-H_r0))/Rate0;

real_lagrange_s0 = p_alpha*C_s0^(p_alpha-1)*H_s0^(1-p_alpha)*(C_s0^p_alpha*H_s0^(1-p_alpha))^(-p_sigma);

N_p_c0 = (eta0*p_nu*Y_c0)/w_p0;

N_b_c0 = (eta0*p_u*Y_c0)/w_b0;

N_s_c0 = (eta0*(1-p_u-p_nu)*Y_c0)/w_s0;

N_p_h0 = (eta0*p_nu*Y_h0)/w_p0;

N_b_h0 = (eta0*p_u*Y_h0)/w_b0;

N_s_h0 = (eta0*(1-p_u-p_nu)*Y_h0)/w_s0;

N_p0 = N_p_c0 + N_p_h0;

N_b0 = N_b_c0 + N_b_h0;

N_s0 = N_s_c0 + N_s_h0;

t_b0 = (1-xi-yi)*(1-eta0)*(Y_c0+Y_h0);

t_p0 = yi*(1-eta0)*(Y_c0+Y_h0);

t_s0 = xi*(Y_c0-w_s0*N_s_c0-w_b0*N_b_c0-w_p0*N_p_c0+Y_h0-w_s0*N_s_h0-w_b0*N_b_h0-w_p0*N_p_h0);

q_h0 = 1;


Z_c0 = 1;

Z_h0 = 1;

B_s0 = d_o0; 

R_s0 = Rate0;

         
real_lagrange1_b = 1;
w_b = 1;
w_p = 1;
N_p = 1;
q_r = 1;
C_p = 1;
H_r = 1;
t_p = 1;
N_b = 1;
C_b = 1;
H_b = 1;
q_h = 1;
real_lagrange2_b = 1;
Rate_o = 1;
d_o = 1;
t_b = 1;
N_s = 1;
C_s = 1;
H_s = 1;
w_s = 1;
real_lagrange_s = 1;
B_s = 1;
eta = 1;
Y_c = 1;
Z_c = 1;
N_b_c = 1;
N_s_c = 1;
N_p_c = 1;
N_p_h = 1;
N_b_h = 1;
N_s_h = 1;
Z_h = 1;
Y_h = 1;
t_s = 1;
R_s = 1;
v_pie = 0;
%%%% until here




for iter = 1:length(M_.params)
  eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names(iter,:) ';' ])
end

if isfield(M_,'param_nbr') == 1


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