switch_model/energy_sources/fuel_costs/simple.py
def define_components(mod):
    """

    Augments a Pyomo abstract model object with sets and parameters to
    describe simple fuel costs. Unless otherwise stated, each set and
    parameter is mandatory. Unless otherwise specified, all dollar
    values are real dollars in BASE_YEAR.

    ZONE_FUEL_PERIODS is a set that describes fuel availability. Each
    element of the set is (load_zone, fuel, period).

    fuel_cost[(z, f, p) in ZONE_FUEL_PERIODS] describes flat fuel costs
    for each supply of fuel. Costs can vary by load zone and period.

    GEN_TP_FUELS_UNAVAILABLE is a subset of
    GEN_TP_FUELS that describes which points don't have fuel
    available.

    Enforce_Fuel_Unavailability[(g, t, f) in
    GEN_TP_FUELS_UNAVAILABLE] is a constraint that restricts
    GenFuelUseRate to 0 for in load zones and periods where the
    projects' fuel is unavailable.

    FuelCostsPerTP[t in TIMEPOINTS] is an expression that summarizes fuel
    costs for the objective function.

    """

    mod.ZONE_FUEL_PERIODS = Set(
        dimen=3,
        input_file="fuel_cost.csv",
        validate=lambda m, z, f, p: (
            z in m.LOAD_ZONES and
            f in m.FUELS and
            p in m.PERIODS))
    mod.fuel_cost = Param(
        mod.ZONE_FUEL_PERIODS,
        input_file="fuel_cost.csv",
        within=NonNegativeReals)
    mod.min_data_check('ZONE_FUEL_PERIODS', 'fuel_cost')

    mod.GEN_TP_FUELS_UNAVAILABLE = Set(
        initialize=mod.GEN_TP_FUELS,
        filter=lambda m, g, t, f: (
            (m.gen_load_zone[g], f, m.tp_period[t])
            not in m.ZONE_FUEL_PERIODS))
    mod.Enforce_Fuel_Unavailability = Constraint(
        mod.GEN_TP_FUELS_UNAVAILABLE,
        rule=lambda m, g, t, f: m.GenFuelUseRate[g, t, f] == 0)

    # Summarize total fuel costs in each timepoint for the objective function
    def FuelCostsPerTP_rule(m, t):
        if not hasattr(m, 'FuelCostsPerTP_dict'):
            # cache all Fuel_Cost_TP values in a dictionary (created in one pass)
            m.FuelCostsPerTP_dict = {t2: 0.0 for t2 in m.TIMEPOINTS}
            for (g, t2, f) in m.GEN_TP_FUELS:
                if (m.gen_load_zone[g], f, m.tp_period[t2]) in m.ZONE_FUEL_PERIODS:
                    m.FuelCostsPerTP_dict[t2] += (
                        m.GenFuelUseRate[g, t2, f]
                        * m.fuel_cost[m.gen_load_zone[g], f, m.tp_period[t2]])
        # return a result from the dictionary and pop the element each time
        # to release memory
        return m.FuelCostsPerTP_dict.pop(t)
    mod.FuelCostsPerTP = Expression(mod.TIMEPOINTS, rule=FuelCostsPerTP_rule)
    mod.Cost_Components_Per_TP.append('FuelCostsPerTP')


    Augments a Pyomo abstract model object with sets and parameters to
    describe simple fuel costs. Unless otherwise stated, each set and
    parameter is mandatory. Unless otherwise specified, all dollar
    values are real dollars in BASE_YEAR.

    ZONE_FUEL_PERIODS is a set that describes fuel availability. Each
    element of the set is (load_zone, fuel, period).

    fuel_cost[(z, f, p) in ZONE_FUEL_PERIODS] describes flat fuel costs
    for each supply of fuel. Costs can vary by load zone and period.

    GEN_TP_FUELS_UNAVAILABLE is a subset of
    GEN_TP_FUELS that describes which points don't have fuel
    available.

    Enforce_Fuel_Unavailability[(g, t, f) in
    GEN_TP_FUELS_UNAVAILABLE] is a constraint that restricts
    GenFuelUseRate to 0 for in load zones and periods where the
    projects' fuel is unavailable.

    FuelCostsPerTP[t in TIMEPOINTS] is an expression that summarizes fuel
    costs for the objective function.

    
Augments a Pyomo abstract model object with sets and parameters to
describe simple fuel costs. Unless otherwise stated, each set and
parameter is mandatory. Unless otherwise specified, all dollar
values are real dollars in BASE_YEAR.

ZONE_FUEL_PERIODS is a set that describes fuel availability. Each
element of the set is (load_zone, fuel, period).

fuel_cost[(z, f, p) in ZONE_FUEL_PERIODS] describes flat fuel costs
for each supply of fuel. Costs can vary by load zone and period.

GEN_TP_FUELS_UNAVAILABLE is a subset of
GEN_TP_FUELS that describes which points don't have fuel
available.

Enforce_Fuel_Unavailability[(g, t, f) in
GEN_TP_FUELS_UNAVAILABLE] is a constraint that restricts
GenFuelUseRate to 0 for in load zones and periods where the
projects' fuel is unavailable.

FuelCostsPerTP[t in TIMEPOINTS] is an expression that summarizes fuel
costs for the objective function.
Augments a Pyomo abstract model object with sets and parameters to describe simple fuel costs . Unless otherwise stated each set and parameter is mandatory . Unless otherwise specified all dollar values are real dollars in BASE_YEAR . ZONE_FUEL_PERIODS is a set that describes fuel availability . Each element of the set is ( load_zone fuel period ) . fuel_cost [ ( z f p ) in ZONE_FUEL_PERIODS ] describes flat fuel costs for each supply of fuel . Costs can vary by load zone and period . GEN_TP_FUELS_UNAVAILABLE is a subset of GEN_TP_FUELS that describes which points don ' t have fuel available . Enforce_Fuel_Unavailability [ ( g t f ) in GEN_TP_FUELS_UNAVAILABLE ] is a constraint that restricts GenFuelUseRate to 0 for in load zones and periods where the projects ' fuel is unavailable . FuelCostsPerTP [ t in TIMEPOINTS ] is an expression that summarizes fuel costs for the objective function .
def define_components(mod):
    mod.ZONE_FUEL_PERIODS = Set(
        dimen=3,
        input_file="fuel_cost.csv",
        validate=lambda m, z, f, p: (
            z in m.LOAD_ZONES and
            f in m.FUELS and
            p in m.PERIODS))
    mod.fuel_cost = Param(
        mod.ZONE_FUEL_PERIODS,
        input_file="fuel_cost.csv",
        within=NonNegativeReals)
    mod.min_data_check('ZONE_FUEL_PERIODS', 'fuel_cost')
    mod.GEN_TP_FUELS_UNAVAILABLE = Set(
        initialize=mod.GEN_TP_FUELS,
        filter=lambda m, g, t, f: (
            (m.gen_load_zone[g], f, m.tp_period[t])
            not in m.ZONE_FUEL_PERIODS))
    mod.Enforce_Fuel_Unavailability = Constraint(
        mod.GEN_TP_FUELS_UNAVAILABLE,
        rule=lambda m, g, t, f: m.GenFuelUseRate[g, t, f] == 0)
    def FuelCostsPerTP_rule(m, t):
        if not hasattr(m, 'FuelCostsPerTP_dict'):
            m.FuelCostsPerTP_dict = {t2: 0.0 for t2 in m.TIMEPOINTS}
            for (g, t2, f) in m.GEN_TP_FUELS:
                if (m.gen_load_zone[g], f, m.tp_period[t2]) in m.ZONE_FUEL_PERIODS:
                    m.FuelCostsPerTP_dict[t2] += (
                        m.GenFuelUseRate[g, t2, f]
                        * m.fuel_cost[m.gen_load_zone[g], f, m.tp_period[t2]])
        return m.FuelCostsPerTP_dict.pop(t)
    mod.FuelCostsPerTP = Expression(mod.TIMEPOINTS, rule=FuelCostsPerTP_rule)
    mod.Cost_Components_Per_TP.append('FuelCostsPerTP')
def define_components ( mod ) : mod . ZONE_FUEL_PERIODS = Set ( dimen = 3 , input_file = "fuel_cost.csv" , validate = lambda m , z , f , p : ( z in m . LOAD_ZONES and f in m . FUELS and p in m . PERIODS ) ) mod . fuel_cost = Param ( mod . ZONE_FUEL_PERIODS , input_file = "fuel_cost.csv" , within = NonNegativeReals ) mod . min_data_check ( 'ZONE_FUEL_PERIODS' , 'fuel_cost' ) mod . GEN_TP_FUELS_UNAVAILABLE = Set ( initialize = mod . GEN_TP_FUELS , filter = lambda m , g , t , f : ( ( m . gen_load_zone [ g ] , f , m . tp_period [ t ] ) not in m . ZONE_FUEL_PERIODS ) ) mod . Enforce_Fuel_Unavailability = Constraint ( mod . GEN_TP_FUELS_UNAVAILABLE , rule = lambda m , g , t , f : m . GenFuelUseRate [ g , t , f ] == 0 ) def FuelCostsPerTP_rule ( m , t ) : if not hasattr ( m , 'FuelCostsPerTP_dict' ) : m . FuelCostsPerTP_dict = { t2 : 0.0 for t2 in m . TIMEPOINTS } for ( g , t2 , f ) in m . GEN_TP_FUELS : if ( m . gen_load_zone [ g ] , f , m . tp_period [ t2 ] ) in m . ZONE_FUEL_PERIODS : m . FuelCostsPerTP_dict [ t2 ] += ( m . GenFuelUseRate [ g , t2 , f ] * m . fuel_cost [ m . gen_load_zone [ g ] , f , m . tp_period [ t2 ] ] ) return m . FuelCostsPerTP_dict . pop ( t ) mod . FuelCostsPerTP = Expression ( mod . TIMEPOINTS , rule = FuelCostsPerTP_rule ) mod . Cost_Components_Per_TP . append ( 'FuelCostsPerTP' )
Augments a Pyomo abstract model object with sets and parameters to
describe simple fuel costs.
Augments a Pyomo abstract model object with sets and parameters to describe simple fuel costs .
"""

    Augments a Pyomo abstract model object with sets and parameters to
    describe simple fuel costs. Unless otherwise stated, each set and
    parameter is mandatory. Unless otherwise specified, all dollar
    values are real dollars in BASE_YEAR.

    ZONE_FUEL_PERIODS is a set that describes fuel availability. Each
    element of the set is (load_zone, fuel, period).

    fuel_cost[(z, f, p) in ZONE_FUEL_PERIODS] describes flat fuel costs
    for each supply of fuel. Costs can vary by load zone and period.

    GEN_TP_FUELS_UNAVAILABLE is a subset of
    GEN_TP_FUELS that describes which points don't have fuel
    available.

    Enforce_Fuel_Unavailability[(g, t, f) in
    GEN_TP_FUELS_UNAVAILABLE] is a constraint that restricts
    GenFuelUseRate to 0 for in load zones and periods where the
    projects' fuel is unavailable.

    FuelCostsPerTP[t in TIMEPOINTS] is an expression that summarizes fuel
    costs for the objective function.

    """ # Summarize total fuel costs in each timepoint for the objective function # cache all Fuel_Cost_TP values in a dictionary (created in one pass) # return a result from the dictionary and pop the element each time # to release memory
mod