예제 #1
0
파일: test_ga.py 프로젝트: S-Ercan/GA
    def test_ga_uses_one_iteration_for_trivially_satisfiable_problem(self):
        v1 = Variable('a')
        c1 = Clause([Literal(v1)])
        maxsat = MAXSAT([v1], [c1])

        ga = GA(maxsat)
        _, _, iteration = ga.run()
        self.assertEqual(1, iteration)
예제 #2
0
파일: test_ga.py 프로젝트: S-Ercan/GA
    def test_ga_uses_one_iteration_for_unsatisfiable_problem_if_not_below_threshold(self):
        v1 = Variable('a')
        c1 = Clause([Literal(v1, positive=True)])
        c2 = Clause([Literal(v1, positive=False)])
        maxsat = MAXSAT([v1], [c1, c2])

        ga = GA(maxsat, fitness_threshold=0.5)
        _, _, iteration = ga.run()
        self.assertEqual(1, iteration)
예제 #3
0
파일: test_ga.py 프로젝트: S-Ercan/GA
    def test_ga_achieves_fitness_of_one(self):
        v1 = Variable('a')
        c1 = Clause([Literal(v1)])
        maxsat = MAXSAT([v1], [c1])

        ga = GA(maxsat)
        _, fitness, _ = ga.run()

        self.assertEqual(1, fitness)
예제 #4
0
파일: test_ga.py 프로젝트: S-Ercan/GA
    def test_ga_uses_all_iterations_for_unsatisfiable_problem_if_below_threshold(self):
        v1 = Variable('a')
        c1 = Clause([Literal(v1, positive=True)])
        c2 = Clause([Literal(v1, positive=False)])
        maxsat = MAXSAT([v1], [c1, c2])

        ga = GA(maxsat)
        _, _, iteration = ga.run()
        self.assertEqual(iteration, ga.max_iterations)
예제 #5
0
파일: test_ga.py 프로젝트: S-Ercan/GA
    def test_ga_achieves_fitness_of_half(self):
        v1 = Variable('a')
        c1 = Clause([Literal(v1, positive=True)])
        c2 = Clause([Literal(v1, positive=False)])
        maxsat = MAXSAT([v1], [c1, c2])

        ga = GA(maxsat)
        _, fitness, _ = ga.run()

        self.assertEqual(0.5, fitness)