コード例 #1
0
ファイル: mpolicies.py プロジェクト: TueVJ/stBaCU
def get_policy_7_storage(ts, eta_in, eta_out, storage_capacity):
    storage_part = pos(ts) - pos(neg(ts) - constant.policy_7_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
コード例 #2
0
ファイル: mpolicies.py プロジェクト: TueVJ/stBaCU
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
コード例 #3
0
ファイル: mpolicies.py プロジェクト: TueVJ/stBaCU
def old_storage(ts, eta_in = 1., eta_out = 1., storage_capacity = NaN):
    indices, integrals = get_indices_and_integrals(ts)
    storing_potential = eta_in * eta_out * sum(integrals * (integrals > 0))
    extracting_potential = -sum(integrals * (integrals < 0))

    storage_start, used_storage = get_storage_start(integrals, eta_in, eta_out, 
                                      storage_capacity, 
                                      storing_potential > extracting_potential)
    
    storage_usage_ts = get_storage_usage_ts(integrals, storage_start, eta_in, eta_out, storage_capacity, storing_potential > extracting_potential)
    
    extracting = zeros_like(ts)
    storing = zeros_like(ts)

    end_to_start_slice = concatenate((ts[indices[-1] + 1:],ts[:indices[0] + 1]))
    if storage_usage_ts[0] < 0:
        end_to_start_extracting = pos(-end_to_start_slice - find_height(-end_to_start_slice, -storage_usage_ts[0]))
        extracting[indices[-1] + 1:] = -end_to_start_extracting[:len(extracting[indices[-1] + 1:])]
        extracting[:indices[0] + 1] = -end_to_start_extracting[len(extracting[indices[-1] + 1:]):]
    else:
        end_to_start_storing = pos(end_to_start_slice - find_height(end_to_start_slice, storage_usage_ts[0]))
        storing[indices[-1] + 1:] = end_to_start_storing[:len(extracting[indices[-1] + 1:])]
        storing[:indices[0] + 1] = end_to_start_storing[len(extracting[indices[-1] + 1:]):]
    
    for x in arange(len(indices)-1) + 1:
        #print x
        if storage_usage_ts[x] < 0:
            #print storage_usage_ts[x]
            #print indices[x]
            extracting[indices[x - 1] + 1: indices[x] + 1] = -pos(-ts[indices[x - 1] + 1: indices[x] + 1] - find_height(-ts[indices[x - 1] + 1: indices[x] + 1], -storage_usage_ts[x]))
        else:
            storing[indices[x - 1] + 1: indices[x] + 1] = pos(ts[indices[x - 1] + 1: indices[x] + 1] - find_height(ts[indices[x - 1] + 1: indices[x] + 1], storage_usage_ts[x]))

    #plot(storing, lw = 2)
    #plot(extracting, lw = 2)
    #plot(ts)
    #plot(ts - storing - extracting+ 1)

    return(ts - storing - extracting)
コード例 #4
0
ファイル: mfunc.py プロジェクト: TueVJ/stBaCU
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()
コード例 #5
0
ファイル: mfunc.py プロジェクト: TueVJ/stBaCU
 def find_equilibrium(K_B):
     storage_part = pos(mismatch) - pos(neg(mismatch) - K_B)
     return storage_part.sum()