Exemplo n.º 1
0
def annualize_present_value_period_cost(m, period, val):
    # convert a discounted, total cost per-period into an annual stream of costs
    discount_factor = (
        # this term is straight from financials.py
        # Conversion to lump sum at beginning of period
        financials.uniform_series_to_present_value(
            m.discount_rate, m.period_length_years[period]) *
        # Conversion to base year
        financials.future_to_present_value(
            m.discount_rate, (m.period_start[period] - m.base_financial_year)))
    return val / discount_factor
Exemplo n.º 2
0
def annualize_present_value_period_cost(m, period, val):
    # convert a discounted, total cost per-period into an annual stream of costs
    discount_factor = (
        # this term is straight from financials.py
        # Conversion to lump sum at beginning of period
        financials.uniform_series_to_present_value(
            m.discount_rate, m.period_length_years[period]) *
        # Conversion to base year
        financials.future_to_present_value(
            m.discount_rate, (m.period_start[period] - m.base_financial_year))
    )
    return val / discount_factor
Exemplo n.º 3
0
 def calc_tp_costs_in_period_one_scenario(m, p, s):
     return (sum(sum(
         # This are total costs in each tp for a scenario
         getattr(m, tp_cost)[t, s].expr() * m.tp_weight_in_year[t]
                 for tp_cost in m.cost_components_tp)
                 # Now, summation over timepoints 
                     for t in m.PERIOD_TPS[p]) *
         # Conversion to lump sum at beginning of period
         uniform_series_to_present_value(
             0, m.period_length_years[p]) *
         # Conversion to base year
         future_to_present_value(
             m.discount_rate, (m.period_start[p] - m.base_financial_year)))
Exemplo n.º 4
0
 def calc_tp_costs_in_period_one_scenario(m, p, s):
     return (sum(
         sum(
             # This are total costs in each tp for a scenario
             getattr(m, tp_cost)[t, s].expr() * m.tp_weight_in_year[t]
             for tp_cost in m.cost_components_tp)
         # Now, summation over timepoints
         for t in m.PERIOD_TPS[p]) *
             # Conversion to lump sum at beginning of period
             uniform_series_to_present_value(0, m.period_length_years[p]) *
             # Conversion to base year
             future_to_present_value(
                 m.discount_rate,
                 (m.period_start[p] - m.base_financial_year)))
Exemplo n.º 5
0
def calc_tp_costs_in_period(m, t):
        return sum(
            getattr(m, tp_cost)[t] * m.tp_weight_in_year[t]
            for tp_cost in m.cost_components_tp)

def calc_annual_costs_in_period(m, p):
        return sum(
            getattr(m, annual_cost)[p]
            for annual_cost in m.cost_components_annual)

# In the current version of Switch-Pyomo, all annual costs are defined 
# by First Stage decision variables, such as fixed O&M and capital 
# costs, which are caused by the BuildProj, BuildTrans and BuildLocalTD
# variables, all of which are considered as first stage decisions in this
# two-stage example.
# Likewise, all timepoint defined costs are caused by Second Stage decision
# variables, such as variable O&M and fuel use costs, which are caused by
# the DispatchProj variable. These will be considered as second stage
# decisions in this example.
# Further comments on this are written in the Readme file.

model.InvestmentCost = Expression(rule=lambda m: sum(
                calc_annual_costs_in_period(m, p) * financials.uniform_series_to_present_value(
                m.discount_rate, m.period_length_years[p]) * financials.future_to_present_value(
                m.discount_rate, (m.period_start[p] - m.base_financial_year)) for p in m.PERIODS))
model.OperationCost = Expression(rule=lambda m: sum(
                sum(calc_tp_costs_in_period(m, t) for t in m.PERIOD_TPS[p]) * financials.uniform_series_to_present_value(
                m.discount_rate, m.period_length_years[p]) * financials.future_to_present_value(
                m.discount_rate, (m.period_start[p] - m.base_financial_year)) for p in m.PERIODS))

print "model successfully loaded..."