/* Checks for any clashes between groups and rooms for a particular slot */ public bool doClashesExist(Slot s, Event e, Room r) { int indexOfSelectedSlot = Program.slots.IndexOf(s); bool clashes = false; int i = 0; // ensure there are no index out of bound errors if ((indexOfSelectedSlot + e.getDuration()) >= Program.slots.Count) clashes = true; /* Check that there are no clashes for any hours of the event */ while ((i < e.getDuration()) && (!clashes)) { List<Gene> eventsAtThisTime = new List<Gene>(); foreach (Gene g in chromosome) { if (g.getSlot() == s) eventsAtThisTime.Add(g); } int j = 0; while ((j < eventsAtThisTime.Count) && (!clashes)) { if ((eventsAtThisTime[j].getEvent().getGroups().Intersect(e.getGroups()).Count() > 0) || (eventsAtThisTime[j].getRoom() == r && r != Program.lunchRoom)) clashes = true; j++; } s = Program.slots[++indexOfSelectedSlot]; i++; } return clashes; }
} // scheduleLunch /* Checks for any clashes between groups and rooms for a particular slot */ public bool doClashesExist(Slot s, Event e, Room r) { int indexOfSelectedSlot = Program.slots.IndexOf(s); bool clashes = false; int i = 0; // ensure there are no index out of bound errors if ((indexOfSelectedSlot + e.getDuration()) >= Program.slots.Count) { clashes = true; } /* Check that there are no clashes for any hours of the event */ while ((i < e.getDuration()) && (!clashes)) { List <Gene> eventsAtThisTime = new List <Gene>(); foreach (Gene g in chromosome) { if (g.getSlot() == s) { eventsAtThisTime.Add(g); } } int j = 0; while ((j < eventsAtThisTime.Count) && (!clashes)) { if ((eventsAtThisTime[j].getEvent().getGroups().Intersect(e.getGroups()).Count() > 0) || (eventsAtThisTime[j].getRoom() == r && r != Program.lunchRoom)) { clashes = true; } j++; } s = Program.slots[++indexOfSelectedSlot]; i++; } return(clashes); } // doClashesExist
} // getCorrespondingSlot public bool enoughTimeInDay(Slot s, Event e) { List <Slot> remainingSlotsInDay = new List <Slot>(); for (int i = 0; i < Program.slots.Count; i++) { if ((Program.slots[i].getDay() == s.getDay()) && (Program.slots[i].getWeek() == s.getWeek())) { remainingSlotsInDay.Add(Program.slots[i]); } } if (((remainingSlotsInDay.IndexOf(s) + e.getDuration()) > remainingSlotsInDay.Count)) { return(false); } else { return(true); } } // enoughTimeInDay
} // enoughTimeInDay public bool hasEventBeenScheduled(Event e) { int numberTimesScheduled = chromosome.FindAll(delegate(Gene g) { return(g.getEvent() == e); }).Count; int expectedNumberOfTimes = Program.events.FindAll(delegate(Event evt) { return(evt == e); }).Count *e.getDuration(); if (e.getWeekly()) { expectedNumberOfTimes *= 2; } if (numberTimesScheduled == expectedNumberOfTimes) { return(true); } else { return(false); } } // hasEventBeenScheduled
public bool enoughTimeInDay(Slot s, Event e) { List<Slot> remainingSlotsInDay = new List<Slot>(); for (int i = 0; i < Program.slots.Count; i++) { if ((Program.slots[i].getDay() == s.getDay()) && (Program.slots[i].getWeek() == s.getWeek())) remainingSlotsInDay.Add(Program.slots[i]); } if (((remainingSlotsInDay.IndexOf(s) + e.getDuration()) > remainingSlotsInDay.Count)) return false; else return true; }
public bool hasEventBeenScheduled(Event e) { int numberTimesScheduled = chromosome.FindAll(delegate(Gene g) { return g.getEvent() == e; }).Count; int expectedNumberOfTimes = Program.events.FindAll(delegate(Event evt) { return evt == e; }).Count * e.getDuration(); if (e.getWeekly()) expectedNumberOfTimes *= 2; if (numberTimesScheduled == expectedNumberOfTimes) return true; else return false; }