Exemplo n.º 1
0
    def test_case9(self):
        """Testing the K Point crossover function - when k > no_students"""

        self.assertRaises(
            ValueError, lambda: kPoint(self.solution1,
                                       self.solution2,
                                       self.supervisors,
                                       self.students,
                                       k=6))
Exemplo n.º 2
0
    def test_case4(self):
        """Testing the K Point Crossover function - when one valid and one dummy solution are passed"""

        self.assertRaises(
            KeyError, lambda: kPoint(self.solution2,
                                     self.dummySolution,
                                     self.supervisors,
                                     self.students,
                                     k=3))
Exemplo n.º 3
0
    def test_case2(self):
        """Testing the kPoint crossover function - for 3sup:4stu solution"""

        solution3 = kPoint(self.solution1,
                           self.solution2,
                           self.supervisors,
                           self.students,
                           k=3)
        result = solution3.isValid(self.students, self.supervisors)
        self.assertTrue(result)
Exemplo n.º 4
0
    def test_case8(self):
        """Testing the K Point crossover function - when k=1"""

        solution3 = kPoint(self.solution1,
                           self.solution2,
                           self.supervisors,
                           self.students,
                           k=1)

        result = solution3.isValid(self.students, self.supervisors)

        self.assertTrue(result)
Exemplo n.º 5
0
    def test_case13(self):
        """Testing the kPoint crossover function - for random 60sup:400stu solution"""

        solution1 = Solution.generateRandomSolution(self.students2,
                                                    self.supervisors2)
        solution2 = Solution.generateRandomSolution(self.students2,
                                                    self.supervisors2)

        solution3 = kPoint(solution1,
                           solution2,
                           self.supervisors2,
                           self.students2,
                           k=15)

        result = solution3.isValid(self.students2, self.supervisors2)

        self.assertTrue(result)
Exemplo n.º 6
0
    def test_case7(self):
        """Testing the K Point crossover function - when k=0"""

        solution3 = kPoint(self.solution1,
                           self.solution2,
                           self.supervisors,
                           self.students,
                           k=0)

        structureResult = (solution3.getGraph().getStructure()
                           == self.solution1.getGraph().getStructure()) or (
                               solution3.getGraph().getStructure()
                               == self.solution2.getGraph().getStructure())
        result = (solution3.isValid(self.students,
                                    self.supervisors)) and (structureResult)

        self.assertTrue(result)
Exemplo n.º 7
0
    def test_case6(self):
        """Testing the K Point Crossover function - for random 3sup:4stu solution"""

        solution1 = Solution.generateRandomSolution(self.students,
                                                    self.supervisors)
        solution2 = Solution.generateRandomSolution(self.students,
                                                    self.supervisors)

        solution3 = kPoint(solution1,
                           solution2,
                           self.supervisors,
                           self.students,
                           k=3)

        result = solution3.isValid(self.students, self.supervisors)

        self.assertTrue(result)