public void AssigningAllSessions()
        {
            var sessions = new SessionsCollection();
            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, null, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(2));
            sessions.Add(4, null, Presenter.Create(3));
            sessions.Add(5, null, Presenter.Create(3));
            sessions.Add(6, null, Presenter.Create(3));
            sessions.Add(7, null, Presenter.Create(3));

            var rooms = new List<Room>();
            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));
            rooms.Add(Room.Create(3, 10));

            var timeslots = new List<Timeslot>();
            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));
            timeslots.Add(Timeslot.Create(3));
            timeslots.Add(Timeslot.Create(4));
            timeslots.Add(Timeslot.Create(5));

            var engine = (null as IConferenceOptimizer).Create();

            var assignments = engine.Process(sessions, rooms, timeslots);
            var assignmentsWithSessions = assignments.Where(a => a.SessionId.HasValue);
            assignments.WriteSchedule();
            Assert.That(assignmentsWithSessions.Count(), Is.EqualTo(sessions.Count()), "The wrong number of assignments were returned.");
        }
        public void ResultInTheSameNumberOfAssignments()
        {
            var sessions = new SessionsCollection();
            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, 1, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(3));
            sessions.Add(4, 1, Presenter.Create(4));

            var rooms = new List<Room>();
            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List<Timeslot>();
            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var solution = new Solution(sessions, rooms, timeslots);
            while (solution.AssignmentsCompleted < sessions.Count())
            {
                solution.AssignSessionsWithOnlyOneOption();
                solution.AssignMostConstrainedSession();
            }

            var s2 = solution.SwapAssignments();

            Assert.AreEqual(solution.Assignments.Count(), s2.Assignments.Count());
        }
예제 #3
0
        public void AssigningAllSessions()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, null, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(2));
            sessions.Add(4, null, Presenter.Create(3));
            sessions.Add(5, null, Presenter.Create(3));
            sessions.Add(6, null, Presenter.Create(3));
            sessions.Add(7, null, Presenter.Create(3));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));
            rooms.Add(Room.Create(3, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));
            timeslots.Add(Timeslot.Create(3));
            timeslots.Add(Timeslot.Create(4));
            timeslots.Add(Timeslot.Create(5));

            var engine = (null as IConferenceOptimizer).Create();

            var assignments             = engine.Process(sessions, rooms, timeslots);
            var assignmentsWithSessions = assignments.Where(a => a.SessionId.HasValue);

            assignments.WriteSchedule();
            Assert.That(assignmentsWithSessions.Count(), Is.EqualTo(sessions.Count()), "The wrong number of assignments were returned.");
        }
        public void KeepTheOriginalAssignmentsUnchanged()
        {
            var sessions = new SessionsCollection();
            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, 1, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(3));
            sessions.Add(4, 1, Presenter.Create(4));

            var rooms = new List<Room>();
            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List<Timeslot>();
            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var solution = new Solution(sessions, rooms, timeslots);
            while (solution.AssignmentsCompleted < sessions.Count())
            {
                solution.AssignSessionsWithOnlyOneOption();
                solution.AssignMostConstrainedSession();
            }

            var originalSolution = solution.Assignments.Serialize();
            solution.Assignments.WriteSchedule();

            var s2 = solution.SwapAssignments();
            var postSwapSolution = solution.Assignments.Serialize();
            solution.Assignments.WriteSchedule();

            Assert.AreEqual(originalSolution, postSwapSolution);
        }
        public void ResultInTheSameNumberOfAssignments()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, 1, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(3));
            sessions.Add(4, 1, Presenter.Create(4));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var solution = new Solution(sessions, rooms, timeslots);

            while (solution.AssignmentsCompleted < sessions.Count())
            {
                solution.AssignSessionsWithOnlyOneOption();
                solution.AssignMostConstrainedSession();
            }

            var s2 = solution.SwapAssignments();

            Assert.AreEqual(solution.Assignments.Count(), s2.Assignments.Count());
        }
예제 #6
0
        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.");
            }
        }
        public void ResultInTwoDifferencesInAssignments()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, 1, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(3));
            sessions.Add(4, 1, Presenter.Create(4));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var solution = new Solution(sessions, rooms, timeslots);

            while (solution.AssignmentsCompleted < sessions.Count())
            {
                solution.AssignSessionsWithOnlyOneOption();
                solution.AssignMostConstrainedSession();
            }

            var s2 = solution.SwapAssignments();

            int differenceCount = 0;

            foreach (var a1 in solution.Assignments)
            {
                var a2 = s2.Assignments.Where(a => a.RoomId == a1.RoomId && a.TimeslotId == a1.TimeslotId).Single();
                if (a1.SessionId != a2.SessionId)
                {
                    differenceCount++;
                }
            }

            Assert.AreEqual(2, differenceCount);
        }
        public void KeepTheOriginalAssignmentsUnchanged()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, 1, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(3));
            sessions.Add(4, 1, Presenter.Create(4));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var solution = new Solution(sessions, rooms, timeslots);

            while (solution.AssignmentsCompleted < sessions.Count())
            {
                solution.AssignSessionsWithOnlyOneOption();
                solution.AssignMostConstrainedSession();
            }

            var originalSolution = solution.Assignments.Serialize();

            solution.Assignments.WriteSchedule();

            var s2 = solution.SwapAssignments();
            var postSwapSolution = solution.Assignments.Serialize();

            solution.Assignments.WriteSchedule();

            Assert.AreEqual(originalSolution, postSwapSolution);
        }
        public void ResultInTwoDifferencesInAssignments()
        {
            var sessions = new SessionsCollection();
            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, 1, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(3));
            sessions.Add(4, 1, Presenter.Create(4));

            var rooms = new List<Room>();
            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List<Timeslot>();
            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var solution = new Solution(sessions, rooms, timeslots);
            while (solution.AssignmentsCompleted < sessions.Count())
            {
                solution.AssignSessionsWithOnlyOneOption();
                solution.AssignMostConstrainedSession();
            }

            var s2 = solution.SwapAssignments();

            int differenceCount = 0;
            foreach (var a1 in solution.Assignments)
            {
                var a2 = s2.Assignments.Where(a => a.RoomId == a1.RoomId && a.TimeslotId == a1.TimeslotId).Single();
                if (a1.SessionId != a2.SessionId)
                    differenceCount++;
            }

            Assert.AreEqual(2, differenceCount);
        }
예제 #10
0
        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.");
        }