Пример #1
0
def TRAC(n, m):
    y_sum = 0
    z_sum = 0
    # print('in loop ' + str(i))
    tasks = generator.generate_tasks(m)
    bids = generator.generate_bids(0, tasks, n)
    bids_tmp = bids
    s, w = algorithm.WDBP(tasks, bids_tmp, r, n)
    print(s)
    print(w)
    # compute payment.
    p_all = 0
    for bid in s:
        bid_tmp = bid
        bid_tmp[0] = 0
        bids.remove(bid_tmp)
        bids_tmp = bids
        cb, p = algorithm.TMDP(bid_tmp, bids_tmp, n, m, r)
        bids.append(bid_tmp)
        # logging.info(p)
        p_all = p_all + p
    overpayment = (p_all - w) / w
    print(overpayment)
    y_sum += overpayment
    z_sum += w
    y_sum /= loop
    z_sum /= loop
Пример #2
0
def cdf(op, n, m):

    x = []
    y = []
    z = []
    p_list = []
    for i in range(0, n // 10):
        p_list.append(0)

    y_sum = 0
    z_sum = 0
    loop = 20
    for i in range(0, loop):
        tasks = generator.generate_tasks(m)
        bids = generator.generate_bids(op, tasks, n)
        bids_tmp = bids
        res = algorithm.WDBP(tasks, bids_tmp, r, n)
        s = res[0]
        w = res[1]
        logging.info(w)
        p_all = 0
        for bid in s:
            bid_tmp = bid
            bid_tmp[0] = 0
            bids.remove(bid_tmp)
            bids_tmp = bids
            ans = algorithm.TMDP(bid_tmp, bids_tmp, n, m, r)
            bids.append(bid_tmp)
            cd = ans[0]
            p = ans[1]
            print(bid[3])
            p_all = p_all + p
            p_list[bid[3]] += p
        overpayment = (p_all - w) / w
        logging.info(overpayment)
        y_sum += overpayment
        z_sum += w
    x.append(m)
    y.append(y_sum / loop)
    z.append(z_sum / loop)
    p_list = sorted(p_list)
    return p_list
Пример #3
0
def range_n(op):
    # x -- n, y -- overpayment ratio, z -- social cost.
    x = []
    y = []
    z = []
    for n in range(400, 1100, 100):
        # print('in n = ' + str(n))
        y_sum = 0
        z_sum = 0
        loop = 20
        for i in range(0, loop):
            # print('in loop ' + str(i))
            tasks = generator.generate_tasks(m)
            bids = generator.generate_bids(op, tasks, n)
            bids_tmp = bids
            s, w = algorithm.WDBP(tasks, bids_tmp, r, n)
            print(s)
            print(w)
            # logging.info(s)
            # logging.info(w)
            # compute payment.
            p_all = 0
            # print("s = " + str(len(s)))
            for bid in s:
                bid_tmp = bid
                bid_tmp[0] = 0
                bids.remove(bid_tmp)
                bids_tmp = bids
                cb, p = algorithm.TMDP(bid_tmp, bids_tmp, n, m, r)
                bids.append(bid_tmp)
                # logging.info(p)
                p_all = p_all + p
            overpayment = (p_all - w) / w
            print(overpayment)
            y_sum += overpayment
            z_sum += w
        x.append(n)
        y.append(y_sum / loop)
        z.append(z_sum / loop)
    return x, y, z
Пример #4
0
def range_m(op):
    x = []
    y = []
    z = []
    for m in range(10, 60, 10):
        y_sum = 0
        z_sum = 0
        loop = 20
        for i in range(0, loop):
            tasks = generator.generate_tasks(m)
            bids = generator.generate_bids(op, tasks, n)
            bids_tmp = bids
            res = algorithm.WDBP(tasks, bids_tmp, r, n)
            s = res[0]
            w = res[1]
            # logging.info(w)
            p_all = 0
            for bid in s:
                bid_tmp = bid
                bid_tmp[0] = 0
                bids.remove(bid_tmp)
                bids_tmp = bids
                ans = algorithm.TMDP(bid_tmp, bids_tmp, n, m, r)
                bids.append(bid_tmp)
                cd = ans[0]
                p = ans[1]
                # logging.info(p)
                p_all = p_all + p
            overpayment = (p_all - w) / w
            # logging.info(overpayment)
            y_sum += overpayment
            z_sum += w
        x.append(m)
        y.append(y_sum / loop)
        z.append(z_sum / loop)
    return x, y, z