function[ys,params,check]=macropru_steadystate(ys,exe,M_,options_)

check = 0;

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

%转化为4.6版本dynare需要的代码修正,但好像没完全好
%size(M_.param_names) = M_.param_nbr;
%for jj=1:size(M_.param_names);
 %   paramname = M_.param_names(jj,:);
 %   eval([paramname,'=',num2str(M_.params(jj,:),10),';'])
%end

%Alpha is assigned to a matlab function, so need to declare it separately
alpha       = 0.3;
zeta        = xi_c;
zeta_chi    = xi_chi;
%Straightening differences between 1- and 2-country notation
tau_p       = tau_H;
mu_p        = mu_H;
theta_p     = theta_H;

%added by me 
rho_R = 0.95;
rho_m_chi = 0.95;
rho_m_chi_s = 0.95;


%Starting values for numerical solvers（就是initival）
global start
start.r_k   = 0.03;
start.l     = 4.5;


Delta_p     = 1;
Delta_L     = 1;
r           = 1/beta_P;
u           = 1;
pi_zeta_w   = pic_ss;
pi_zeta_p   = pic_ss;
pic         = pic_ss;
m_chi       = m_chi_ss;

p_k         = 1;
p_chi       = 1;
p_tilde     = 1;
R           = pic_ss/beta_P;
%r_k         = p_k*(1/beta_P-1+delta_k);
k           = 6.5;
mc          = tau_p/mu_p;
%w           = (1-alpha)*mc^(1/(1-alpha))*(r_k/alpha)^(-alpha/(1-alpha));


options     = optimset('MaxFunEvals',1000,'TolFun',1e-08);

f_l_rk    = @(x)solve_l_rk(x,beta_P,beta_I,pic_ss,tau_p,mu_p,alpha,omega_I,omega_P, ... 
            gy_ss,mu_L,tau_L,m_chi_ss,delta_chi,A_chi,sigma_chi,mu_n,A_n,sigma_n, ...
            mu_w,tau_w,theta_w,theta_p,theta_L,sigma_c,zeta,tax_I,zeta_chi,p_chi,R,k,mc);
[x,fval]    = fsolve(f_l_rk,[start.r_k,start.l],options);
r_k         = x(1);
l           = x(2);
w           = (1-alpha)*mc^(1/(1-alpha))*(r_k/alpha)^(-alpha/(1-alpha));
l_b         = omega_I*l;
R_Lb        = R;
R_L_tilde   = mu_L/tau_L*R_Lb;
R_L         = R_L_tilde;

k_tilde     = k;
i_k         = 0;
n           = (1-alpha)/alpha*r_k/w*k;
y           = k^alpha*n^(1-alpha);
t           = tax_I;

chi_I       = R_L*l/pic_ss/m_chi_ss/p_chi/(1-delta_chi);
u_c_I       = A_chi*(chi_I*(1-zeta_chi))^(-sigma_chi)/(1-beta_I*(1-delta_chi)-(1/R_L-beta_I/pic_ss)*m_chi_ss*pic_ss*(1-delta_chi))/p_chi;
lambda_2    = u_c_I*(1/R_L-beta_I/pic_ss);
Ppsi_L      = 0;
Ppsi_chi    = 0;

w_I_tilde   = (mu_w*A_n*n^sigma_n*w^(sigma_n*mu_n/(mu_n-1))/u_c_I/tau_w)^((1-mu_n)/(1-mu_n-sigma_n*mu_n));
w_I         = w_I_tilde;
n_I         = (w_I/w)^(mu_n/(1-mu_n))*n;
w_P         = omega_P^(mu_n-1)*(w^(1/(1-mu_n))-omega_I*w_I^(1/(1-mu_n)))^(1-mu_n);
w_P_tilde   = w_P;
n_P         = (w_P/w)^(mu_n/(1-mu_n))*n;
u_c_P       = mu_w*A_n*n_P^sigma_n/w_P_tilde/tau_w;
c_P         = u_c_P^(-1/sigma_c)*(1-zeta)^(-1);
c_I         = u_c_I^(-1/sigma_c)*(1-zeta)^(-1);
chi_P       = A_chi^(1/sigma_chi)*(u_c_P*(1-beta_P*(1-delta_chi)))^(-1/sigma_chi)/(1-zeta_chi);
chi         = omega_P*chi_P+omega_I*chi_I;
i_chi       = delta_chi*chi;
g           = gy_ss*y;
Omega_w_P   = (1-beta_P*theta_w)^(-1)*mu_w*A_n*w_P^(mu_w*(1+sigma_n)/(mu_w-1))*n_P^(1+sigma_n);
Omega_w_I   = (1-beta_I*theta_w)^(-1)*mu_w*A_n*w_I^(mu_w*(1+sigma_n)/(mu_w-1))*n_I^(1+sigma_n);
Upsilon_w_P = (1-beta_P*theta_w)^(-1)*u_c_P*tau_w*w_P^(mu_w/(mu_w-1))*n_P;
Upsilon_w_I = (1-beta_I*theta_w)^(-1)*u_c_I*tau_w*w_I^(mu_w/(mu_w-1))*n_I;
Omega_p     = (1-beta_P*theta_p)^(-1)*u_c_P*mc*y;
Upsilon_p   = (1-beta_P*theta_p)^(-1)*u_c_P*tau_p*y;
Omega_L     = (1-beta_P*theta_L)^(-1)*R_Lb*R_L^(mu_L/(mu_L-1))*l*u_c_P/pic;
Upsilon_L   = (1-beta_P*theta_L)^(-1)*tau_L*R_L^(mu_L/(mu_L-1))*l*u_c_P/pic;

eps_u       = 0;
eps_chi     = 0;
eps_n       = 0;
eps_i_chi   = 0;
eps_z       = 0;
eps_g       = 0;
eps_tau_H   = 0;
eps_tau_F   = 0;
eps_tau_w   = 0;
eps_tau_L   = 0;

%added by me
eps_R = 0;
eps_m_chi = 0;
eps_m_chi_s = 0;

% Foreign country + other specific to 2-country symmetric setup

Delta_L_s     = Delta_L;
r_s           = r;
u_s           = u;
pi_zeta_w_s   = pi_zeta_w;
pi_zeta_p_s   = pi_zeta_p;
pic_s         = pic;
m_chi_s       = m_chi;
p_tilde_s     = p_tilde;
R_s           = R;
r_k_s         = r_k;
mc_s          = mc;
w_s           = w;
k_s           = k;
l_s           = l;
l_b_s         = l_b;
R_Lb_s        = R_Lb;
R_L_tilde_s   = R_L_tilde;
R_L_s         = R_L;
k_tilde_s     = k_tilde;
i_k_s         = i_k;
n_s           = n;
y_s           = y;
t_s           = t;
u_c_I_s       = u_c_I;
chi_I_s       = chi_I;
lambda_2_s    = lambda_2;
Ppsi_L_s      = Ppsi_L;
Ppsi_chi_s    = Ppsi_chi;
w_I_tilde_s   = w_I_tilde;
w_I_s         = w_I;
n_I_s         = n_I;
w_P_s         = w_P;
w_P_tilde_s   = w_P_tilde;
n_P_s         = n_P;
u_c_P_s       = u_c_P;
c_P_s         = c_P;
c_I_s         = c_I;
chi_P_s       = chi_P;
chi_s         = chi;
i_chi_s       = i_chi;
g_s           = g;
Omega_w_P_s   = Omega_w_P;
Omega_w_I_s   = Omega_w_I;
Upsilon_w_P_s = Upsilon_w_P;
Upsilon_w_I_s = Upsilon_w_I;
Omega_L_s     = Omega_L;
Upsilon_L_s   = Upsilon_L;

eps_u_s       = 0;
eps_chi_s     = 0;
eps_n_s       = 0;
eps_i_chi_s   = 0;
eps_z_s       = 0;
eps_g_s       = 0;
eps_tau_H_s   = 0;
eps_tau_F_s   = 0;
eps_tau_w_s   = 0;
eps_tau_L_s   = 0;
eps_rho       = 0;

q             = 1;
Ttheta        = lambda_2;
Ttheta_s      = Ttheta;
Ppsi_chi      = -Ttheta*(m_chi*p_chi*pic*(1-delta_chi));
Ppsi_chi_s    = Ppsi_chi;
Ppsi_L        = Ttheta*R_L;
Ppsi_L_s      = Ppsi_L;

pH_tilde      = 1;
pH_tilde_s    = pH_tilde;
pF_tilde      = 1;
pF_tilde_s    = pF_tilde;
pH            = pH_tilde;
pH_s          = pH;
pF            = pF_tilde;
pF_s          = pF;

c             = omega_I*c_I + omega_P*c_P;
c_s           = c;
cH            = eta_c*pH^(-mu_c/(mu_c - 1))*c;
cF            = (1-eta_c)*pF^(-mu_c/(mu_c - 1))*c;
cH_s          = eta_c_s*pH_s^(-mu_c_s/(mu_c_s - 1))*c_s;
cF_s          = (1 - eta_c_s)*pF_s^(-mu_c_s/(mu_c_s - 1))*c_s;

p_ichi        = (eta_chi*pH^(1/(1-mu_chi))+(1-eta_chi)*pF^(1/(1-mu_chi)))^(1-mu_chi);
p_ichi_s      = p_ichi;
i_chiH        = eta_chi*(pH/p_ichi)^(mu_chi/(1-mu_chi))*i_chi;
i_chiF        = (1-eta_chi)*(pF/p_ichi)^(mu_chi/(1-mu_chi))*i_chi;
i_chiH_s      = eta_chi_s*(pH_s/p_ichi_s)^(mu_chi_s/(1-mu_chi_s))*i_chi_s;
i_chiF_s      = (1-eta_chi_s)*(pF_s/p_ichi_s)^(mu_chi_s/(1-mu_chi_s))*i_chi_s;
p_chi         = p_ichi;
p_chi_s       = p_chi;

p_g           = (eta_g*pH^(1/(1-mu_g))+(1-eta_g)*pF^(1/(1-mu_g)))^(1-mu_g);
p_g_s         = p_g;
gH            = eta_g*(pH/p_g)^(-mu_g/(mu_g-1))*g;
gF            = (1-eta_g)*(pF/p_g)^(-mu_g/(mu_g-1))*g;
gF_s          = (1-eta_g_s)*(pF_s/p_g_s)^(-mu_g_s/(mu_g_s-1))*g_s;
gH_s          = eta_g_s*(pH_s/p_g_s)^(-mu_g_s/(mu_g_s-1))*g_s;

zeta_piH      = pic_ss;
zeta_piH_s    = zeta_piH;
zeta_piF      = pic_ss;
zeta_piF_s    = zeta_piF;
Delta_H       = 1;
Delta_H_s     = Delta_H;
Delta_F       = 1;
Delta_F_s     = Delta_F;

yH            = cH + i_chiH + gH;
yF            = cF + i_chiF + gF;
yH_s          = cH_s + i_chiH_s + gH_s;
yF_s          = cF_s + i_chiF_s + gF_s;

Omega_H       = (1-beta_P*theta_H)^(-1)*u_c_P*mc*yH;
Omega_F       = (1-beta_P*theta_F)^(-1)*u_c_P*mc_s*yF;
Omega_H_s     = (1-beta_P*theta_H_s)^(-1)*u_c_P*mc*yH_s;
Omega_F_s     = (1-beta_P*theta_F_s)^(-1)*u_c_P*mc_s*yF_s;
Upsilon_H     = (1-beta_P*theta_H)^(-1)*u_c_P*tau_p*yH;
Upsilon_F     = (1-beta_P*theta_F)^(-1)*u_c_P*tau_p*yF;
Upsilon_H_s   = (1-beta_P*theta_H_s)^(-1)*u_c_P*tau_p*yH_s;
Upsilon_F_s   = (1-beta_P*theta_F_s)^(-1)*u_c_P*tau_p*yF_s;

d             = 0;
rho           = 1;
l_Fb_tilde    = 0;
l_Hb_tilde    = l_b;

y_eur = omega*y + (1-omega)*y_s;
pic_eur = (pic^(omega))*(pic_s^(1-omega));
dR            = 0;
dR_s          = 0;
dv            = 0;
dv_s          = 0;           
dm_chi 		  = 0;           
dm_chi_s	  = 0;
ly 			  = l_b/y;
ly_s 		  = l_b_s/y_s;

logc = 100*log(c);
logi_chi = 100*log(i_chi);
logl = 100*log(l);
logc_s = 100*log(c_s);
logi_chi_s = 100*log(i_chi_s);
logl_s = 100*log(l_s);
logy = 100*log(y);
logy_s = 100*log(y_s);
c_eur = c; 
l_eur = l; 
i_chi_eur = i_chi; 
p_chi_eur = p_chi; 
R_L_eur = R_L; 
logc_eur = 100*log(c_eur);
logi_chi_eur = 100*log(i_chi_eur);
logl_eur = 100*log(l_eur);


Util_P = ((c_P - xi_c*c_P)^(1-sigma_c)/(1-sigma_c) + A_chi*((1-xi_chi)*chi_P)^(1-sigma_chi)/(1-sigma_chi)- A_n/(1+sigma_n)*n_P^(1+sigma_n))/(1 - beta_P);
Util_I = ((c_I - xi_c*c_I)^(1-sigma_c)/(1-sigma_c) + A_chi*((1-xi_chi)*chi_I)^(1-sigma_chi)/(1-sigma_chi)- A_n/(1+sigma_n)*n_I^(1+sigma_n))/(1 - beta_I);
Util   = omega_P*(1-beta_P)*Util_P + omega_I*(1-beta_I)*Util_I;
Delta_w_P = 1;
Delta_w_I = 1;


%% end own model equations

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
