예제 #1
0
def test_glouton(nmax, p):
    x = []
    y = []
    xl = []
    yl = []
    N = nmax * (np.arange(10) + 1) / 10
    if (nmax > 1):
        for i in (N):
            i = int(i) + 1
            x.append(i)
            xl.append(math.log(i))
            tcumul = 0
            for j in range(10):
                g = imp.gen_graphe(i, p)
                while (imp.is_empty(g)):
                    g = imp.gen_graphe(i, p)
                start_time = time.time()
                c = imp.glouton(g)
                end_time = time.time()
                t = (end_time - start_time)
                tcumul += t
            y.append(tcumul / 10)
            yl.append(math.log(tcumul / 10))
        return x, y, xl, yl
    else:
        print('nmax doit etre supérieur à 1')
        return None
예제 #2
0
def test_branch_born_brut(nmax, p):
    x = []
    y = []
    xl = []
    yl = []
    N = nmax * (np.arange(10) + 1) / 10
    if (nmax > 1):
        for i in (N):
            print(i)
            i = int(i) + 1
            x.append(i)
            xl.append(math.log(i))
            tcumul = 0
            for j in range(10):
                g = imp.gen_graphe(i, p)
                while (imp.is_empty(g)):
                    g = imp.gen_graphe(i, p)
                t, b, nb_n = imp.branch_born_brut(g)
                tcumul += t
            y.append(tcumul / 10)
            yl.append(math.log(tcumul / 10))
        return x, y, xl, yl
    else:
        print('nmax doit etre supérieur à 1')
        return None
예제 #3
0
def rapport_approxim(nmax, p):
    x = []
    y1 = []
    y2 = []
    N = nmax * (np.arange(10) + 1) / 10
    if (nmax > 1):
        for i in (N):
            print(i)
            i = int(i) + 1
            x.append(i)
            rcumul1 = 0
            rcumul2 = 0
            for j in range(10):
                g = imp.gen_graphe(i, p)
                while (imp.is_empty(g)):
                    g = imp.gen_graphe(i, p)
                t, C, nb_n = imp.branch_born_ameliore1(g)
                c1 = len(C)
                c2 = len(imp.couplage(g))
                c3 = len(imp.glouton(g))
                rcumul1 += c2 / c1
                rcumul2 += c3 / c1
            y1.append(rcumul1 / 10)
            y2.append(rcumul2 / 10)
        return x, y1, y2
    else:
        print('nmax doit etre supérieur à 1')
        return None
예제 #4
0
def compare_couplage_glouton(nmax, p):
    x = []
    y1 = []
    y2 = []
    N = nmax * (np.arange(10) + 1) / 10
    if (nmax > 1):
        for i in (N):
            i = int(i) + 1
            x.append(i)
            cumul1 = 0
            cumul2 = 0
            for j in range(20):
                g = imp.gen_graphe(i, p)
                while (imp.is_empty(g)):
                    g = imp.gen_graphe(i, p)
                c2 = len(imp.glouton(g))
                c1 = len(imp.couplage(g))
                if (c1 < c2):
                    cumul1 += 1
                else:
                    if (c2 < c1):
                        cumul2 += 1
                    else:
                        cumul2 += 1
                        cumul1 += 1
            y1.append(cumul1)
            y2.append(cumul2)
        return x, y1, y2
    else:
        print('nmax doit etre supérieur à 1')
        return None
예제 #5
0
def ecart_couplage_glouton(nmax, p):
    x = []
    y = []
    N = nmax * (np.arange(10) + 1) / 10
    if (nmax > 1):
        for i in (N):
            i = int(i) + 1
            x.append(i)
            ecumul = 0
            for j in range(20):
                g = imp.gen_graphe(i, p)
                while (imp.is_empty(g)):
                    g = imp.gen_graphe(i, p)
                c2 = len(imp.glouton(g))
                c1 = len(imp.couplage(g))
                ecumul += abs(c2 - c1)
            y.append(ecumul / 20)
        return x, y
    else:
        print('nmax doit etre supérieur à 1')
        return None
예제 #6
0
def Comparaison_branch_born(nmax, p):
    x = []
    xl = []
    yl1 = []
    y1 = []
    yl2 = []
    y2 = []
    yl3 = []
    y3 = []

    N = nmax * (np.arange(10) + 1) / 10
    if (nmax > 1):
        for i in (N):
            print(i)
            i = int(i) + 1
            x.append(i)
            xl.append(math.log(i))
            tcumul1 = 0
            tcumul2 = 0
            tcumul3 = 0
            nbSommet1 = 0
            nbSommet2 = 0
            nbSommet3 = 0
            for j in range(10):
                g = imp.gen_graphe(i, p)
                while (imp.is_empty(g)):
                    g = imp.gen_graphe(i, p)
                t, b, nb_n = imp.branch_born(g)
                tcumul1 += t
                nbSommet1 += nb_n
                t, b, nb_n = imp.branch_born_glouton(g)
                tcumul2 += t
                nbSommet2 += nb_n
                t, b, nb_n = imp.branch_born_brut(g)
                tcumul3 += t
                nbSommet3 += nb_n

            y1.append(nbSommet1 / 10)
            y2.append(nbSommet2 / 10)
            y3.append(nbSommet3 / 10)
            yl1.append(math.log(tcumul1 / 10))
            yl2.append(math.log(tcumul2 / 10))
            yl3.append(math.log(tcumul3 / 10))
    #comparaison du log (temps)
    plt.xlabel('Log de la taille d' 'instance: N')
    plt.ylabel('Log du temps de calcul')
    plt.title("comparaison du log (temps)")
    plt.plot(xl, yl1, label="branch-born")
    plt.plot(xl, yl2, label="branch-born_glouton")
    plt.plot(xl, yl3, label="branch-born_brut")
    plt.legend()
    plt.show()
    #comparaison du nombre de noeuds créé
    plt.xlabel('Taille d' 'instance: N')
    plt.ylabel('Nombre de noeuds')
    plt.title("comparaison du nombre de noeuds créés")
    plt.plot(x, y1, label="branch-born")
    plt.plot(x, y2, label="branch-born_glouton")
    plt.plot(x, y3, label="branch-born_brut")
    plt.legend()
    plt.show()