In this exercise, we'll develop and use an abstract, highly simplified model and simulation of social interaction.
Imagine a group of four hundred first-year students at a small, isolated four-year undergraduate college. Suppose that they all live in dormitories -- specifically, in twenty different halls, twenty students each, in ten double rooms in each hall, so that each student has a roommate and eighteen other hallmates.
Each student enrolls for four courses; in the simulation, we'll assume that these are chosen at random from a roster of eighty available courses, with no constraints on the number of students who can take a given course and no time conflicts between courses.
Every week, ten of the students (chosen at random) host parties. A student who hosts a party invites his twenty closest friends to it. The recipient of an invitation can accept or decline it. In the simulation, a student who receives only one invitation in a given week always accepts it; a student who receives more than one invitation accepts the one hosted by whichever of the inviters is the closest friend of the recipient and declines all the others.
In the simulation, we measure the closeness of the friendship between students A and B basically by counting and scoring interactions: three points if A and B are roommates, two points if they are hallmates, one point for every course that they take together, and one point for every party that they both attend. (Since roommates are always hallmates, their total closeness score is always at least 5.)
Each student also has a popularity score, which includes three points for each party that she hosts and one point for each invitation that she receives (including those that she declines).
In deciding whom to invite to a party, then, a host examines the closeness score that holds between himself and each of the other 399 students, and invites the twenty others for which the closeness score is highest. It may be necessary to resolve ties in order to limit the invitation list to exactly twenty. In such cases, students with higher popularity scores should be added to the invitation list before students with lower ones. If popularity scores are also tied, these ties should be resolved by choosing invitees from the tied group at random.
Similarly, when a student receives more than one invitation in the same week, she accepts the one with whose host she has the highest closeness score, or, in case of a tie, the one whose host has the highest popularity score (or choose at random in case there is also a tie in popularity).
The first part of the assignment is to design data structures appropriate for use in this simulation. How will you represent a student in this simulation? a room? a hall? a course? a party? an invitation? How will your program calculate or keep track of closeness scores and popularity scores?
Next, develop appropriate procedures for initializing the simulation -- assigning students to rooms and halls and enrolling them for courses.
Next, develop appropriate procedures for holding all the parties in one week -- choosing the hosts, generating the invitation lists, figuring out who accepts and who declines, adjusting the closeness and popularity scores to reflect the results.
Next, write a procedure to initialize the simulation and then simulate fourteen weeks of parties.
There are a number of questions that one might ask at the end of the simulation. Here are three that I'd be particularly interested in:
Write Scheme procedures to determine the answers to these questions (and any others, of your own invention, that might interest you).
This exercise will be due at 2:15 p.m. on Friday, May 13.