!procedure added to EMPIRE including CFD


procedure CFD_support_policy
    declarations
        CFD_SUPPORT_START                    : integer;
        CFD_TECHNOLOGIES                     : set of integer;
        AVG_PM_PRICE                         : integer;
        MAX_CDF_SUP                          : integer;
        CFD_SUPPORT_FACTOR_TIDAL             : integer;!TECH 19 !based on inv year
        CFD_SUPPORT_FACTOR_WINDOFF           : integer;!TECH 21 !based on inv year
        CFD_SUPPORT_FACTOR_WINDON            : integer;!TECH 20 !based on inv year
        CFD_SUPPORT_FACTOR_SOLAR             : integer;!TECH 22 !based on inv year
        CFD_SUPPORT_FACTOR_NUCLEAR           : integer;!TECH 14 !based on inv year
        CFD_YEARS                            : set of integer; ! based on year
        Max_CFD_support_money                : array(YEARS) of integer;
        TECH_CFD_SUBSIDY                     : array(YEARS, TECHNOLOGIES)  of real;
        GEN_CFD                              : array(YEARS,GENERATORS) of real; 
        Max_CFD_support_volum_Ctr            : array(YEARS) of linctr;
        
        
    end-declarations
    
    !Hardcoded subsidy levels in EUR/MWh
        CFD_SUPPORT_FACTOR_TIDAL             := 182;
        CFD_SUPPORT_FACTOR_WINDOFF           := 168;
        CFD_SUPPORT_FACTOR_WINDON            := 112;
        CFD_SUPPORT_FACTOR_SOLAR             := 112;
!Technologies receiving CFD support
        CFD_TECHNOLOGIES                    := {19,20,21,22,14}; 
!Average assumed power price for the future
        AVG_PM_PRICE                        :=91; 
!first investment period of subsidy support
        CFD_SUPPORT_START   := 2;   ! 2 : year 2015
    
!Number of years each technology receive CFD subsidy is harcoded
    if(CFD_SUPPORT) then
        writeln("CFD support is used in this simulation");

        
            forall(yy in YEARS, tt in TECHNOLOGIES) do
                TECH_CFD_SUBSIDY(yy,tt) :=0;
            end-do
        
            if CFD_SUPPORT_FACTOR_TIDAL  > 0 then
                forall(yy in YEARS| yy>= CFD_SUPPORT_START and yy<=(CFD_SUPPORT_START + 30/5) and yy <=9) do
                    TECH_CFD_SUBSIDY(yy,19) :=  - (CFD_SUPPORT_FACTOR_TIDAL - AVG_PM_PRICE);
                end-do
            end-if
        
            if CFD_SUPPORT_FACTOR_WINDON    > 0 then
                forall(yy in YEARS| yy>= CFD_SUPPORT_START and yy<=(CFD_SUPPORT_START + 10/5) and yy <=9) do
                    TECH_CFD_SUBSIDY(yy,20) := - (CFD_SUPPORT_FACTOR_WINDON - AVG_PM_PRICE);
                end-do
            end-if
    
            if CFD_SUPPORT_FACTOR_WINDOFF    > 0 then
                forall(yy in YEARS| yy>= CFD_SUPPORT_START and yy<=(CFD_SUPPORT_START + 10/5) and yy <=9) do
                    TECH_CFD_SUBSIDY(yy,21) := - (CFD_SUPPORT_FACTOR_WINDOFF - AVG_PM_PRICE);
                end-do
            end-if
        
            if CFD_SUPPORT_FACTOR_SOLAR   > 0 then
                forall(yy in YEARS| yy>= CFD_SUPPORT_START and yy<=(CFD_SUPPORT_START + 10/5) and yy <=9) do
                    TECH_CFD_SUBSIDY(yy,22) := - (CFD_SUPPORT_FACTOR_SOLAR - AVG_PM_PRICE);
                end-do
            end-if
        
            if CFD_SUPPORT_FACTOR_NUCLEAR  > 0 then
                forall(yy in YEARS| yy>= CFD_SUPPORT_START and yy<=(CFD_SUPPORT_START + 30/5) and yy <=9) do
                    TECH_CFD_SUBSIDY(yy,14) := - (CFD_SUPPORT_FACTOR_NUCLEAR - AVG_PM_PRICE);
                end-do
            end-if
    
            forall(nn in {13}) do
                forall(yy in YEARS, gg in GENERATORS| GEN_NODE(gg)=nn ) do
                    if (GEN_TECH(gg) in CFD_TECHNOLOGIES) then
                        GEN_CFD(yy,gg) := TECH_CFD_SUBSIDY(yy,GEN_TECH(gg));
                    else
                        GEN_CFD(yy,gg) := 0;
                    end-if      
                end-do
            end-do
            
!Subsidy is added to the objective value
MinTotalExpectedCost+=
    sum(yy in YEARS) (1 + DISCOUNT_RATE)^(-LEAP*(yy-1)) * (
        ! Operational costs
        + 1/LEAP_CRF * ! Scale to get five year operational costs (assuming constant annual operation in this period)
            sum(ss in SCENARIOS) PROB(ss) * ( ! Expectation
                sum(hh in HOURS) ALPHA * SEASON_SCALE(hh) * ( ! Scale to get annual figure
                    sum(gg in GENERATORS | exists(gen_prod(ss, yy, hh, gg))) (
                        (GEN_CFD(yy,gg)) * gen_prod(ss, yy, hh, gg) ! Added CFD subsidy
                    )
                )
            )
    );
    
    else
            writeln("No CFD support in this simulation");
    end-if
end-procedure