Exemplo n.º 1
0
        public List <List <Slot> > GetPossibleTimetables(Slot[] inputSlots)
        {
            var subjects = SubjectModel.Parse(inputSlots.ToList());
            Func <Slot[], List <List <Slot> > > permutator = Permutator.Run_v2_withoutConsideringWeekNumber;

            subjects = SortBySlotCount(subjects);
            var currentSlots        = subjects[0].Slots;
            var possibleCombination = permutator.Invoke(currentSlots.ToArray());
            var state = StateTable.GetStateOfDefinitelyOccupied(possibleCombination);
            int last  = subjects.Count - 1;

            for (int i = 1; i < subjects.Count; i++)
            {
                var originalSchema = new SubjectSchema(subjects[i].Slots);
                var filtrate       = StateTable.Filter(subjects[i].Slots, state);
                var newSchema      = new SubjectSchema(filtrate);
                if (!originalSchema.Equals(newSchema))
                {
                    return(null);
                }
                currentSlots.AddRange(filtrate);
                possibleCombination = permutator.Invoke(currentSlots.ToArray());
                if (i != last)
                {
                    state = StateTable.GetStateOfDefinitelyOccupied(possibleCombination);
                }
            }
            return(possibleCombination);
        }
Exemplo n.º 2
0
        public void Test_StateTable_Filter_1()
        {
            var input      = TestData.GetSlotsByName(TestData.Subjects.AdvancedStructuralSteelDesign);
            var inputState = StateTable.ParseString_AsStateOfDefinitelyOccupied(
                "11111111111111111111111111111111~" +
                "11111111111111111111111111111111~" +
                "11111111111111111111111111111111~" +
                "11111111111111111111111111111111~" +
                "11111111111111111111111111111111~" +
                "11111111111111111111111111111111~" +
                "11111111111111111111111111111111"
                );
            var expectedCount = 0;
            var actualCount   = StateTable.Filter(input, inputState).Count;

            Assert.AreEqual(expectedCount, actualCount);
        }
Exemplo n.º 3
0
        public void Test_StateTable_Filter_ShouldRemoveRelatedSlots()
        {
            var input = new List <Slot> {
                TestData.GetSlot(309), TestData.GetSlot(311)
            };
            var inputState = StateTable.ParseString_AsStateOfDefinitelyOccupied(
                "00000011110000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000"
                );
            var expectedCount = 0;
            var actualCount   = StateTable.Filter(input, inputState).Count;

            Assert.AreEqual(expectedCount, actualCount);
        }