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()