private void Load(SessionsCollection sessions, IEnumerable <Room> rooms, IEnumerable <Timeslot> timeslots) { _sessions = sessions; _rooms = rooms; _timeslots = timeslots; _presenters = sessions.GetPresenters(); // Create the session availability matrix _sessionMatrix = new SessionAvailabilityCollection(sessions, rooms, timeslots); if (!_sessionMatrix.IsFeasible) { throw new Exceptions.NoFeasibleSolutionsException(); } // Setup the empty assignment matrix foreach (var room in rooms) { foreach (var timeslot in timeslots) { if (room.AvailableInTimeslot(timeslot.Id)) { this.Assignments.Add(new Assignment(room.Id, timeslot.Id)); } } } // Make sure there are enough slots/rooms for all of the sessions if (sessions.Count() > this.Assignments.Count()) { throw new Exceptions.NoFeasibleSolutionsException("There are not enough rooms and timeslots to accommodate all of the sessions."); } }
private void Load(SessionsCollection sessions, IEnumerable<Room> rooms, IEnumerable<Timeslot> timeslots) { _sessions = sessions; _rooms = rooms; _timeslots = timeslots; _presenters = sessions.GetPresenters(); // Create the session availability matrix _sessionMatrix = new SessionAvailabilityCollection(sessions, rooms, timeslots); if (!_sessionMatrix.IsFeasible) throw new Exceptions.NoFeasibleSolutionsException(); // Setup the empty assignment matrix foreach (var room in rooms) foreach (var timeslot in timeslots) if (room.AvailableInTimeslot(timeslot.Id)) this.Assignments.Add(new Assignment(room.Id, timeslot.Id)); // Make sure there are enough slots/rooms for all of the sessions if (sessions.Count() > this.Assignments.Count()) throw new Exceptions.NoFeasibleSolutionsException("There are not enough rooms and timeslots to accommodate all of the sessions."); }