Beispiel #1
0
def test(TM_plain):
    global interval_begin

    print "#" + "-" * 79
    tm = TransitionMap.from_iterable(
        (interval, long(target)) for interval, target in TM_plain
    )
    print_tm(tm)
    most_often_appearing_target, target_n = TransitionMap.get_target_statistics(tm)
    node = BranchTable(copy(tm), most_often_appearing_target)
    print "    ---"
    for element in node.implement():
        print "    %s" % element,

    interval_begin = 0
Beispiel #2
0
def test(TM_plain):
    global interval_begin

    print "#" + "-" * 79
    tm = TransitionMap.from_iterable((interval, "%s" % target.related_address)
                                     for interval, target in TM_plain)
    print_tm(tm)
    most_often_appearing_target, target_n = TransitionMap.get_target_statistics(
        tm)
    node = get_Bisection(copy(tm))
    print "    ---"
    for element in node.implement():
        print "    %s" % element,

    interval_begin = 0
Beispiel #3
0
def test(TM_plain):
    global interval_begin

    print "#" + "-" * 79
    tm = TransitionMap.from_iterable(
        (interval, "%s" % target) for interval, target in TM_plain)
    print_tm(tm)
    most_often_appearing_target, target_n = TransitionMap.get_target_statistics(
        tm)
    node = BranchTable(copy(tm), most_often_appearing_target)
    prev = "\n"
    print "    ---"
    for element in node.implement():
        if prev and prev[-1] == "\n": print "    %s" % element,
        else: print element,
        prev = element
Beispiel #4
0
def get_solution(TM):
    """RETURNS: [0] Solution from E_Solution
                [1] Most often appearing target
    """
    interval_n = len(TM)
    assert interval_n > 0

    most_often_appearing_target, target_n = TransitionMap.get_target_statistics(TM)

    # If there's only one interval, there's no need to compare, just go!
    # Otherwise, if there's a very low number of intervals, make a small
    # comparison list that iterates linearly through the items.
    if target_n < 4 and interval_n < 6: 
        return E_Solution.COMPARISON_SEQUENCE, None

    # If the size of character ranges which do not target 'moat' is less
    # than a certain number, implement the transition as branch table. The
    # 'moat' is implemented as the 'default:' case.
    sz_non_moat = TransitionMap.get_size_of_range_other_targets(TM, most_often_appearing_target)
    if sz_non_moat < 256: 
        return E_Solution.BRANCH_TABLE, most_often_appearing_target

    return E_Solution.BISECTIONING, None