Exemplo n.º 1
0
def main():
    filename = sys.argv[1] if len(sys.argv) == 2 else "seating.xls"
    if filename.endswith('.xls') or filename.endswith('.xlsx'):
        state = read_excel(open(filename).read())
    elif filename.endswith('.txt'):
        state = read_text(open(filename).read())
    else:
        state = start_seating()

    state.shuffle()
    state = fast_search(state)

    print dump(state)
    print report(state)
    print repr(state)
    print write_text(state)
    with open("seating.xls", "wb") as f:
        f.write(write_excel(state))
Exemplo n.º 2
0
def main():
    filename = sys.argv[1] if len(sys.argv) == 2 else "seating.xls"
    if filename.endswith('.xls') or filename.endswith('.xlsx'):
        state = read_excel(open(filename).read())
    elif filename.endswith('.txt'):
        state = read_text(open(filename).read())
    else:
        state = start_seating()

    state.shuffle()
    state = fast_search(state)

    print dump(state)
    print report(state)
    print repr(state)
    print write_text(state)
    with open("seating.xls", "wb") as f:
        f.write(write_excel(state))
Exemplo n.º 3
0
def test_fast_search():
    initial = start_seating()
    score = energy_sum_of_square
    e1 = score(initial)
    e2 = score(fast_search(initial, score=score, n=100))
    assert e2 < e1