%==========================================================================
%       RBC MODEL WITH TWO SECTORS AND EPSTEIN-ZIN UTILITY FUNCTION
%==========================================================================

class{HOUSEHOLD}
{
    controls
    {   
        C[], A[], h[], obj[];
    };
    Objective
    {  
        Obj[]^phi = obj[]^phi + beta*(E[](Obj[1]^mu))^(phi/mu)          :lambda_beta[];
        Obj[];
    };
    constraints
    {
        A[]+C[] = A[-1]*(1+r[]) + PI[] + W[]*h[]                        : lambda_c[];
        obj[] = C[]^(1-util_sigma)/(1-util_sigma) - util_omega/(1+util_L)*h[]^(1+util_L)
                                                                        :lambda_C_util[];
    };
};

class{FIRM} 
{
    controls
    {   
        Y[], h[],K[],INV[],PI[];
    };
    Objective
    {   SPI[] = PI[] + beta*E[](lambda_c[1]/lambda_c[]*SPI[1])          : lambda_Y_Obj[];
        SPI[];
    };
    constraints
    {
        Y[] = exp(techn_Y[])*K[-1]^techn_alpha*h[]^(1-techn_alpha)      : lambda_Y_1[];
        K[] = (1-techn_delta)*K[-1] + INV[]                             : lambda_Y_2[];
        PI[] = P[]*Y[] - h[]*W[] - INV[]                                : lambda_Y_obj[];
    };
    definitions
    {
        techn_Y[] = rho_Y*techn_Y[-1] + signa_Y*epsilon_Y;
    };    
    shocks
    {     
        epsilon_Y ~ N(0,1);
    };    
    postfix
    {    
        T, N;
    };
    locals
    {
        techn_alpha, rho_Y, signa_Y,
        epsilon_Y,
        techn_Y[],P[];
    };    
};

class{FIRM_AGG} 
{
    controls
    {   
        Y[], Y_T[], Y_N[];
    };
    Objective
    {   ;
        PI_AGG[];
    };
    constraints
    {
        Y[] = (Y_T[]^rho+Y_N[]^rho)^(1\rho)                             : lambda_Y_AGG_1[];
        PI_AGG[] = Y[]-Y_T[]*P_T[]-Y_N[]*P_N[]                          : lambda_Y_AGG_2[];
    };
};

class{EQUILIBRIUM}
{
    definitions
    { 
        h[] = h_T[] + h_N[];
        PI[]= PI_T[]+PI_N[];
        A[] = 0;
    };
};