Question: Using C++ OR Python: For this program were going to take a look at another type of stochastic optimization, simulated annealing. The residence hall at

Using C++ OR Python:
For this program were going to take a look at another type of stochastic optimization, simulated annealing.
The residence hall at Wassamatta U. is co-ed, with each floor being single-sex. We are going to deal with one gender, so that any student in our pool can become roommates with any other student in the pool. There are 50 4-student suites. Thus we must assign 4 students to each room; we would prefer to do this in a way that optimizes student satisfaction. Rooms are considered interchangeable; we dont care which student or group of students is in which room as long as each room has exactly 4 students assigned to it.
We have given each student a questionnaire, covering student demographics (including things like year, major, etc) as well as several potential-roommate questionsDo you like getting up early, or are you a night owl? Is it important that your space be neat and tidy at all times? Do you like cranking the tunes, or would you rather have a quiet environment?--and assigned each possible pairing a compatibility score, ranging from 0 (disaster in the making) to 100 (will probably become close friends). Your task is to find an optimum or near-optimum assignment of roommates.
Your input file is a text file containing a 200x200 table. For each entry in the table at a particular row R and column C, Table[R][C] gives the compatibility of students # R and C. The table is symmetric, so Table[R][C] = Table[C][R]. Each student is assigned a score of 0 with themselves, as a place holder. Our compatibility measure is symmetric, but in general it need not be. Note that this measure codes a better fit as a higher score. How you address this in your program (changing the formula, recoding each score S as 100-S, whatever) is up to you as an implementation detail.
Start with an initial assignment of 200 students to 50 rooms using any convenient methodconsecutive assignment, random assignment, etc. Randomly select any 2 rooms and consider swapping two random students from those rooms. Note that you must compare total compatibility of the groupings that result; an exchange that works much better for 1 student at a cost of lower satisfaction for 2 others may or may not be worthwhile. Your overall suite roommate compatibility score is the RMS (root-mean-square) of the pairwise scores. That is, given students A, B, C, and D, find the scores for AB, AC, AD, BC, BD, and CD; square each score; then take the square root of the average squared value. Start with a value of T that seems generously high. Every 2000 accepted exchanges, or 20,000 attempted exchanges (whichever comes first), reduce T slightly (T = 0.95 T). Your stopping criterion is a full pass of 20,000 attempted exchanges with no exchanges accepted.
For each iteration (value of T), your program should print out how many exchanges were made and attempted, and the best, worst, and average compatibility score of your assignment. At the program conclusion, report the scores of the best, worst, and average match.
4 1 1728832624 060019813818232 759135188063875 866110337182920431 7698706113 733425792211 923173612075752703857252 577, 8 1 6 6 6 7 9 9 8 3 6 8 4 8 6771533 2490267433795 81176971 72352279898 97822| 6 9 9 0 2 5 5 2 1 1 7 7 6 8939169 3409552| 4 8 9 6 4 6 3 9660549485 589562902 6144 5 14 *38 814509 28777747 209608 87850268890766 8872945748 1872609 8939198196048550 118290 232838286 g044307763256013- 5-_ -_ > 0 5 9 7 6 8 5 1 2 4 8 9 2 7 7 2 4 5 4 3570 --gg 261387 gAA22@33537282714122 A-87686475 7585 .4 .6357470 .8 .71 .7 .177289 6633897 A429725406 8650227611 >>1284708 915093218183135181 620057 185076 4 8951985966751 9481159765653779 72971111265 2963 1741915914304491 51017370517169397702223 42192190688351174519342 654934215987 112862632070 361656463662 8088919196269268890688026 9898619799375755130663998 88817546494105 250539883 627772 614087730 2333212026324721333 3 1810.1 n n i n M M M M M.! M-1 M i M M i i M M M M M 2000002222202020220022222 pppppspspsppssppppp nMpsspsaaaaapapapaappaaaaa appapWWWWWaWaWaWWaaWWWWW 255778988090 606006800101 2 0 2 0 2 2 e 2 2 2 2 2 28535000005 002 __ 2 3 2 2 2 2 2 2 pa s t t t t t A A A A A t A t A t A A t t A A A A A 6289307 S432999 4-e82-567880575518172 202__ 9 9 4 8 5 2 9 819 61333572026 629021 866637 861865036222148152 7911323267 6506173184 63118987 001753076206 tA 7305802608734660748679967 006622769671 0631098890135815 7543209877654332 05187679119 0123456789012345678 4 1 1728832624 060019813818232 759135188063875 866110337182920431 7698706113 733425792211 923173612075752703857252 577, 8 1 6 6 6 7 9 9 8 3 6 8 4 8 6771533 2490267433795 81176971 72352279898 97822| 6 9 9 0 2 5 5 2 1 1 7 7 6 8939169 3409552| 4 8 9 6 4 6 3 9660549485 589562902 6144 5 14 *38 814509 28777747 209608 87850268890766 8872945748 1872609 8939198196048550 118290 232838286 g044307763256013- 5-_ -_ > 0 5 9 7 6 8 5 1 2 4 8 9 2 7 7 2 4 5 4 3570 --gg 261387 gAA22@33537282714122 A-87686475 7585 .4 .6357470 .8 .71 .7 .177289 6633897 A429725406 8650227611 >>1284708 915093218183135181 620057 185076 4 8951985966751 9481159765653779 72971111265 2963 1741915914304491 51017370517169397702223 42192190688351174519342 654934215987 112862632070 361656463662 8088919196269268890688026 9898619799375755130663998 88817546494105 250539883 627772 614087730 2333212026324721333 3 1810.1 n n i n M M M M M.! M-1 M i M M i i M M M M M 2000002222202020220022222 pppppspspsppssppppp nMpsspsaaaaapapapaappaaaaa appapWWWWWaWaWaWWaaWWWWW 255778988090 606006800101 2 0 2 0 2 2 e 2 2 2 2 2 28535000005 002 __ 2 3 2 2 2 2 2 2 pa s t t t t t A A A A A t A t A t A A t t A A A A A 6289307 S432999 4-e82-567880575518172 202__ 9 9 4 8 5 2 9 819 61333572026 629021 866637 861865036222148152 7911323267 6506173184 63118987 001753076206 tA 7305802608734660748679967 006622769671 0631098890135815 7543209877654332 05187679119 0123456789012345678
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
