|
1 |
| -import seatingchart as sc |
2 |
| -import random |
| 1 | +import seatingchart.seatingchart as sc |
3 | 2 | import numpy as np
|
4 | 3 | import matplotlib.pyplot as plt
|
5 | 4 | import copy
|
|
12 | 11 | nguests = len(guestlist.guests)
|
13 | 12 | seatsper = 5
|
14 | 13 |
|
15 |
| -chart = sc.SeatingChart(guestlist,nguests/seatsper,seatsper) |
16 |
| -chart0=copy.deepcopy(chart) |
| 14 | +chart = sc.SeatingChart(guestlist, nguests/seatsper, seatsper) |
| 15 | +chart0 = copy.deepcopy(chart) |
17 | 16 | print ''
|
18 | 17 | print "Guests to be seated and their friends"
|
19 | 18 |
|
20 |
| -org = sc.Organizer(guestlist,chart) |
21 |
| -org0 = sc.Organizer(guestlist,chart0) |
22 |
| -#Seat everyone |
| 19 | +org = sc.Organizer(guestlist, chart) |
| 20 | +org0 = sc.Organizer(guestlist, chart0) |
| 21 | +# Seat everyone |
23 | 22 | org.seatguests()
|
24 | 23 |
|
25 |
| - |
26 |
| - |
27 | 24 | print "The final seating chart"
|
28 | 25 | chart.print_seatingchart()
|
29 | 26 | chart.print_chart()
|
|
39 | 36 | friendsT2 = np.zeros(nsteps)
|
40 | 37 | friendsT3 = np.zeros(nsteps)
|
41 | 38 | for i in steps:
|
42 |
| - friendsT1[i] = org1.metropolisstep(0.01) |
43 |
| - friendsT2[i] = org2.metropolisstep(.1) |
44 |
| - friendsT3[i] = org3.metropolisstep(1) |
| 39 | + friendsT1[i] = org1.metropolisstep(temp=0.01) |
| 40 | + friendsT2[i] = org2.metropolisstep(temp=.1) |
| 41 | + friendsT3[i] = org3.metropolisstep(temp=1) |
45 | 42 |
|
46 |
| -#Now compare to what happens if i just seat people with friends |
| 43 | +# Now compare to what happens if i just seat people with friends |
47 | 44 | org0.sc.print_chart()
|
48 | 45 | org0.seatguestsfriends()
|
49 |
| -count=org0.friendcount() |
| 46 | +count = org0.friendcount() |
50 | 47 | print "Number of friends with seating with friends method"
|
51 | 48 | print count
|
52 |
| -print "friends T1,T2,T3" |
53 |
| -print [friendsT1[-1],friendsT2[-1],friendsT3[-1]] |
54 |
| -plt.plot(steps, friendsT1,label='T1') |
55 |
| -plt.plot(steps, friendsT2,label='T2') |
56 |
| -plt.plot(steps, friendsT3,label='T3') |
57 |
| -plt.legend( loc='upper left') |
58 |
| -plt.xlabel="step" |
59 |
| -plt.ylabel="friendships" |
| 49 | +print "friends T1, T2, T3" |
| 50 | +print [friendsT1[-1], friendsT2[-1], friendsT3[-1]] |
| 51 | +plt.plot(steps, friendsT1, label='T1') |
| 52 | +plt.plot(steps, friendsT2, label='T2') |
| 53 | +plt.plot(steps, friendsT3, label='T3') |
| 54 | +plt.legend(loc='upper left') |
| 55 | +plt.xlabel = "step" |
| 56 | +plt.ylabel = "friendships" |
60 | 57 |
|
61 | 58 | org0.sc.to_excel('SeatingChart0.xlsx')
|
62 | 59 | org1.sc.to_excel('SeatingChart1.xlsx')
|
63 | 60 |
|
64 | 61 |
|
65 | 62 | plt.show()
|
66 |
| - |
67 |
| - |
0 commit comments