コード例 #1
0
def test0():                    # test shifting
    testing_ = 1
    threshold = 6
    optigoal = "Bill"
    shifting_ = 0
    c_load = 0
    meter = 1
    min_interval = 60
    csv_directory = "C:\Users\Bat Cave\Dropbox\My Files\Raw Data\house2"
    csv = "consumption.csv"
    csvpath = str(csv_directory) + "\\" + str(csv)
    housedata = ida.aggregatedatacsv(csvpath, min_interval)
    demand_ = housedata[1]
    occupants = [1, 1, 1, 1, 1, 1]
    routine_ = rb.routine_builder(demand_, min_interval, occupants)
    bill_type = 2
    bill_number = 1
    if optigoal == "Bill" and bill_type == 2:                    # if optimising for bill and eval at ToU bill
        shifting_ = 1                                             # enable appliance shifting
    all_billing = be.bill_eval(demand_, bill_type, bill_number, min_interval, c_load, meter, 0)
    cost_ = all_billing[1]
    expected_ = []
    appliancedemand = ida.deviceimport(housedata, min_interval, csv_directory, "No", "Yes", "No", "No", "No", "No",
                                       "No", "No", "No", "No", "No", "No", "No", "No")
    device_demand = appliancedemand[0][1]
    variation = clothesdryer(device_demand, routine_, min_interval, cost_, threshold, shifting_, testing_)
    print "        Variation: " + str(variation)
    if variation == expected_:
        print "Pass test 0: Testing device optimisation using minimisation\n"
    else:
        print "         Expected: " + str(expected_)
        print "***** Fail ***** test 0: Testing device optimisation using minimisation\n"
コード例 #2
0
def test0():                    # test shifting
    testing_ = 1
    threshold = 6
    optigoal = "Bill"
    shifting_ = 0
    c_load = 0
    meter = 1
    min_interval = 15
    csv_directory = "C:\Users\Bat Cave\Dropbox\My Files\Raw Data\house2"
    csv = "consumption.csv"
    csvpath = str(csv_directory) + "\\" + str(csv)
    housedata = ida.aggregatedatacsv(csvpath, min_interval)
    demand_ = housedata[1]
    occupants = [1, 1, 1, 1, 1, 1]
    routine_ = rb.routine_builder(demand_, min_interval, occupants)
    bill_type = 2
    bill_number = 1
    if optigoal == "Bill" and bill_type == 2:                    # if optimising for bill and eval at ToU bill
        shifting_ = 1                                             # enable appliance shifting
    all_billing = be.bill_eval(demand_, bill_type, bill_number, min_interval, c_load, meter, 0)
    cost_ = all_billing[1]
    expected_ = []
    devicedemand = ida.deviceimport(housedata, min_interval, csv_directory, "No", "No", "No", "No", "No", "No",
                                    "Yes", "No", "No", "No", "No", "No", "No", "No")
    device_demand = devicedemand[0][6]
    variation = secondfridge(device_demand, routine_, cost_, threshold, testing_)
    print "\n        Variation: " + str(variation)
    if variation == expected_:
        print "Pass test 0: Testing device optimisation using minimisation\n"
    else:
        print "         Expected: " + str(expected_)
        print "***** Fail ***** test 0: Testing device optimisation using minimisation\n"
コード例 #3
0
def test1():
    optigoal = "Bill"
    dataid = 4922
    meter = 1
    shifting_ = 1
    csvpath = "C:\Users\Bat Cave\Dropbox\My Files\Uni Work\Capstone\PeaconStreet\dataid_" + str(
        dataid) + "_localdate_07012013_AND_09302013.csv"
    min_interval = 15
    df = ida.peacon_street(csvpath, min_interval)
    houselevel_data = []
    for row in df[1][0]:
        houselevel_data.append(row)
    houselevel_cum_sum = np.cumsum(houselevel_data)
    plt.plot(houselevel_cum_sum, label='Unoptimised Household Demand')
    print "Total house level consumption = " + str(
        np.around(houselevel_cum_sum[-1], 2)) + " kWh"
    c_load = [0 for zero in range(0, len(houselevel_data))
              ]  # zero value matrix for controlled demand
    occupants = [2, 0, 0, 0, 0, 0]
    routine_ = rb.routine_builder(houselevel_data, min_interval, occupants)
    bill_type = 2
    cost_number = 54
    billing_info = be.bill_eval(houselevel_data, bill_type, cost_number,
                                min_interval, c_load, meter, 0)
    house_cost = be.billing_calc(houselevel_data, c_load, bill_type,
                                 billing_info[0], billing_info[1],
                                 billing_info[2], billing_info[3])
    print "Costing a total of $ " + str(np.around(sum(house_cost), 2))
    device_data = []
    for row in df[1][1]:
        device_data.append(row)
    skiplist = []
    count = 0
    for x in np.arange(0, len(device_data)):
        if not x in skiplist:
            if device_data[x] > 0:
                count += 1
                for z in np.arange(x, len(device_data)):
                    skiplist.append(z)
                    if device_data[z] == 0:
                        break
    original_cum_sum = np.cumsum(device_data)
    plt.plot(original_cum_sum, label='Unoptimised Device Demand')
    device_per = np.around(
        np.divide(original_cum_sum[-1], houselevel_cum_sum[-1]) * 100, 2)
    device_cost = be.billing_calc(device_data, c_load, bill_type, 0,
                                  billing_info[1], billing_info[2],
                                  billing_info[3])
    print "Device accounts for " + str(
        device_per) + "% of household consumption"
    print "A total of " + str(np.around(original_cum_sum[-1], 2)) + " kWh"
    print "The device costings a total of $ " + str(
        np.around(sum(device_cost), 2))
    print "Occuring in " + str(count) + " blocks"
    for i in np.arange(7, 8):
        hh_threshold = i
        if hh_threshold >= 6:
            print "\nThreshold number = " + str(hh_threshold)
        vari = airconditioner(device_data, routine_, min_interval,
                              billing_info[1], hh_threshold, shifting_, 0)
        print(np.sum(vari))
        var_cum_sum = np.cumsum(vari)
        optimised_cum_sum = original_cum_sum + var_cum_sum
        if hh_threshold >= 1000:
            plt.plot(optimised_cum_sum, label='Motivation Level = %i' % i)
            per_saved = np.around(
                100 - np.divide(np.max(optimised_cum_sum),
                                np.max(original_cum_sum)) * 100, 2)
            print "Percentage Saved = " + str(
                per_saved) + "% & kWh saved = " + str(
                    np.around((original_cum_sum[-1] - optimised_cum_sum[-1]),
                              2)) + " kWh"
            device_per = np.around(
                np.divide(optimised_cum_sum[-1],
                          houselevel_cum_sum[-1] + var_cum_sum[-1]) * 100, 2)
            optimised_device_data = [a + b for a, b in zip(device_data, vari)]
            opti_device_cost = be.billing_calc(optimised_device_data, c_load,
                                               bill_type, 0, billing_info[1],
                                               billing_info[2],
                                               billing_info[3])
            print "Saving a total of $ " + str(
                np.around(sum(device_cost) - sum(opti_device_cost), 2))
            print "Device accounts for " + str(
                device_per) + "% of household consumption"
            house_per_save = np.around(
                100 - np.divide(houselevel_cum_sum[-1] + var_cum_sum[-1],
                                houselevel_cum_sum[-1]) * 100, 2)
            print "Comparitive house level saving " + str(house_per_save) + "%"
            print "Optimised house level consumption " + str(
                np.around(houselevel_cum_sum[-1] + var_cum_sum[-1],
                          2)) + " kWh"
            optimised_house_level = [
                a + b for a, b in zip(houselevel_data, vari)
            ]
            houselevel_cost = be.billing_calc(optimised_house_level, c_load,
                                              bill_type, 0, billing_info[1],
                                              billing_info[2], billing_info[3])
            print "Costing a total of $ " + str(
                np.around(sum(houselevel_cost), 2))
コード例 #4
0
def test11():  # real kettle data treated as a cycle
    optigoal = "Bill"
    testing_ = 1
    shifting_ = 0
    min_interval = 60
    threshold = 1
    meal_appliance = 0
    c_load = 0
    meter = 1
    device_type = "Cycle"
    elimthres = 7
    minithres = 6
    minisaving = 20
    minicyclemax = 1
    minitime = 3600
    shiftthres = 5
    shifttime = 180
    subthres = 4
    subtype = "Cycle"
    subtime = 45
    subdemand = 1000
    subsaving = 15
    csv = "sound-system.csv"
    csvpath = "C:\Users\Bat Cave\Dropbox\My Files\Raw Data\house" + "\\" + str(
        csv)
    data = ida.aggregatedatacsv(csvpath, min_interval)
    demand_ = data[1]
    occupants = [1, 1, 1, 1, 1, 1]
    routine_ = rb.routine_builder(demand_, min_interval, occupants)
    bill_type = 2
    bill_number = 1
    if optigoal == "Bill" and bill_type == 2:  # if optimising for bill and eval at ToU bill
        shifting_ = 1  # enable appliance shifting
    all_billing = be.bill_eval(demand_, bill_type, bill_number, min_interval,
                               0, c_load, meter)
    cost_ = all_billing[1]
    expected_ = [[]]
    expected_saving = [[]]
    print "** Test 11 ** " + str(csv)
    variation = []
    for q in np.arange(0, 1):
        variation.append(
            testsettings(demand_, routine_, min_interval, cost_, threshold,
                         shifting_, testing_, meal_appliance, device_type,
                         elimthres, minithres, minisaving, minicyclemax,
                         minitime, shiftthres, shifttime, subthres, subtype,
                         subtime, subdemand, subsaving))

    vary_calc = []  # define variation calculation as a list
    max_saving = []  # define maximum savings as a list
    for m in np.arange(0, len(variation)):  # for all the different variations
        vary_calc.append(
            sum(variation[m]
                ))  # sum all the optimisation changes and add to a list
    min_variation_index = [
        i for i, x in enumerate(vary_calc) if x == min(vary_calc)
    ]  # find index of greatest saving
    for y in np.arange(
            0, len(min_variation_index
                   )):  # for all scenerios where the greatest saving is made
        max_saving.append(
            variation[min_variation_index[y]])  # add the variations to a list

    print "   Intervals optimised " + str(np.count_nonzero(max_saving[0]))
    print "       Variations: " + str(variation)
    print " Saving Variation: " + str(
        max_saving)  # print the max saving variation pattern list

    if variation == expected_ and max_saving == expected_saving:
        print "Pass test 11: real data \n"
    else:
        print "         Expected: " + str(expected_)
        print "  Expected saving: " + str(expected_saving)
        print "***** Fail ***** test 11: real data\n"
コード例 #5
0
def test10():  # real kettle data treated as a cycle
    optigoal = "Bill"
    testing_ = 1
    shifting_ = 0
    min_interval = 180
    c_load = 0
    meter = 1
    threshold = 6
    csv = "74-kettle-101-consumption.csv"
    csvpath = "C:\Users\Bat Cave\Dropbox\My Files\Raw Data\h1_150120\h1" + "\\" + "141229_150104_50_h1" + "\\" \
              + str(csv)
    kettledata = ida.aggregatedatacsv(csvpath, min_interval)
    demand_ = kettledata[1]
    occupants = [1, 1, 1, 1, 1, 1]
    routine_ = rb.routine_builder(demand_, min_interval, occupants)
    bill_type = 1
    bill_number = 1
    if optigoal == "Bill" and bill_type == 3:  # if optimising for bill and eval at ToU bill
        shifting_ = 1  # enable appliance shifting
    cost_ = be.bill_eval(demand_, bill_type, bill_number, min_interval, 0,
                         c_load, meter)
    expected_ = [[
        0.0, 0.0, 0.0, -68021.64893168, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        -74762.03088144002, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -96389.143949120044,
        0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -160431.63805943992, 0.0, 0.0,
        0.0, 0.0, 0.0, 0.0, -75922.154274079978, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0, -103159.85328527998, -68490.919669680006, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0, -58786.738587680011, 0.0, 0.0, 0.0, 0.0, 0.0
    ]]
    expected_saving = [[
        0.0, 0.0, 0.0, -68021.64893168, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        -74762.03088144002, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -96389.143949120044,
        0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -160431.63805943992, 0.0, 0.0,
        0.0, 0.0, 0.0, 0.0, -75922.154274079978, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0, -103159.85328527998, -68490.919669680006, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0, -58786.738587680011, 0.0, 0.0, 0.0, 0.0, 0.0
    ]]
    meal_appliance = 0
    device_type = "Cycle"
    elimthres = 7
    minithres = 6
    minisaving = 20
    minicyclemax = 1
    minitime = 3600
    shiftthres = 5
    shifttime = 60
    subthres = 4
    subtype = "Cycle"
    subtime = 45
    subdemand = 1000
    subsaving = 15
    variation = []
    print "** Test 10 **"
    for q in np.arange(0, 1):
        variation.append(
            testsettings(demand_, routine_, min_interval, cost_, threshold,
                         shifting_, testing_, meal_appliance, device_type,
                         elimthres, minithres, minisaving, minicyclemax,
                         minitime, shiftthres, shifttime, subthres, subtype,
                         subtime, subdemand, subsaving))
    print "       Variations: " + str(variation)

    vary_calc = []  # define variation calculation as a list
    max_saving = []  # define maximum savings as a list
    for m in np.arange(0, len(variation)):  # for all the different variations
        vary_calc.append(
            sum(variation[m]
                ))  # sum all the optimisation changes and add to a list
    min_variation_index = [
        i for i, x in enumerate(vary_calc) if x == min(vary_calc)
    ]  # find index of greatest saving
    for y in np.arange(
            0, len(min_variation_index
                   )):  # for all scenerios where the greatest saving is made
        max_saving.append(
            variation[min_variation_index[y]])  # add the variations to a list
    print " Saving Variation: " + str(
        max_saving)  # print the max saving variation pattern list
    print "   Intervals optimised " + str(np.count_nonzero(max_saving[0]))

    if variation == expected_ and max_saving == expected_saving:
        print "Pass test 10: real data \n"
    else:
        print "         Expected: " + str(expected_)
        print "  Expected saving: " + str(expected_saving)
        print "***** Fail ***** test 10: real data\n"
コード例 #6
0
def test1():
    optigoal = "Bill"
    dataid = 4922
    meter = 1
    shifting_ = 1
    csvpath = "C:\Users\Bat Cave\Dropbox\My Files\Uni Work\Capstone\PeaconStreet\dataid_" + str(
        dataid) + "_localdate_07012013_AND_09302013.csv"
    min_interval = 15
    df = ida.peacon_street(csvpath, min_interval)
    houselevel_data = []
    for row in df[1][0]:
        houselevel_data.append(row)
    houselevel_cum_sum = np.cumsum(houselevel_data)
    print "Total house level consumption = " + str(
        np.around(houselevel_cum_sum[-1], 2)) + " kWh"
    c_load = [0 for zero in range(0, len(houselevel_data))
              ]  # zero value matrix for controlled demand
    occupants = [2, 0, 0, 0, 0, 0]
    routine_ = rb.routine_builder(houselevel_data, min_interval, occupants)
    bill_type = 2
    cost_number = 54
    billing_info = be.bill_eval(houselevel_data, bill_type, cost_number,
                                min_interval, c_load, meter, 0)
    house_cost = be.billing_calc(houselevel_data, c_load, bill_type,
                                 billing_info[0], billing_info[1],
                                 billing_info[2], billing_info[3])
    print "Costing a total of $ " + str(np.around(sum(house_cost), 2))
    device_data = []
    for row in df[1][7]:  # <<<<----- Edit device number here
        device_data.append(row)
    skiplist = []
    count = 0
    for x in np.arange(0, len(device_data)):
        if not x in skiplist:
            if device_data[x] > 0:
                count += 1
                for z in np.arange(x, len(device_data)):
                    skiplist.append(z)
                    if device_data[z] == 0:
                        break
    original_cum_sum = np.cumsum(device_data)
    plt.plot(original_cum_sum, label='Unoptimised Device Demand')
    device_per = np.around(
        np.divide(original_cum_sum[-1], houselevel_cum_sum[-1]) * 100, 2)
    device_cost = be.billing_calc(device_data, c_load, bill_type, 0,
                                  billing_info[1], billing_info[2],
                                  billing_info[3])
    print "Device accounts for " + str(
        device_per) + "% of household consumption"
    print "A total of " + str(np.around(original_cum_sum[-1], 2)) + " kWh"
    print "The device costings a total of $ " + str(
        np.around(sum(device_cost), 2))
    print "Occuring in " + str(count) + " blocks \n"
    for i in np.arange(7, 8):
        hh_threshold = i
        if hh_threshold >= 7:
            print "\nThreshold number = " + str(hh_threshold)
        vari = clotheswasher(device_data, routine_, min_interval,
                             billing_info[1], hh_threshold, shifting_, 0)
        var_cum_sum = np.cumsum(vari)
        optimised_cum_sum = original_cum_sum + var_cum_sum
        if hh_threshold >= 7:
            plt.plot(optimised_cum_sum, label='Motivation Level = %i' % i)
            per_saved = np.around(
                100 - np.divide(np.max(optimised_cum_sum),
                                np.max(original_cum_sum)) * 100, 2)
            print "Percentage Saved = " + str(
                per_saved) + "% & kWh saved = " + str(
                    np.around((original_cum_sum[-1] - optimised_cum_sum[-1]),
                              2)) + " kWh"
            device_per = np.around(
                np.divide(optimised_cum_sum[-1],
                          houselevel_cum_sum[-1] + var_cum_sum[-1]) * 100, 2)
            optimised_device_data = [a + b for a, b in zip(device_data, vari)]
            opti_device_cost = be.billing_calc(optimised_device_data, c_load,
                                               bill_type, 0, billing_info[1],
                                               billing_info[2],
                                               billing_info[3])
            print "Saving a total of $ " + str(
                np.around(sum(device_cost) - sum(opti_device_cost), 2))
            print "Device accounts for " + str(
                device_per) + "% of household consumption"
            house_per_save = np.around(
                100 - np.divide(houselevel_cum_sum[-1] + var_cum_sum[-1],
                                houselevel_cum_sum[-1]) * 100, 2)
            print "Comparitive house level saving " + str(house_per_save) + "%"
            print "Optimised house level consumption " + str(
                np.around(houselevel_cum_sum[-1] + var_cum_sum[-1],
                          2)) + " kWh"
            optimised_house_level = [
                a + b for a, b in zip(houselevel_data, vari)
            ]
            houselevel_cost = be.billing_calc(optimised_house_level, c_load,
                                              bill_type, 0, billing_info[1],
                                              billing_info[2], billing_info[3])
            print "Costing a total of $ " + str(
                np.around(sum(houselevel_cost), 2))
    plt.legend(loc="best", fontsize='medium')
    w = len(device_data)
    plt.xlabel('Time Intervals (From 01/07/2013 [0] - 01/09/2013 [' + str(w) +
               '])')
    plt.ylabel('Kilowatt hours of Electricity (kWh)')
    plt.title('Impact of Behavioural Change on Clothes Washer Use (Data ID:' +
              str(dataid) + ")")
    plt.show()
コード例 #7
0
ファイル: Optimiser.py プロジェクト: tymiles003/Optimiser
    )

# End of demand aggregator
# Start of routine builder
if household_makeup == "Custom" or household_makeup == "custom":  # if exact situation needs to be specified
    occupant = [0 for i in range(0, 6)]
    occupant[0] = 2  # number of occupants with full time jobs
    occupant[1] = 0  # number of occupants with part time jobs
    occupant[2] = 0  # number of occupants with casual time jobs
    occupant[3] = 0  # number of occupants that are unemployed
    occupant[4] = 0  # number of occupants that are retired
    occupant[5] = 0  # number of children at school
    for z in np.arange(0, len(occupant)):  # loop through occupant list
        if occupant[z] > 1:  # if more then one occupant has the same job type
            occupant[z] = 1  # just enter 1, system treats it the same
    routinelist.append(rb.routine_builder(house_demand, mininterval, occupant))
    # at to list of routines to be evaluated
else:
    routinelist = rb.routineselect(house_demand, mininterval, household_makeup)
    # returns list of all routines that match criteria
routineloop = 0  # counts how many routines that are evaluated
for routine in routinelist:  # looping through all applicable routines
    routineloop += 1  # add one to routine counter
    # End of routine builder
    # Start household type
    householdcount = 0  # counts how many household loops are completed
    for xyz in np.arange(min_loop, max_loop):  # for each value between range
        if household_eval == "loop" or household_eval == "specific":
            threshold = xyz
        else:
            threshold = ht.householdthreshold(
コード例 #8
0
def test1():
    optigoal = "Bill"
    dataid = 4922
    meter = 1
    shifting_ = 1
    csvpath = "C:\Users\Bat Cave\Dropbox\My Files\Uni Work\Capstone\PeaconStreet\dataid_" + str(dataid) + "_localdate_07012013_AND_09302013.csv"
    min_interval = 15
    weather_forecast = weather(min_interval)     # import weather for the period being evaluated
    df = ida.peacon_street(csvpath, min_interval)
    houselevel_data = []
    for row in df[1][0]:
        houselevel_data.append(row)
    houselevel_cum_sum = np.cumsum(houselevel_data)
    # plt.plot(houselevel_cum_sum, label='Unoptimised House Level Demand')           # <<< --- House level demand graph
    print "Total house level consumption = " + str(np.around(houselevel_cum_sum[-1], 2)) + " kWh"
    c_load = [0 for zero in range(0, len(houselevel_data))]   # zero value matrix for controlled demand
    occupants = [2, 0, 0, 0, 0, 0]
    routine_ = rb.routine_builder(houselevel_data, min_interval, occupants)
    bill_type = 2
    cost_number = 54
    billing_info = be.bill_eval(houselevel_data, bill_type, cost_number, min_interval, c_load, meter, 0)
    house_cost = be.billing_calc(houselevel_data, c_load, bill_type, billing_info[0], billing_info[1], billing_info[2], billing_info[3])
    print "Costing a total of $ " + str(np.around(sum(house_cost), 2))
    device_data = []
    for row in df[1][11]:                                                    # <<<<----- Edit device number here
        device_data.append(row)
    skiplist = []
    count = 0
    for x in np.arange(0, len(device_data)):
        if not x in skiplist:
            if device_data[x] > 0:
                count += 1
                for z in np.arange(x, len(device_data)):
                    skiplist.append(z)
                    if device_data[z] == 0:
                        break
    original_cum_sum = np.cumsum(device_data)
    plt.plot(original_cum_sum, label='Unoptimised Device Demand')
    device_per = np.around(np.divide(original_cum_sum[-1], houselevel_cum_sum[-1])*100, 2)
    device_cost = be.billing_calc(device_data, c_load, bill_type, 0, billing_info[1], billing_info[2], billing_info[3])
    print "Device accounts for " + str(device_per) + "% of household consumption"
    print "A total of " + str(np.around(original_cum_sum[-1], 2)) + " kWh"
    print "The device costings a total of $ " + str(np.around(sum(device_cost), 2))
    print "Occuring in " + str(count) + " blocks"
    for i in np.arange(7, 8):
        hh_threshold = i
        if hh_threshold >= 7:
            print "\nThreshold number = " + str(hh_threshold)
        vari = clothesdryer(device_data, routine_, min_interval, billing_info[1], hh_threshold, shifting_, weather_forecast, 0)
        var_cum_sum = np.cumsum(vari)
        optimised_cum_sum = original_cum_sum + var_cum_sum
        if hh_threshold >= 7:
            plt.plot(optimised_cum_sum, label='Motivation Level = %i' % i)
            per_saved = np.around(100 - np.divide(np.max(optimised_cum_sum), np.max(original_cum_sum))*100, 2)
            print "Percentage Saved = " + str(per_saved) + "% & kWh saved = " + str(np.around((original_cum_sum[-1]-optimised_cum_sum[-1]), 2)) + " kWh"
            device_per = np.around(np.divide(optimised_cum_sum[-1], houselevel_cum_sum[-1]+var_cum_sum[-1])*100, 2)
            optimised_device_data = [a + b for a, b in zip(device_data, vari)]
            opti_device_cost = be.billing_calc(optimised_device_data, c_load, bill_type, 0, billing_info[1], billing_info[2], billing_info[3])
            print "Saving a total of $ " + str(np.around(sum(device_cost)-sum(opti_device_cost), 2))
            print "Device accounts for " + str(device_per) + "% of household consumption"
            house_per_save = np.around(100 - np.divide(houselevel_cum_sum[-1]+var_cum_sum[-1], houselevel_cum_sum[-1])*100, 2)
            print "Comparitive house level saving " + str(house_per_save) + "%"
            print "Optimised house level consumption " + str(np.around(houselevel_cum_sum[-1]+var_cum_sum[-1], 2)) + " kWh"
            optimised_house_level = [a + b for a, b in zip(houselevel_data, vari)]
            houselevel_cost = be.billing_calc(optimised_house_level, c_load, bill_type, 0, billing_info[1], billing_info[2], billing_info[3])
            print "Costing a total of $ " + str(np.around(sum(houselevel_cost), 2))
    plt.legend(loc="best", fontsize='medium')
    w = len(device_data)
    plt.xlabel('Time Intervals (From 01/07/2013 [0] - 01/09/2013 [' + str(w) + '])')
    plt.ylabel('Kilowatt hours of Electricity (kWh)')
    plt.title('Impact of Behavioural Change on Clothes Dryer Use (Data ID:' + str(dataid) + ")")
    plt.show()
コード例 #9
0
ファイル: Optimiser.py プロジェクト: mjwatson6116/Optimiser
    sys.exit("Data Source Error 1: Please select a valid data source as either 'own' or 'pecan'")

# End of demand aggregator
# Start of routine builder
if household_makeup == "Custom" or household_makeup == "custom":      # if exact situation needs to be specified
    occupant = [0 for i in range(0, 6)]
    occupant[0] = 2                                             # number of occupants with full time jobs
    occupant[1] = 0                                             # number of occupants with part time jobs
    occupant[2] = 0                                             # number of occupants with casual time jobs
    occupant[3] = 0                                             # number of occupants that are unemployed
    occupant[4] = 0                                             # number of occupants that are retired
    occupant[5] = 0                                             # number of children at school
    for z in np.arange(0, len(occupant)):                       # loop through occupant list
        if occupant[z] > 1:                                     # if more then one occupant has the same job type
            occupant[z] = 1                                     # just enter 1, system treats it the same
    routinelist.append(rb.routine_builder(house_demand, mininterval, occupant))
                                                                # at to list of routines to be evaluated
else:
    routinelist = rb.routineselect(house_demand, mininterval, household_makeup)
                                                                # returns list of all routines that match criteria
routineloop = 0                                                 # counts how many routines that are evaluated
for routine in routinelist:                                     # looping through all applicable routines
    routineloop += 1                                            # add one to routine counter
    # End of routine builder
    # Start household type
    householdcount = 0                                           # counts how many household loops are completed
    for xyz in np.arange(min_loop, max_loop):                    # for each value between range
        if household_eval == "loop" or household_eval == "specific":
            threshold = xyz
        else:
            threshold = ht.householdthreshold(xyz, household_type, optigoal)    # return the threshold value
コード例 #10
0
def test1():
    optigoal = "Bill"
    dataid = 4922
    meter = 1
    shifting_ = 1
    csvpath = "C:\Users\Bat Cave\Dropbox\My Files\Uni Work\Capstone\PeaconStreet\dataid_" + str(dataid) + "_localdate_07012013_AND_09302013.csv"
    min_interval = 15
    df = ida.peacon_street(csvpath, min_interval)
    houselevel_data = []
    for row in df[1][0]:
        houselevel_data.append(row)
    houselevel_cum_sum = np.cumsum(houselevel_data)
    plt.plot(houselevel_cum_sum, label='Unoptimised Household Demand')
    print "Total house level consumption = " + str(np.around(houselevel_cum_sum[-1], 2)) + " kWh"
    c_load = [0 for zero in range(0, len(houselevel_data))]   # zero value matrix for controlled demand
    occupants = [2, 0, 0, 0, 0, 0]
    routine_ = rb.routine_builder(houselevel_data, min_interval, occupants)
    bill_type = 2
    cost_number = 54
    billing_info = be.bill_eval(houselevel_data, bill_type, cost_number, min_interval, c_load, meter, 0)
    house_cost = be.billing_calc(houselevel_data, c_load, bill_type, billing_info[0], billing_info[1], billing_info[2], billing_info[3])
    print "Costing a total of $ " + str(np.around(sum(house_cost), 2))
    device_data = []
    for row in df[1][1]:
        device_data.append(row)
    skiplist = []
    count = 0
    for x in np.arange(0, len(device_data)):
        if not x in skiplist:
            if device_data[x] > 0:
                count += 1
                for z in np.arange(x, len(device_data)):
                    skiplist.append(z)
                    if device_data[z] == 0:
                        break
    original_cum_sum = np.cumsum(device_data)
    plt.plot(original_cum_sum, label='Unoptimised Device Demand')
    device_per = np.around(np.divide(original_cum_sum[-1], houselevel_cum_sum[-1])*100, 2)
    device_cost = be.billing_calc(device_data, c_load, bill_type, 0, billing_info[1], billing_info[2], billing_info[3])
    print "Device accounts for " + str(device_per) + "% of household consumption"
    print "A total of " + str(np.around(original_cum_sum[-1], 2)) + " kWh"
    print "The device costings a total of $ " + str(np.around(sum(device_cost), 2))
    print "Occuring in " + str(count) + " blocks"
    for i in np.arange(7, 8):
        hh_threshold = i
        if hh_threshold >= 6:
            print "\nThreshold number = " + str(hh_threshold)
        vari = airconditioner(device_data, routine_, min_interval, billing_info[1], hh_threshold, shifting_, 0)
        print(np.sum(vari))
        var_cum_sum = np.cumsum(vari)
        optimised_cum_sum = original_cum_sum + var_cum_sum
        if hh_threshold >= 1000:
            plt.plot(optimised_cum_sum, label='Motivation Level = %i' % i)
            per_saved = np.around(100 - np.divide(np.max(optimised_cum_sum), np.max(original_cum_sum))*100, 2)
            print "Percentage Saved = " + str(per_saved) + "% & kWh saved = " + str(np.around((original_cum_sum[-1]-optimised_cum_sum[-1]), 2)) + " kWh"
            device_per = np.around(np.divide(optimised_cum_sum[-1], houselevel_cum_sum[-1]+var_cum_sum[-1])*100, 2)
            optimised_device_data = [a + b for a, b in zip(device_data, vari)]
            opti_device_cost = be.billing_calc(optimised_device_data, c_load, bill_type, 0, billing_info[1], billing_info[2], billing_info[3])
            print "Saving a total of $ " + str(np.around(sum(device_cost)-sum(opti_device_cost), 2))
            print "Device accounts for " + str(device_per) + "% of household consumption"
            house_per_save = np.around(100 - np.divide(houselevel_cum_sum[-1]+var_cum_sum[-1], houselevel_cum_sum[-1])*100, 2)
            print "Comparitive house level saving " + str(house_per_save) + "%"
            print "Optimised house level consumption " + str(np.around(houselevel_cum_sum[-1]+var_cum_sum[-1], 2)) + " kWh"
            optimised_house_level = [a + b for a, b in zip(houselevel_data, vari)]
            houselevel_cost = be.billing_calc(optimised_house_level, c_load, bill_type, 0, billing_info[1], billing_info[2], billing_info[3])
            print "Costing a total of $ " + str(np.around(sum(houselevel_cost), 2))