Example #1
0
def get_policy_9_storage(ts, eta_in, eta_out, storage_capacity):
    if pos(ts).sum() * eta_in * eta_out < neg(ts).sum():
        beta = (pos(ts).sum() * eta_in * eta_out) / neg(ts).sum()
    else:
        beta = 1.
    storage_part = pos(ts) - beta * neg(ts)
    remainder = ts - storage_part
    storage_ts, used_storage = get_policy_2_storage(storage_part, eta_in, eta_out, storage_capacity)
    print used_storage
    return storage_ts + remainder, used_storage
Example #2
0
def get_policy_8_storage(ts, eta_in, eta_out, storage_capacity):
    storage_part = pos(ts) - (neg(ts) - constant.policy_8_capacity)
    if storage_part.min() >= 0:
        return ts, 0
    remainder = ts - storage_part
    storage_ts, used_storage = get_policy_2_storage(storage_part, eta_in, eta_out, storage_capacity)
    return storage_ts + remainder, used_storage
Example #3
0
def get_storage_data(gamma, alpha, storage_capacity, eta_in = 1., eta_out = 1., policy = 3, quantile = .99, mismatch = None):
    if not isnan(gamma):
        mismatch = get_mismatch(gamma, alpha)
    if mismatch.max() < 0 or mismatch.min() > 0:
        print "Warning!"
        new_mismatch = mismatch
    elif policy == 4:
        new_mismatch = get_mismatch_after_policy_4_storage(mismatch, eta_in, eta_out, storage_capacity)
    elif policy == 2:
        new_mismatch = get_mismatch_after_policy_2_storage(mismatch, eta_in, eta_out, storage_capacity)
    elif policy == 1:
        new_mismatch = get_mismatch_after_policy_1_storage(mismatch, eta_in, eta_out, storage_capacity)
    elif policy == 5:
        new_mismatch = get_mismatch_after_policy_5_storage(mismatch, eta_in, eta_out, storage_capacity)
    elif policy == 7:
        new_mismatch = get_mismatch_after_policy_7_storage(mismatch, eta_in, eta_out, storage_capacity)
    elif policy == 8:
        new_mismatch = get_mismatch_after_policy_8_storage(mismatch, eta_in, eta_out, storage_capacity)
    elif policy == 9:
        new_mismatch = get_mismatch_after_policy_9_storage(mismatch, eta_in, eta_out, storage_capacity)
    else:
        new_mismatch = get_mismatch_after_policy_3_storage(mismatch, eta_in, eta_out, storage_capacity)
    storage_transactions = mismatch - new_mismatch
    
    storage_filling = eta_in * pos(storage_transactions).cumsum() - neg(storage_transactions).cumsum() / eta_out
    storage_filling = storage_filling - storage_filling.min()

    storage_capacity = storage_filling.max()

    balancing = neg(new_mismatch)
    if policy == 8:
        balancing = balancing * (balancing > constant.policy_8_capacity) + constant.policy_8_capacity * (balancing <= constant.policy_8_capacity)
    
    #plot(storage_filling)

    excess = pos(new_mismatch)
    return storage_capacity, excess.mean(), mquantiles(excess, quantile), pos(storage_transactions).mean(), mquantiles(pos(storage_transactions), quantile), neg(storage_transactions).mean(), mquantiles(neg(storage_transactions), quantile), balancing.mean(), mquantiles(balancing, quantile), storage_filling.mean()
Example #4
0
def get_contours_for_limited_in_and_output_capacities(mismatch, eta_in = .6, eta_out = .6, N = 30, maxstorage = NaN, L = None):
    if L is None:
        L = N
    b_contour = empty([N,L])
    sc_contour = empty([N,L])
    inrange = linspace(0, mismatch.max(), N)
    outrange = linspace(0, -mismatch.min(), L)
    for i in arange(N):
        print "i: ", i, inrange[i]
        constant.policy_5_in_capacity = inrange[i]
        sc_contour[i,0] = 0
        b_contour[i,0] = neg(mismatch).mean()
        for j in arange(1,L):
            print "j: ", j, outrange[i]
            constant.policy_5_out_capacity = outrange[j]
            sc_contour[i,j], a, b, c, d, e, f, b_contour[i,j], g, h = get_storage_data(NaN, 1, maxstorage, eta_in, eta_out, 5, 1., mismatch)
    return inrange, outrange, b_contour, sc_contour
Example #5
0
 def find_equilibrium(K_B):
     storage_part = pos(mismatch) - pos(neg(mismatch) - K_B)
     return storage_part.sum()
Example #6
0
def get_balancing_from_mismatch(ts):
    return neg(ts).sum()