% ------------------------------------------------------
% This program defines the conditions needed to find the
% steady state value of formal hours worked using fsolve
% ------------------------------------------------------

function y=fun_rbc_optimal_tax_soe_Ramsey2(x,M_,ys)

%global M_
 
%% DO NOT CHANGE THIS PART.
%%
%% Here we load the values of the deep parameters in a loop.
%%
% 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

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

%%Define hours as unknown
  l_m=exp(x(1))/(1+exp(x(1)));


%Define only the steady state relationships needed to find the value of formal hours worked that supports
%the resource constraint relationship Y=C+I+G+NX
  z_m   = 1;
  R     = Rss;
  k2lm  = (((1/betta)-1+delta)/(alp*(1-tau_m)))^(1/(alp-1));
  y_m   = z_m*l_m*k2lm^((1-alp)/alp);
  w_m   = (1-tau_m)*(1-alp)*y_m/l_m;
  k     = k2lm*l_m;
  i     = delta*k;
  g     = GoverYf*y_m;                                         
  c_m   = (g-tau_m*y_m-tau_y*w_m*l_m)/tau_c; 
  bp    = bpss;          


%Resource constraint 
%this is the equation for which fsolve will find the solution
y = [y_m-c_m-i-g-R*bp];

