예제 #1
0
def experiment():
    """
    Generates Macaulay 2 test cases, runs them using Swinarski's program, then outputs new unit tests if successful
    :return: Null
    """
    rank = 3
    level = 3
    num_points = 3
    tries = 10

    client = cbc.CBClient()
    liealg = cbd.TypeALieAlgebra(rank)
    A_l = liealg.get_weights(level)
    m2file = open("TestRank.m2", "w")
    m2file.write("loadPackage(\"ConformalBlocks\");\n")
    m2file.write("sl_" + str(rank + 1) + " = simpleLieAlgebra(\"A\", " +
                 str(rank) + ");\n")
    test_cases = []
    for i in range(tries):
        weights = [random.choice(A_l) for i in range(num_points)]
        test_cases.append(weights)
        cbb = cbd.ConformalBlocksBundle(client, liealg, weights, level)
        wt_str = "{"
        for wt in weights:
            if len(wt) == 1:
                wt_str += "{" + str(wt)[1] + "}, "
            else:
                wt_str += "{" + str(wt)[1:-1] + "}, "
        wt_str = wt_str[:-2] + "}"

        m2file.write("V = conformalBlockVectorBundle(sl_" + str(rank + 1) +
                     ", " + str(level) + ", " + wt_str + ", 0);\n")
        m2file.write("if " + str(cbb.get_rank()) +
                     " != conformalBlockRank(V) then error(\"Bundle " +
                     "(sl_" + str(rank + 1) + ", " + str(level) + ", " +
                     wt_str + ") incorrect rank\");\n")

    m2file.write("print(\"OK\");\n")
    m2file.close()

    test_out = subprocess.check_output(["M2", "--script", "TestRank.m2"])
    if test_out == "OK\n":
        for case in test_cases:
            cbb = cbd.ConformalBlocksBundle(client, liealg, case, level)
            wts_str = "[]lie.Weight{"
            for wt in case:
                if len(wt) == 1:
                    wts_str += "lie.Weight{" + str(wt)[1] + "}, "
                else:
                    wts_str += "lie.Weight{" + str(wt)[1:-1] + "}, "
            wts_str = wts_str[:-2] + "}, "

            print("{lie.NewTypeARootSystem(" + str(rank) + "), " + wts_str +
                  str(level) + ", big.NewInt(" + str(cbb.get_rank()) + ")},")
        print("OK")
    else:
        print(test_out)
예제 #2
0
def experiment():
    rank = 5
    level = 4
    num_points = 10

    client = cbc.CBClient()
    liealg = cbd.TypeALieAlgebra(rank, store_fusion=True, exact=False)
    print("Weight", "Rank", "Divisor")
    for wt in liealg.get_weights(level):
        cbb = cbd.SymmetricConformalBlocksBundle(client, liealg, wt,
                                                 num_points, level)
        if cbb.get_rank() == 0:
            #print(wt, 0)
            continue
        divisor = cbb.get_symmetrized_divisor()
        print(wt, cbb.get_rank(), divisor)
예제 #3
0
def experiment():
    rank = 5
    level = 4
    num_points = 11

    client = cbc.CBClient()
    liealg = cbd.TypeALieAlgebra(rank, store_fusion=True, exact=True)
    rays = []
    wts = []
    ranks = []
    for wt in liealg.get_weights(level):
        if wt == tuple([0 for x in range(0, rank)]):
            continue
        cbb = cbd.SymmetricConformalBlocksBundle(client, liealg, wt,
                                                 num_points, level)
        if cbb.get_rank() == 0:
            continue
        divisor = cbb.get_symmetrized_divisor()
        if divisor == [
                sage.Rational(0) for x in range(0, num_points // 2 - 1)
        ]:
            continue
        rays = rays + [divisor]
        wts = wts + [wt]
        ranks = ranks + [cbb.get_rank()]
        #print(wt, cbb.get_rank(), divisor)

    p = Polyhedron(rays=rays, base_ring=RationalField(), backend="cdd")
    extremal_rays = [list(v.vector()) for v in p.Vrepresentation()]
    c = Cone(p)
    print("Extremal rays:")
    for i in range(0, len(rays)):
        ray = rays[i]
        wt = wts[i]
        rk = ranks[i]
        if ray in extremal_rays:
            print(rk, wt, ray)
예제 #4
0
def experiment():
    """
    Generates Macaulay 2 test cases, runs them using Swinarski's program, then outputs new unit tests if successful
    :return: Null
    """
    rank = 3
    level = 3
    num_points = 6

    client = cbc.CBClient()
    liealg = cbd.TypeALieAlgebra(rank)
    A_l = liealg.get_weights(level)
    m2file = open("TestDivisor.m2", "w")
    m2file.write("loadPackage(\"ConformalBlocks\");\n")
    m2file.write("sl_" + str(rank + 1) + " = simpleLieAlgebra(\"A\", " +
                 str(rank) + ");\n")
    test_cases = []
    for wt in A_l:
        cbb = cbd.SymmetricConformalBlocksBundle(client, liealg, wt,
                                                 num_points, level)
        if cbb.get_rank() == 0:
            continue

        test_cases.append(wt)
        wt_str = "{"
        for i in range(num_points):
            if len(wt) == 1:
                wt_str += "{" + str(wt)[1] + "}, "
            else:
                wt_str += "{" + str(wt)[1:-1] + "}, "
        wt_str = wt_str[:-2] + "}"

        div = cbb.get_symmetrized_divisor()
        div_str = "{"
        for coord in div:
            div_str += str(coord * math.factorial(num_points)) + ", "
        div_str = div_str[:-2] + "}"

        m2file.write("V = conformalBlockVectorBundle(sl_" + str(rank + 1) +
                     ", " + str(level) + ", " + wt_str + ", 0);\n")
        m2file.write(
            "if " + div_str +
            " != coefficientList symmetrizedConformalBlockDivisor(V) then error(\"Bundle "
            + "(sl_" + str(rank + 1) + ", " + str(level) + ", " + wt_str +
            ") incorrect divisor\");\n")

    m2file.write("print(\"OK\");\n")
    m2file.close()

    test_out = subprocess.check_output(["M2", "--script", "TestRank.m2"])
    if test_out == "OK\n":
        for wt in test_cases:
            cbb = cbd.SymmetricConformalBlocksBundle(client, liealg, wt,
                                                     num_points, level)
            wt_str = ""
            if len(wt) == 1:
                wt_str += "{" + str(wt)[1] + "}, "
            else:
                wt_str += "{" + str(wt)[1:-1] + "}, "

            div = cbb.get_symmetrized_divisor()
            div_str = "[]*big.Rat{"
            for coord in div:
                div_str += "big.NewRat(" + str(coord.numerator) + ", " + str(
                    coord.denominator) + ")" + ", "
            div_str = div_str[:-2] + "}"

            print("{lie.NewTypeARootSystem(" + str(rank) + "), lie.Weight" +
                  wt_str + str(level) + ", " + str(num_points) + ", " +
                  div_str + "},")
        print("OK")
    else:
        print(test_out)
예제 #5
0
def experiment():
    """
    Generates Macaulay 2 test cases, runs them using Swinarski's program, then outputs new unit tests if successful
    :return: Null
    """
    rank = 3
    level = 2
    num_points = 6

    client = cbc.CBClient()
    liealg = cbd.TypeALieAlgebra(rank)
    A_l = liealg.get_weights(level)
    m2file = open("TestFCurve.m2", "w")
    m2file.write("loadPackage(\"ConformalBlocks\");\n")
    m2file.write("sl_" + str(rank + 1) + " = simpleLieAlgebra(\"A\", " +
                 str(rank) + ");\n")
    test_cases = []
    for wt in A_l:
        cbb = cbd.SymmetricConformalBlocksBundle(client, liealg, wt,
                                                 num_points, level)
        if cbb.get_rank() == 0:
            continue

        wt_str = "{"
        for i in range(num_points):
            if len(wt) == 1:
                wt_str += "{" + str(wt)[1] + "}, "
            else:
                wt_str += "{" + str(wt)[1:-1] + "}, "
        wt_str = wt_str[:-2] + "}"

        for curve in cbb.get_sym_F_curves():
            test_cases.append((wt, curve))
            curve_str = "{"
            for i in range(4):
                if len(curve[i]) == 1:
                    curve_str += "{" + str(curve[i])[1] + "}, "
                else:
                    curve_str += "{" + str(curve[i])[1:-1] + "}, "
            curve_str = curve_str[:-2] + "}"

            int_num = cbb.intersect_F_curve(curve)

            m2file.write("V = conformalBlockVectorBundle(sl_" + str(rank + 1) +
                         ", " + str(level) + ", " + wt_str + ", 0);\n")
            m2file.write("if " + str(int_num) +
                         " != FCurveDotConformalBlockDivisor(" + curve_str +
                         ", V) then error(\"Bundle " + "(sl_" + str(rank + 1) +
                         ", " + str(level) + ", " + wt_str + ") and curve " +
                         curve_str + " incorrect rank\");\n")

    m2file.write("print(\"OK\");\n")
    m2file.close()

    test_out = subprocess.check_output(["M2", "--script", "TestRank.m2"])
    if test_out == "OK\n":
        for case in test_cases:
            wt = case[0]
            curve = case[1]
            cbb = cbd.SymmetricConformalBlocksBundle(client, liealg, wt,
                                                     num_points, level)
            wt_str = ""
            if len(wt) == 1:
                wt_str += "{" + str(wt)[1] + "}, "
            else:
                wt_str += "{" + str(wt)[1:-1] + "}, "
            curve_str = "{"
            for i in range(4):
                if len(curve[i]) == 1:
                    curve_str += "{" + str(curve[i])[1] + "}, "
                else:
                    curve_str += "{" + str(curve[i])[1:-1] + "}, "
            curve_str = curve_str[:-2] + "}"

            int_num = cbb.intersect_F_curve(curve)

            print("{lie.NewTypeARootSystem(" + str(rank) + "), lie.Weight" +
                  wt_str + str(level) + ", " + str(num_points) + ", [4][]int" +
                  curve_str + ", big.NewInt(" + str(int_num) + ")},")
        print("OK")
    else:
        print(test_out)