def simple(r,retry):
    ellCandidate=[]
    score=1000000000
    tmp=genEll(r)
    tmp=(tmp[0],tmp[1],tmp[2],r)
    ellCandidate.append(tmp)
    if tmp[0]<score:
        score=tmp[0]
        sellx=tmp[1]
        selly=tmp[2]
        opti=r
        print rectDiagMisc.toStringNice(r)
        print score
##            print evalEll(sellx,selly)
##    print tmp[0],sellx,selly,opti
##    return (score,sellx,selly,opti)
    ellCandidate.sort()
    ellCandidate=ellCandidate[:retry]
    ellCandidate.reverse()
    return ellCandidate
def main(rect,retry):
    print "opti, Ell"
    ellCandidate=[]
    l=genCycles(rect)
    score=1000000000
    for r in l:
        tmp=genEll(r)
        tmp=(tmp[0],tmp[1],tmp[2],r)
        ellCandidate.append(tmp)
        if tmp[0]<score:
            score=tmp[0]
            sellx=tmp[1]
            selly=tmp[2]
            opti=r
            print rectDiagMisc.toStringNice(r)
            print score
##            print evalEll(sellx,selly)
##    print tmp[0],sellx,selly,opti
##    return (score,sellx,selly,opti)
    ellCandidate.sort()
    ellCandidate=ellCandidate[:retry]
    ellCandidate.reverse()
    return ellCandidate
示例#3
0
def simple(r, retry):
    ellCandidate = []
    score = 1000000000
    tmp = genEll(r)
    tmp = (tmp[0], tmp[1], tmp[2], r)
    ellCandidate.append(tmp)
    if tmp[0] < score:
        score = tmp[0]
        print(rectDiagMisc.toStringNice(r))
        print(score)

    ellCandidate.sort()
    ellCandidate = ellCandidate[:retry]
    ellCandidate.reverse()
    return ellCandidate
示例#4
0
def main(rect, retry):
    print("opti, Ell")
    ellCandidate = []
    list_cycles = genCycles(rect)
    score = 1000000000
    for r in list_cycles:
        tmp = genEll(r)
        tmp = (tmp[0], tmp[1], tmp[2], r)
        ellCandidate.append(tmp)
        if tmp[0] < score:
            score = tmp[0]
            print(rectDiagMisc.toStringNice(r))
            print(score)
    ellCandidate.sort()
    ellCandidate = ellCandidate[:retry]
    ellCandidate.reverse()
    return ellCandidate
示例#5
0
    ##          [5,8],[7,11],[10,13],[9,12],[6,11],[4,8],[5,12],[4,7]]

    ##Sebs
    ##    rect=[[0,2],[1,3],[2,5],[1,4],[3,5],[0,4]]
    ##    rect=[[1,6],[0,2],[1,4],[0,3],[2,5],[4,7],[6,8],[5,7],[3,8]]
    ##    rect=[[0,1],[0,1]]
    ##    rect=[[0,13],[9,11],[5,7],[6,10],[9,12],[11,13],[5,8],[7,10],[1,3],[2,6],[1,4],[3,8],[4,12],[0,2]]
    import braid2rect

    ##    rect=braid2rect.atlas[(12,1291)]
    ##    rect=braid2rect.atlas[(11,370)]##90s about
    rect = braid2rect.atlas[(11, 418)]  ##has a multi domain!
    ##    rect=braid2rect.atlas[(9,15)]

    ##    rect=rect[6:]+rect[:6]
    import rectDiagMisc

    print rectDiagMisc.toStringNice(rect)
    print rect
    print 11
    import time

    startTime = time.clock()
    ##    print "second phase"
    print AllToString(rect)
    print "categ:", categ
    print "dpM2:", deepBdMap2.debug
    print "Duration:", time.clock() - startTime
##    raw_input("")
##    print deepBdMap.totalG
示例#6
0
def getKnotFloerHomology(rect):
    """
    INPUT:

    a grid diagram ?
    """
    ellCandidate = getOptiEllipses.simple(rect, 1)
    print(ellCandidate)
    tmp = ellCandidate.pop()
    rect = tmp[3]
    print(rect)
    ell = (tmp[1], tmp[2])
    print("ellipses:")
    print(ell)
    print("score:", tmp[0])
    print("new Diagram:")
    print(rectDiagMisc.toStringNice(rect))
    tmp, b, pool, index = generators.classifiedGen(rect, ell, 1)
    print("index", index)
    print("Scale:A and M: ", b)
    print("Generators, tabulated by Maslov and Alexander grading:")

    transposed = transpose(tmp)

    def format(s, l):
        if len(s) < l:
            return " " * (l - len(s)) + s
        return s

    for i in transposed:
        s = ""
        for j in i:
            s += format(str(len(j)), 6) + " "
        print(s)

    # the bdMap stuff
    HDEll = hdEllipsesGen(ell[0], ell[1])
    to0, toPlus, chEll = hdCond(rect, HDEll)
    delta = hdCond2(rect, HDEll, to0, toPlus)
    path = preparePath(rect, ell)
    print("path", path)

    # the deepBd stuff
    init = deepBdMap2.initWith(rect, ell)

    #     def eulerP(tab):
    #         k=[0]*(len(tab[0]))
    #         for i in range(len(tab[0])):
    #             tot = 0
    #             for j in range(len(tab)):
    #                 tot = len(tab[j][i])-tot
    #             k[i] = tot
    #         return k
    #     print(eulerP(tmp))
    cache = bdMapPsgenCache(rect, ell, pool)
    fillFValue(tmp, cache, ell, to0, toPlus, chEll, delta)
    # new
    #         cache2=bdMapGolay.bdMapPsgenCache(rect, ell, pool)
    #     a=raw_input("w")

    def coeff(x, y):
        return bdMap(rect, x, y, cache, ell,
                     to0, toPlus, chEll, delta,
                     path, init)

    tmp2 = homology.chain2DToHomv3(tmp, coeff, len(rect) - 1, index)

    return transpose(tmp2)
示例#7
0
    rect6 = [[5, 7], [3, 6], [2, 5], [1, 4], [0, 3], [2, 6],
             [1, 7], [0, 4]]  # 8_19
    rect7 = [[0, 4], [3, 6], [2, 5], [1, 3], [4, 7], [2, 6],
             [0, 5], [1, 7]]  # 8_20
    rect8 = [[0, 3], [1, 14], [0, 2], [1, 9], [3, 11], [2, 10], [4, 7], [6, 9],
             [5, 8], [7, 12], [11, 14], [10, 13], [6, 12], [4, 8], [5, 13]]
    rect9 = [[0, 3], [1, 13], [0, 2], [1, 6], [3, 10], [2, 9],
             [5, 8], [7, 11], [10, 13], [9, 12], [6, 11], [4, 8],
             [5, 12], [4, 7]]

    rect_a = [[0, 2], [1, 3], [2, 5], [1, 4], [3, 5], [0, 4]]
    rect_b = [[1, 6], [0, 2], [1, 4], [0, 3], [2, 5], [4, 7],
              [6, 8], [5, 7], [3, 8]]
    rect_c = [[0, 1], [0, 1]]
    rect_d = [[0, 13], [9, 11], [5, 7], [6, 10], [9, 12], [11, 13], [5, 8],
              [7, 10], [1, 3], [2, 6], [1, 4], [3, 8], [4, 12], [0, 2]]

    rect_e = atlas[(12, 1291)]
    rect_f = atlas[(11, 370)]  # 90s about
    rect_g = atlas[(9, 15)]
    rect = atlas[(11, 418)]  # has a multi domain!

    print(rectDiagMisc.toStringNice(rect))
    print(rect)

    startTime = time.clock()
    print(AllToString(rect))
    print("categ:", categ)
    print("dpM2:", deepBdMap2.debug)
    print("Duration:", time.clock() - startTime)
示例#8
0
""")
s = ""
while s != "y" and s != "n":
    s = input("""Do you want to enter a knot:
(y) by its rectangular diagram ?
(n) by its table location (for knots with at most 12 crossings) ?
Please answer (y/n): """)

if s == "n":
    i = int(input("knot number of crossings: "))
    j = int(input("knot number: "))
    if (i, j) in atlas:
        rect = atlas[(i, j)]
        print("KNOT: ", i, "n", j)
        print(rect)
        print(toStringNice(rect))
        print(AllToString(rect))
    else:
        raise ValueError("not in the knot table")
else:
    print(
        "Please enter the rectangular diagram as a list of pairs of coordinates:"
    )
    print(
        "Example: [[0,0],[0,1],[1,0],[1,1]] is the trivial knot (the 4 corners of a rectangle)."
    )
    print("Example: [[0,0],[2,0],[2,3],[1,3],[1,1],[3,1],[3,2],[0,2]] for ?")
    s = input("")
    rect = json.loads(s)
    print(
        "How hard do you want the program to try to simplify your rectangular diagram?(0-100000) 0: no simplification 5000: pretty good compromise"