Esempio n. 1
0
def UMMP_time_dummy():
    size = [20, 30, 40]

    times = []

    for s in size:

        ufuncs = utility.read_ufuncs("../data/ufuncs/uf_" + str(s * (s - 1)) +
                                     ".txt")

        scaled_ufuncs = utility.scale_ufuncs(ufuncs)

        pl_mat, cms, c = topo.read_data("../data/topologies/waxman_" + str(s) +
                                        "_3_" + str(s * (s - 1)) + ".txt")

        new_c = [10000.0 for i in range(len(c))]
        c = new_c

        pl_mat = np.matrix(pl_mat)

        start_time = time.time()
        cm_alloc, paths_alloc, useful_when_error = UMMP.max_min_program(
            pl_mat, cms, c, scaled_ufuncs, len(cms))
        tot_time = time.time() - start_time

        times.append(tot_time)

    print(times)
Esempio n. 2
0
def congestion_time():

    caps = [4000.0, 6000.0, 8000.0, 10000.0]

    times = []

    for cap in caps:

        time_sum = 0

        for i in range(1, 11):

            ufuncs = utility.read_ufuncs("../data/ufuncs/uf_870" + "_v" +
                                         str(i) + ".txt")

            scaled_ufuncs = utility.scale_ufuncs(ufuncs)

            pl_mat, cms, c = topo.read_data(
                "../data/topologies/waxman_30_3_870.txt")

            new_c = [cap for i in range(len(c))]
            c = new_c

            pl_mat = np.matrix(pl_mat)

            start_time = time.time()
            #cm_alloc, paths_alloc, useful_when_error = UMMP.max_min_program(
            #    pl_mat, cms, c, scaled_ufuncs, len(cms))

            #initial_splits=UIEWF.exp_congestion_decay_splits(cms,pl_mat)
            #cm_alloc,diffs=UIEWF.Util_IEWF(
            #    pl_mat,cms,c,initial_splits,scaled_ufuncs,it=100,th=0.03)

            cm_alloc, diffs = Hybrid.hybrid_alloc(pl_mat,
                                                  cms,
                                                  c,
                                                  scaled_ufuncs,
                                                  it=100,
                                                  th=0.03,
                                                  k=0.5 * len(cms))
            tot_time = time.time() - start_time

            time_sum += tot_time

        avg_time = time_sum / 10

        times.append(avg_time)

    print(times)
Esempio n. 3
0
def performance_waxman():

    plt.rcParams['font.family'] = 'serif'
    plt.rcParams['font.size'] = 18
    plt.rcParams['font.weight'] = 'bold'
    plt.rcParams['axes.labelweight'] = 'bold'
    plt.rcParams['axes.labelsize'] = 18

    fig, ax = plt.subplots()
    fig.subplots_adjust(left=0.16, top=0.995, bottom=0.13, right=0.995)

    pl_mat, cms, c = topo.read_data('../data/topologies/waxman_30_3_870.txt')
    ufuncs = utility.read_ufuncs("../data/ufuncs/uf_870_v4.txt")

    scaled_ufuncs = utility.scale_ufuncs(ufuncs)

    new_c = [4000.0 for i in range(len(c))]
    c = new_c

    pl_mat = np.matrix(pl_mat)

    x = [i for i in range(0, 870)]

    cm_alloc, paths_alloc, useful_when_error = UMMP.max_min_program(
        pl_mat, cms, c, scaled_ufuncs, len(cms))

    util_alloc = utility.flow2util(ufuncs, cm_alloc)
    ax.plot(x, sorted(util_alloc), label='Optimal', linestyle='solid')

    #initial_splits=UIEWF.exp_congestion_decay_splits(cms,pl_mat)
    #cm_alloc,diffs=UIEWF.Util_IEWF(pl_mat,cms,c,initial_splits,scaled_ufuncs,it=20,th=0.001)
    #util_alloc=utility.flow2util(ufuncs,cm_alloc)
    #ax.plot(x,sorted(util_alloc),label='U-IEWF',linestyle='dotted')

    #cm_alloc,diffs=Hybrid.hybrid_alloc(pl_mat,cms,c,scaled_ufuncs,it=20,th=0.001,k=100)
    #util_alloc=utility.flow2util(ufuncs,cm_alloc)
    #ax.plot(x,sorted(util_alloc),label='Hybrid-100',linestyle='dashed')

    ax.set_xticks(np.arange(0, 871, step=100))
    ax.set_ylabel('Utility')
    ax.set_xlabel('Commodity Index')

    #ax.grid(ls='--')
    ax.legend()

    plt.show()
Esempio n. 4
0
def dummy():
    # running_time()
    pl_mat, cms, c = topo.read_data('../data/topologies/waxman_30_2_870.txt')
    ufuncs = utility.read_ufuncs("../data/ufuncs/uf_870.txt")

    scaled_ufuncs = utility.scale_ufuncs(ufuncs)

    new_c = [10000.0 for i in range(len(c))]
    c = new_c

    pl_mat = np.matrix(pl_mat)

    start_time = time.time()
    cm_alloc, paths_alloc, useful_when_error = UMMP.max_min_program(
        pl_mat, cms, c, scaled_ufuncs, len(cms))
    tot_time_1 = time.time() - start_time
    #print("UMMP total time is "+str(tot_time))

    start_time = time.time()
    initial_splits = UIEWF.exp_congestion_decay_splits(cms, pl_mat)
    cm_alloc, diffs = UIEWF.Util_IEWF(pl_mat,
                                      cms,
                                      c,
                                      initial_splits,
                                      scaled_ufuncs,
                                      it=10,
                                      th=0.03)
    tot_time_2 = time.time() - start_time
    #print("UIEWF total time is "+str(tot_time))

    start_time = time.time()
    cm_alloc, diffs = Hybrid.hybrid_alloc(pl_mat,
                                          cms,
                                          c,
                                          scaled_ufuncs,
                                          it=10,
                                          th=0.03,
                                          k=500)
    tot_time_3 = time.time() - start_time
    #print("Hybrid total time is "+str(tot_time))

    print("UMMP total time is " + str(tot_time_1))
    print("UIEWF total time is " + str(tot_time_2))
    print("Hybrid total time is " + str(tot_time_3))
Esempio n. 5
0
def UIEWF_time():
    size = [20, 30, 40]

    times = []

    for s in size:

        time_sum = 0

        for i in range(1, 11):

            ufuncs = utility.read_ufuncs("../data/ufuncs/uf_" + str(s *
                                                                    (s - 1)) +
                                         "_v" + str(i) + ".txt")

            scaled_ufuncs = utility.scale_ufuncs(ufuncs)

            pl_mat, cms, c = topo.read_data("../data/topologies/waxman_" +
                                            str(s) + "_3_" + str(s * (s - 1)) +
                                            ".txt")

            new_c = [10000.0 for i in range(len(c))]
            c = new_c

            pl_mat = np.matrix(pl_mat)

            start_time = time.time()
            initial_splits = UIEWF.exp_congestion_decay_splits(cms, pl_mat)
            cm_alloc, diffs = UIEWF.Util_IEWF(pl_mat,
                                              cms,
                                              c,
                                              initial_splits,
                                              scaled_ufuncs,
                                              it=100,
                                              th=0.03)
            tot_time = time.time() - start_time

            time_sum += tot_time

        avg_time = time_sum / 10

        times.append(avg_time)

    print(times)
Esempio n. 6
0
def Hybrid_time():
    size = [40]

    times = []

    for s in size:

        time_sum = 0

        for i in range(1, 11):

            ufuncs = utility.read_ufuncs("../data/ufuncs/uf_" + str(s *
                                                                    (s - 1)) +
                                         "_v" + str(i) + ".txt")

            scaled_ufuncs = utility.scale_ufuncs(ufuncs)

            pl_mat, cms, c = topo.read_data("../data/topologies/waxman_" +
                                            str(s) + "_3_" + str(s * (s - 1)) +
                                            ".txt")

            new_c = [10000.0 for i in range(len(c))]
            c = new_c

            pl_mat = np.matrix(pl_mat)

            start_time = time.time()
            cm_alloc, diffs = Hybrid.hybrid_alloc(pl_mat,
                                                  cms,
                                                  c,
                                                  scaled_ufuncs,
                                                  it=100,
                                                  th=0.03,
                                                  k=0.2 * len(cms))
            tot_time = time.time() - start_time

            time_sum += tot_time

        avg_time = time_sum / 10

        times.append(avg_time)

    print(times)
Esempio n. 7
0
def abilene_time():

    time_sum = 0
    for i in range(1, 11):
        ufuncs = utility.read_ufuncs("../data/ufuncs/uf_110" + "_v" + str(i) +
                                     ".txt")

        scaled_ufuncs = utility.scale_ufuncs(ufuncs)

        pl_mat, cms, c = topo.read_data("../data/topologies/abilene_2_110.txt")

        new_c = [10000.0 for i in range(len(c))]
        c = new_c

        pl_mat = np.matrix(pl_mat)

        start_time = time.time()
        #cm_alloc, paths_alloc, useful_when_error = UMMP.max_min_program(
        #    pl_mat, cms, c, scaled_ufuncs, len(cms))
        #initial_splits=UIEWF.exp_congestion_decay_splits(cms,pl_mat)
        #cm_alloc,diffs=UIEWF.Util_IEWF(
        #    pl_mat,cms,c,initial_splits,scaled_ufuncs,it=100,th=0.03)
        cm_alloc, diffs = Hybrid.hybrid_alloc(pl_mat,
                                              cms,
                                              c,
                                              scaled_ufuncs,
                                              it=100,
                                              th=0.03,
                                              k=0.2 * len(cms))
        tot_time = time.time() - start_time

        time_sum += tot_time
    avg_time = time_sum / 10

    print("average time is")
    print(avg_time)
Esempio n. 8
0
def convergence_waxman_size():

    plt.rcParams['font.family'] = 'serif'
    plt.rcParams['font.size'] = 18
    plt.rcParams['font.weight'] = 'bold'
    plt.rcParams['axes.labelweight'] = 'bold'
    plt.rcParams['axes.labelsize'] = 18

    fig, ax = plt.subplots()
    fig.subplots_adjust(left=0.16, top=0.995, bottom=0.13, right=0.995)

    size = [20, 30]
    markers = ['x', 'v', '.', '^']

    x = [i for i in range(2, 21)]

    for i in range(len(size)):
        s = size[i]
        ufuncs = utility.read_ufuncs("../data/ufuncs/uf_" + str(s * (s - 1)) +
                                     ".txt")
        pl_mat, cms, c = topo.read_data("../data/topologies/waxman_" + str(s) +
                                        "_3_" + str(s * (s - 1)) + ".txt")

        ufuncs = utility.scale_ufuncs(ufuncs)

        new_c = [10000.0 for i in range(len(c))]
        c = new_c

        pl_mat = np.matrix(pl_mat)

        initial_splits = UIEWF.exp_decay_splits(cms, pl_mat)
        cm_alloc, diffs = UIEWF.Util_IEWF(pl_mat,
                                          cms,
                                          c,
                                          initial_splits,
                                          ufuncs,
                                          it=20,
                                          th=0.00001)
        ax.plot(x,
                diffs,
                label='len_decay',
                marker=markers[i],
                linestyle='dotted')

        initial_splits = UIEWF.exp_congestion_decay_splits(cms, pl_mat)
        cm_alloc, diffs = UIEWF.Util_IEWF(pl_mat,
                                          cms,
                                          c,
                                          initial_splits,
                                          ufuncs,
                                          it=20,
                                          th=0.00001)
        ax.plot(x,
                diffs,
                label="waxman-" + str(s),
                marker=markers[i],
                linestyle='solid')

    ax.set_xticks(np.arange(2, 21, step=2))
    ax.set_ylabel('Difference')
    ax.set_xlabel('Iteration number')

    ax.grid(ls='--')
    ax.legend()

    plt.show()
Esempio n. 9
0
def convergence_abilene():

    plt.rcParams['font.family'] = 'serif'
    plt.rcParams['font.size'] = 18
    plt.rcParams['font.weight'] = 'bold'
    plt.rcParams['axes.labelweight'] = 'bold'
    plt.rcParams['axes.labelsize'] = 18

    fig, ax = plt.subplots()
    fig.subplots_adjust(left=0.16, top=0.995, bottom=0.13, right=0.995)

    ufuncs = utility.read_ufuncs("../data/ufuncs/uf_110.txt")
    pl_mat, cms, c = topo.read_data('../data/topologies/abilene_2_110.txt')

    ufuncs = utility.scale_ufuncs(ufuncs)

    new_c = [10000.0 for i in range(len(c))]
    c = new_c

    pl_mat = np.matrix(pl_mat)

    initial_splits = UIEWF.uniform_splits(cms)
    cm_alloc, diffs = UIEWF.Util_IEWF(pl_mat,
                                      cms,
                                      c,
                                      initial_splits,
                                      ufuncs,
                                      it=20,
                                      th=0.00001)
    x = [i for i in range(21)][2:]
    ax.plot(x, diffs, label='uniform', marker='x', linestyle='solid')

    initial_splits = UIEWF.random_splits(cms)
    cm_alloc, diffs = UIEWF.Util_IEWF(pl_mat,
                                      cms,
                                      c,
                                      initial_splits,
                                      ufuncs,
                                      it=20,
                                      th=0.00001)
    ax.plot(x, diffs, label='random', marker='v', linestyle='solid')

    initial_splits = UIEWF.exp_decay_splits(cms, pl_mat)
    cm_alloc, diffs = UIEWF.Util_IEWF(pl_mat,
                                      cms,
                                      c,
                                      initial_splits,
                                      ufuncs,
                                      it=20,
                                      th=0.00001)
    ax.plot(x, diffs, label='len_decay', marker='.', linestyle='solid')

    initial_splits = UIEWF.exp_congestion_decay_splits(cms, pl_mat)
    cm_alloc, diffs = UIEWF.Util_IEWF(pl_mat,
                                      cms,
                                      c,
                                      initial_splits,
                                      ufuncs,
                                      it=20,
                                      th=0.00001)
    ax.plot(x, diffs, label='congestion_decay', marker='^', linestyle='solid')

    ax.set_xticks(np.arange(2, 21, step=2))
    ax.set_yticks(np.arange(0.0, 0.13, step=0.02))
    ax.set_ylabel('Difference')
    ax.set_xlabel('Iteration number')

    ax.grid(ls='--')
    ax.legend()

    plt.show()
Esempio n. 10
0
def running_time():

    plt.rcParams['font.family'] = 'serif'
    plt.rcParams['font.size'] = 18
    plt.rcParams['font.weight'] = 'bold'
    plt.rcParams['axes.labelweight'] = 'bold'
    plt.rcParams['axes.labelsize'] = 18

    fig, ax = plt.subplots()
    fig.subplots_adjust(left=0.12, top=0.99, bottom=0.13, right=0.995)

    pl_mat, cms, c = topo.read_data(
        'D:/utility-mmf/scripts/dataset/convergence/waxman_20_4_380_1.txt')

    new_c = [10000.0 for i in range(len(c))]
    c = new_c

    cm_nums = np.arange(100, 381, 40)

    UIEWF_times = [0 for i in range(len(cm_nums))]
    UIEWF_bin_times = [0 for i in range(len(cm_nums))]

    for i in range(3, 4):

        ufuncs = utility.read_ufuncs(
            "D:/utility-mmf/scripts/dataset/convergence/uf_380_time_" +
            str(i) + ".txt")

        for i in range(len(cm_nums)):
            cm_num = cm_nums[i]
            comms = cms[:cm_num]
            util_functions = ufuncs[:cm_num]
            start_time = time.time()
            initial_splits = UIEWF.exp_decay_splits(comms, pl_mat)
            cm_alloc, diffs = UIEWF.Util_IEWF(pl_mat, comms, c, initial_splits,
                                              util_functions, 5)
            ummf_time = time.time() - start_time
            UIEWF_times[i] += ummf_time

        for i in range(len(cm_nums)):
            cm_num = cm_nums[i]
            comms = cms[:cm_num]
            util_functions = ufuncs[:cm_num]
            start_time = time.time()
            initial_splits = UIEWF.exp_decay_splits(comms, pl_mat)
            cm_alloc, diffs = UIEWF_bin.Util_IEWF(pl_mat, comms, c,
                                                  initial_splits,
                                                  util_functions, 5)
            ummf_time = time.time() - start_time
            UIEWF_bin_times[i] += ummf_time

    ax.set_ylabel('Time(s)')
    ax.set_xlabel('Number of commodities')

    times = [t / 1 for t in UIEWF_times]
    bin_times = [t / 1 for t in UIEWF_bin_times]

    ax.plot(cm_nums, times, label='UIEWF', marker='.')
    ax.plot(cm_nums, bin_times, label='UIEWF-bin', marker='v')

    plt.xticks(np.arange(100, 381, 40))

    plt.grid(ls='--')

    plt.legend()

    plt.show()
Esempio n. 11
0
        pl_mat, cms, c, ufuncs, k)

    splits = np.zeros(path_num)
    paths_alloc = list(paths_alloc)

    for cm in cms:
        flow_sum = 0
        for p in cm:
            flow_sum += paths_alloc[p]
        if flow_sum == 0:
            for p in cm:
                splits[p] = 1 / len(cm)
        else:
            for p in cm:
                splits[p] = paths_alloc[p] / flow_sum

    cms_alloc, diffs = UIEWF.Util_IEWF(pl_mat, cms, c, splits, ufuncs, it, th)
    return cms_alloc, diffs


if __name__ == '__main__':
    ufuncs = utility.read_ufuncs(
        "D:/github/UtiliyUpwardMMF/data/ufuncs/uf_110.txt")
    pl_mat, cms, c = topo.read_data(
        "D:/github/UtiliyUpwardMMF/data/topologies/abilene_2_110.txt")

    cm_alloc, diffs = hybrid_alloc(pl_mat, cms, c, ufuncs, it=5, k=50)

    util_alloc = utility.flow2util(ufuncs, cm_alloc)

    print(sorted(util_alloc))
Esempio n. 12
0
def test():
    ufuncs=utility.read_ufuncs("D:/github/UtiliyUpwardMMF/data/ufuncs/uf_110.txt")
    scaled_ufuncs=scale_utility_functions(ufuncs,100)
    pl_mat,cms,c=topo.read_data("D:/github/UtiliyUpwardMMF/data/topologies/abilene_2_110.txt")
    initial_splits=UIEWF.exp_decay_splits(cms,pl_mat)
    model={'commodities':cms,'utility_functions':scaled_ufuncs,'splits':initial_splits,'pl_matrix':pl_mat,'capacities':c}
Esempio n. 13
0
            for l in range(len(pl_mat[0])):
                if pl_mat[p][l] == 1:
                    length += 1
            p_len[p] = length
        sorted_p = sorted(p_len.items(), key=lambda x: x[1])
        total = 0
        for i in range(len(sorted_p)):
            total += 1 / (10**i)
        for i in range(len(sorted_p)):
            splits[sorted_p[i][0]] = (1 / (10**i)) / total

    return splits


if __name__ == '__main__':
    #ufuncs=utility.read_ufuncs("D:/github/UtiliyUpwardMMF/data/ufuncs/uf_110.txt")
    #pl_mat,cms,c=topo.read_data("D:/github/UtiliyUpwardMMF/data/topologies/abilene_2_110.txt")

    pl_mat, cms, c = topo.read_data(
        'D:/utility-mmf/scripts/dataset/convergence/waxman_20_4_380_1.txt')
    ufuncs = utility.read_ufuncs(
        "D:/utility-mmf/scripts/dataset/convergence/uf_380_time_1.txt")

    initial_splits = exp_decay_splits(cms, pl_mat)
    #initial_splits=congestion_splits(cms,pl_mat)
    cm_alloc, diffs = Util_IEWF(pl_mat, cms, c, initial_splits, ufuncs, 1)

    util_alloc = utility.flow2util(ufuncs, cm_alloc)

    print(sorted(util_alloc))