Exemplo n.º 1
0
        static public List <Team> MakeTestData()
        {
            Random rand = new Random();
            Dictionary <string, Room> rooms = new Dictionary <string, Room>();
            List <Team> teams = new List <Team>();

            /*
             * Making and setting up rooms
             */
            void makeRoom(int i)
            {
                String s = "Room" + i;

                rooms.Add(s, new Room(s));
            }

            //Create all the rooms for the unit
            for (int i = 1; i <= 29; i++)
            {
                makeRoom(i);
            }
            makeRoom(49);
            makeRoom(50);
            makeRoom(51);
            // Mapping rooms to each other
            void MakeAdjacent(int i, int j, int dist)
            {
                rooms["Room" + i].AddAdjacency(rooms["Room" + j], dist);
            }

            void AdjacentRange(int startNum, int endNum)
            {
                for (int i = startNum; i < endNum; i++)
                {
                    MakeAdjacent(i, i + 1, 2);
                }
            }

            void CrossHallwayLink(int sideAstart, int sideBStart, int range, int dist)
            {
                int max = sideAstart + range;

                while (sideAstart < max)
                {
                    MakeAdjacent(sideAstart++, sideBStart--, dist);
                }
            }

            // Link all next-door rooms
            AdjacentRange(1, 9);
            AdjacentRange(10, 16);
            AdjacentRange(17, 23);
            AdjacentRange(24, 26);
            AdjacentRange(27, 29);
            // The "special" rooms
            MakeAdjacent(49, 50, 2);
            MakeAdjacent(24, 50, 2);
            // Hallway->Hallway Links
            MakeAdjacent(9, 10, 5);
            MakeAdjacent(16, 17, 5);
            MakeAdjacent(23, 49, 5);
            MakeAdjacent(1, 29, 10);
            // Link rooms Across Hallways
            CrossHallwayLink(1, 8, 4, 3);
            MakeAdjacent(29, 49, 3);
            MakeAdjacent(28, 50, 3);
            MakeAdjacent(27, 24, 3);

            /*
             * Generate Teams
             */
            int n = 0; // nurse# counter
            int p = 0; // patient# counter

            List <Nurse> MakeNurses(int r)
            {
                List <Nurse> nurses = new List <Nurse>();

                for (int i = 0; i < r; i++)
                {
                    nurses.Add(new Nurse("Nurse" + n++));
                }
                return(nurses);
            }

            List <Patient> MakePatients(int r)
            {
                List <Patient> patients = new List <Patient>();

                for (int i = 0; i < r; i++)
                {
                    patients.Add(new Patient("Patient" + p++, rand.Next(patientAcuityMin, patientAcuityMax)));
                }
                return(patients);
            }

            // Make Teams
            for (int i = 0; i < teamCount; i++)
            {
                teams.Add(new Team());
                teams[i].TeamName = "Team" + i;
                teams[i].Rooms    = rooms.Values.ToList();;
            }
            // Populate teams
            foreach (Team t in teams)
            {
                t.Nurses   = MakeNurses(nurseCount);
                t.Patients = MakePatients(patientCount);
                // Set preferences for the team
                for (int j = 0; j < preferenceCount; j++)
                {
                    Nurse   nurse   = t.Nurses[rand.Next(0, t.Nurses.Count)];
                    Patient patient = t.Patients[rand.Next(0, t.Patients.Count)];
                    t.Preferences.Add(new Preference(nurse, patient, rand.Next(preferenceWeightMin, preferenceWeightMax)));
                }
            }
            {
                //Adding Patients to rooms (obviously in the most readable format ever conceived)
                int   j        = 1;
                int   i        = 0;       // 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 49 50 51
                int[] roomCaps = new int[] { 2, 2, 2, 2, 1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 3, 1, 1, 1 };
                foreach (Team t in teams)
                {
                    i = 0;
                    while (i < t.Patients.Count && j < roomCaps.Length)
                    {
                        for (int k = 0; k < roomCaps[i]; k++)
                        {
                            rooms["Room" + j].patients.Add(t.Patients[i]);
                            i++;
                        }
                        j++;
                    }
                }
                //Team lastTeam = teams[teams.Count - 1];
                //rooms["Room49"].patients.Add(lastTeam.Patients[i++]);
                //rooms["Room50"].patients.Add(lastTeam.Patients[i++]);
            }
            return(teams);
        }
Exemplo n.º 2
0
 public bool EqualTo(Nurse n)
 {
     return(n.Name.Equals(this.Name));
 }
 // Constructor
 public Preference(Nurse n, Patient p, int weight)
 {
     Nurse       = n;
     Patient     = p;
     this.Weight = weight;
 }