Example #1
0
def linear():
    '''
    Create a linear bid curve for one generators.
    Ensure that correct cost is valued for the load.
    '''
    a = 5
    b = 30
    Pd = 221
    generators = [Generator(costcurveequation='{}+{}P'.format(a, b))]
    _, times = solve_problem(generators, **make_loads_times(Pd))
    cost = generators[0].bids.output(times[0], evaluate=True)
    assert cost == a + b * Pd
Example #2
0
def rolling():
    '''
    Run a basic unit commitment over 72hrs
    Ensure that the generation meets the load for each time.
    '''
    generators = [Generator(costcurveequation='10P+.01P^2')]
    Pdt = [random.randrange(0, 200) for i in range(0, 72)]
    power_system, times = solve_problem(generators,
                                        **make_loads_times(Pdt=Pdt))
    load = power_system.loads()[0]
    load_balanced = all(generators[0].power(t) == load.power(t) for t in times)
    assert load_balanced
Example #3
0
def cubic_non_convex():
    '''
    Create a cubic, but non-convex (negative cubic term) bid curve for one generators.
    Ensure that linearized cost is within +5% of the true cost
    '''
    Pd = 221
    a = 5
    b = 30
    c = .2
    d = .0001
    generators = [
        Generator(costcurveequation='{}+{}P+{}P^2 - {}P^3'.format(a, b, c, d))
    ]
    power_system, times = solve_problem(generators, **make_loads_times(Pd))

    cost = generators[0].bids.output(times[0], evaluate=True)
    actual_cost = a + b * Pd + c * Pd**2 + -1 * d * Pd**3
    assert actual_cost <= cost <= 1.05 * actual_cost
Example #4
0
def coverage():
    '''
    Make sure that the bid range covers the whole pmin-pmax range
    '''
    Pd = 221
    a = 5
    b = 30
    c = .2
    d = .1
    pmin = 10
    pmax = 559
    generators = [
        Generator(costcurveequation='{}+{}P+{}P^2+{}P^3'.format(a, b, c, d),
                  pmin=pmin,
                  pmax=pmax)
    ]
    _, times = solve_problem(generators, **make_loads_times(Pd))
    bid_points = generators[0].bids.discrete_input_points
    assert pmin == bid_points[0] and pmax == bid_points[-1]
Example #5
0
def cubic_convex():
    """
    Create a cubic, convex bid curve for one generators.
    Ensure that linearized cost is within +5% of the true cost
    """
    Pd = 221
    a = 5
    b = 30
    c = 0.2
    d = 0.1
    user_config.breakpoints = 10

    generators = [Generator(costcurveequation="{}+{}P+{}P^2+{}P^3".format(a, b, c, d))]
    _, times = solve_problem(
        generators, **make_loads_times(Pd)
    )  # ,problem_filename='bidproblem.lp')
    cost = value(generators[0].bids.output(times[0], evaluate=True))
    actual_cost = a + b * Pd + c * Pd ** 2 + d * Pd ** 3
    assert actual_cost <= cost and cost <= 1.05 * actual_cost
Example #6
0
def make_expensive_gen(**kwargs):
    if 'costcurveequation' not in kwargs:
        kwargs['costcurveequation'] = '{}P'.format(gen_costs['expensive'])
    return Generator(name='expensive gen', **kwargs)
Example #7
0
def make_mid_gen(**kwargs):
    return Generator(name='middle-range gen',
                     costcurveequation='{}P'.format(gen_costs['mid']),
                     **kwargs)
Example #8
0
def make_cheap_gen(**kwargs):
    return Generator(name='cheap gen',
                     costcurveequation='{}P'.format(gen_costs['cheap']),
                     **kwargs)
Example #9
0
def make_expensive_gen(**kwargs):
    if "costcurveequation" not in kwargs:
        kwargs["costcurveequation"] = "{}P".format(gen_costs["expensive"])
    return Generator(name="expensive gen", **kwargs)
Example #10
0
def make_mid_gen(**kwargs):
    return Generator(name="middle-range gen",
                     costcurveequation="{}P".format(gen_costs["mid"]),
                     **kwargs)
Example #11
0
def make_cheap_gen(**kwargs):
    return Generator(name="cheap gen",
                     costcurveequation="{}P".format(gen_costs["cheap"]),
                     **kwargs)