% computes the steady state of codemarch25GM.mod. 

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




%%
%% 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.


A1 = 1;  %1
A1s = 1; %2

A2 = A2ss; %3

Rd = 1/betaH; %4
Rds = 1/betaHs; %5

Rx = (1-gammaa)*Rd + (gammaa/betaB); %6
Rxs = (1-gammaas)*Rds + (gammaas/betaBs); %7

RlIB = Rds*(1-gammaas*omegaIB) + ((gammaas*omegaIB)/betaBs); %24

Rbs = Rds+(phiBD/betaBs); %25
Rb = Rds+(phiBF/betaBs); %26


YtoK = (Rx-1+delta)/alphaa;
HtoK = (YtoK/A1)^(1/(1-alphaa));
YtoH = A1*(HtoK)^(-alphaa);

YtoKs = (Rxs-1+delta)/alphaa;
HtoKs = (YtoKs/A1s)^(1/(1-alphaa));
YtoHs = A1s*(HtoKs)^(-alphaa);

w = (1-alphaa)*YtoH; %8
ws = (1-alphaa)*YtoHs; %9

H = (w/ThetaH)^(1/(omegaH-1)); %10
Hs = (ws/ThetaH)^(1/(omegaH-1)); %11

Y = YtoH * H; %12
Ys = YtoHs * Hs; %13
K = Y  / YtoK ; %14
Ks= Ys / YtoKs; %15

G=mG*Yss; %16
Gs=mG*Ysss; %17

T=Tss; %18
Ts=Tsss; %19

M1 = (Rd-Rb)/(Rd-RlIB);
M2 = (Rd-Rbs)/(Rd-RlIB);

%BD = (M1/(A2ss*theta))^(1/(theta-1)); %27
%BF = (M2/(A2ss*theta*epsilon))^(1/(theta-1)); %28
BD=0;
BF=0;

BDs = (Ts-Gs)/(Rbs-1) - BF; %29
BFs = (T-G)/(Rb-1) - BD; %30

LIB = A2*((BD^theta) + epsilon*(BF^theta)); %31
LIBs = -LIB; %32
ss = LIBs; %33

%X = ((D + LIB)-(BD+BF))/(1-gammaa); %34
%Xs = (Ds + LIBs*(1-gammaas*omegaIB)-(BDs+BFs))/(1-gammaas); %35
X=K; %34
Xs = Ks; %35

%D = nu*C; %22
%Ds = nu*Cs; %23
D = X*(1-gammaa)-LIB+(BD+BF); %36
Ds = Xs*(1-gammaas)- LIBs*(1-gammaas*omegaIB)+(BDs+BFs); %37

%C = (w*H-T)/(1-(Rd-1)*nu); %20
%Cs = (ws*Hs-Ts)/(1-(Rds-1)*nu); %21

C = w*H+(Rd-1)*D-T; %20
Cs = ws*Hs+(Rds-1)*Ds-Ts; %21


%%%%WHAT GUARANTEES X=K???


e = gammaa*X; %36
es = gammaas*(Xs - omegaIB*LIBs); %37

CB = -e  + Rx*X +  Rb*BD +  Rbs*BF - Rd*D  - RlIB*LIB; %38
CBs = -es +Rxs*Xs +Rbs*BDs +Rb*BFs -Rds*Ds - RlIB*LIBs - (phiBD*BDs+phiBF*BFs); %39

I = delta*K; %42
Is = delta*Ks; %43

A1=log(A1);
A1s=log(A1s);
w=log(w);
ws=log(ws);
H=log(H);
Hs=log(Hs);
C=log(C);
Cs=log(Cs);
D=log(D);
Ds=log(Ds);
%Tss=log(T);
%Tsss=log(Ts);
%Gss=log(G);
%Gsss=log(Gs);
I=log(I);
Is=log(Is);
K=log(K);
Ks=log(Ks);
Y=log(Y);
Ys=log(Ys);
CB=log(CB);
CBs=log(CBs);
Rd=log(Rd);
Rds=log(Rds);
Rx=log(Rx);
Rxs=log(Rxs);
Rb=log(Rb);
Rbs=log(Rbs);
RlIB=log(RlIB);

%%
%% END OF THE MODEL SPECIFIC BLOCK.
%
%
%% 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 ';']);
  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.


