-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
54 lines (44 loc) · 1.8 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from seatings import compute_seating_cost, generate_seating
from simulated_annealing import SimulatedAnnealing, MyState
def generate_sample_families(*args):
from random import shuffle
result = []
fam_id = 100
for amount, members in args:
for _ in range(amount):
result.append({"count": members, "id": "%s" % fam_id})
fam_id += 1
shuffle(result)
return result
def main():
"""ROWS = 36
COLUMNS = 36
sa = SimulatedAnnealing(1000, MyState(generate_sample_families((400, 1), (400, 2), (400, 4))), compute_seating_cost,
rows=ROWS, columns=COLUMNS)
state, cost, cost_trace = sa.run_simulation(return_cost_trace=True)
print(cost_trace)
print("first: %s\nlast: %s\nmax: %s\nmin: %s"
% (cost_trace[0], cost_trace[-1], max(cost_trace), min(cost_trace)))
print(cost)
print(state.placing_order)
stadium = generate_seating(state.placing_order, rows=ROWS, columns=COLUMNS)
stadium.get_heatmap_plot().show()
print(stadium.graphic(labeled=True))"""
ROWS = 10
COLUMNS = 100
sa = SimulatedAnnealing(500000, MyState(generate_sample_families((50, 1), (75, 2), (75, 3), (50, 4))), compute_seating_cost,
rows=ROWS, columns=COLUMNS)
state, cost, cost_trace = sa.run_simulation(return_cost_trace=True)
print(cost_trace)
print("first: %s\nlast: %s\nmax: %s\nmin: %s"
% (cost_trace[0], cost_trace[-1], max(cost_trace), min(cost_trace)))
print(cost)
print(state.placing_order)
stadium = generate_seating(state.placing_order, rows=ROWS, columns=COLUMNS)
stadium.get_heatmap_plot().show()
print(stadium.graphic(labeled=True))
import matplotlib.pyplot as plt
plt.plot(cost_trace)
plt.show()
if __name__ == "__main__":
main()