% computes the steady state of MSF.mod. 
% Taken from an example file by Kevin Moran
% October 2015, Nasreddine Ammar

function [ys,check] = model_general_steadystate(ys,exe)
global M_

%% DO NOT CHANGE THIS PART.
%%
%% Here we load the values of the deep parameters in a loop.
%%
NumberOfParameters = M_.param_nbr;                            % Number of deep parameters.
for i = 1:NumberOfParameters                                  % Loop...
  paramname = deblank(M_.param_names(i,:));                   %    Get the name of parameter i. 
  eval([ paramname ' = M_.params(' int2str(i) ');']);         %    Get the value of parameter i.
end                                                           % End of the loop.  
check = 0;
%%
%% END OF THE FIRST MODEL INDEPENDENT BLOCK.


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


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% steady-state computations:

qc_ss = (b*ebar*(1+wx)+d*wy*(-1+theta)-a*ebar*(wx+theta))/(2*ebar*(1+wz+wx*(2+wz-2*theta)-theta^2));

qf_ss = (a*ebar*(1+wx+wz)-b*ebar*(wx+theta)+d*wy*(-1-wz+theta))/(2*ebar*(1+wz+wx*(2+wz-2*theta)-theta^2));

pf_ss = a - qf_ss - theta*qc_ss;

pc_ss = b- qc_ss -theta*qf_ss;

qft_ss = (-d*wy*(2+wz-2*theta)+a*ebar*(1+wz-theta)+b*(ebar-ebar*theta))/(2*ebar*(1+wz+wx*(2+wz-2*theta)-theta^2));

qpt_ss = qft_ss-qf_ss;
Q_ss = 0.000000000000001;
e_ss = ebar;
lambda_ss = (b*ebar*(wx + wz + wx*wz - wx*theta) - a*ebar*(wx*(-1 + theta) + wz*theta) +  d*wy*(1 + wz*theta - theta^2))/(bet*(1 + wz +wx*(2 + wz - 2*theta) - theta^2));
% Now ready to assign these "*_ss values to all variables


qc = qc_ss;

qf = qf_ss;

pf = pf_ss;

pc = pc_ss;

qft = qft_ss;

qpt = qpt_ss;

Q = Q_ss;

e= e_ss;

lambda = lambda_ss;

%%
%% 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.
%%
NumberOfEndogenousVariables = M_.endo_nbr;                    % Number of endogenous variables.
ys = zeros(NumberOfEndogenousVariables,1);                    % Initialization of ys (steady state).
for i = 1:NumberOfEndogenousVariables                         % Loop...
  varname = deblank(M_.endo_names(i,:));                      %    Get the name of endogenous variable i.                     
  eval(['ys(' int2str(i) ') = ' varname ';']);                %    Get the steady state value of this variable.
end                                                           % End of the loop.
%%
%% END OF THE SECOND MODEL INDEPENDENT BLOCK.