예제 #1
0
def main(start=None, addr=None, port=None, slave=None):
    if slave:
        client = SeatingSlave(addr, port)
        client.run()
    else:
        if start:
            if start.endswith('.xls') or start.endswith('.xlsx'):
                state = read_excel(open(start).read())
            elif start.endswith('.txt'):
                state = read_text(open(start).read())
            else:
                raise Exception("Don't know how to open %s" % start)

        else:
            state = start_seating()

        print dump(state)
        state.shuffle()

        state_evaluator = SquareStateEvaluator(
            TablePositionAgnosticClosnessEvaluator())
        server = SeatingMaster(
            StateKeeper(HillClimber(state_evaluator), state=state),
            (addr, 5000), state_evaluator)
        server.run()
예제 #2
0
def main(start=None, addr=None, port=None, slave=None):
    if slave:
        client = SeatingSlave(addr, port)
        client.run()
    else:
        if start:
            if start.endswith('.xls') or start.endswith('.xlsx'):
                state = read_excel(open(start).read())
            elif start.endswith('.txt'):
                state = read_text(open(start).read())
            else:
                raise Exception("Don't know how to open %s" % start)

        else:
            state = start_seating()

        print dump(state)
        state.shuffle()

        state_evaluator = SquareStateEvaluator(TablePositionAgnosticClosnessEvaluator())
        server = SeatingMaster(
            StateKeeper(
                HillClimber(state_evaluator),
                state=state),
            (addr, 5000),
            state_evaluator
        )
        server.run()
예제 #3
0
파일: tests.py 프로젝트: jlubcke/seating
def test_excel_change_geometry():

    start_state = read_text("""\
# Meal #0
3
2

1
0

# Meal #1
3
2

1
0
# Meal #2
2
1

0
""")

    assert dump(start_state) == """\
# Meal #0
   [2 3]
   [0 1]
# Meal #1
   [2 3]
   [0 1]
# Meal #2
   [1 2]
   [0]
"""

    rb = open_workbook(file_contents=(write_excel(start_state)))

    assert int(rb.sheet_by_index(1).cell(0, 1).value) == 2

    wb = copy(rb)
    wb.get_sheet(1).write(0, 1, 3)
    result = BytesIO()
    wb.save(result)
    new_state = read_excel(result.getvalue())

    assert dump(new_state) == """\
예제 #4
0
파일: tests.py 프로젝트: jlubcke/seating
def test_excel(initial):
    excel_content = write_excel(initial)
    actual = read_excel(excel_content)
    _assert_same_state(initial, actual)