예제 #1
0
def learn_DNF__recombination():
    dnf = DNF()
    length = 58
    epsilon = (2**-53)
    tau = (epsilon / length)**3 * log(1 / epsilon)

    tolerance = ConjunctionTolerance(length, epsilon)
    conjunction_performance_oracle = OneSidedPerformanceOracleWithTolerance(
        dnf, tau)
    performance_oracle = DNFOneSidePerformanceOracleWithTolerance(
        dnf, tau, epsilon, conjunction_performance_oracle)
    mutation_neighborhood = MonotoneConjunctionNeighborhood()

    recomb_rate = 0.176
    natural_process = RecombinationProcess(recomb_rate)

    neighborhood = NeighborhoodWithOtherRepresentations(
        length, mutation_neighborhood, 0.1, natural_process)

    recombinator = Recombinator(neighborhood, performance_oracle, tolerance,
                                epsilon)
    algorithm = ConstantPopulationMutationConjunctionAlgorithm(
        recombinator, length, epsilon, performance_oracle, 75)

    print algorithm.learn_ideal_function_until_match()
class TestRecombinationProcess(unittest.TestCase):
    def setUp(self):
        self.process = RecombinationProcess()

    def test_get_recomb_of_two_reps_without_mutation(self):

        first_rep = (1, 3, 5)
        second_rep = (2, 4, 6)

        desc_rep = self.process.get_a_mutation_from_the_reps(first_rep, second_rep)

        self.assertIn(desc_rep[0], [1, 2])
        self.assertIn(desc_rep[1], [3, 4])
        self.assertIn(desc_rep[2], [5, 6])
예제 #3
0
def recombination_main():
    common_classes = CommonClassesCreator()

    length, epsilon, mutation_neighborhood, tolerance = common_classes.get_common_classes()

    mutation_factor = 0.1

    concept_class = MonotoneConjunction(length)
    performance = common_classes.get_perf_without_precomp(concept_class)

    recomb_process = RecombinationProcess()
    neighborhood = NeighborhoodWithOtherRepresentations(length, mutation_neighborhood,
                                                        mutation_factor, recomb_process)
    recombinator = Recombinator(neighborhood, performance, tolerance, epsilon)
    recombination = RecombinationConjunctionAlgorithm(recombinator, length, epsilon, concept_class)

    recombination.learn_ideal_function(concept_class)
 def setUp(self):
     self.process = RecombinationProcess()
예제 #5
0
 def create_recombination_process(self, rate=1):
     self.natural_process = RecombinationProcess(rate)