Ejemplo n.º 1
0
def learn_DNF__basic_model():
    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()
    mutation_probability = ConjunctionMutationProbability(mutation_neighborhood)

    mutator = Mutator(mutation_neighborhood, performance_oracle, tolerance, mutation_probability, epsilon)
    algorithm = ConjunctionEvolvabilityAlgorithm(mutator, length, epsilon, performance_oracle)

    print algorithm.learn_ideal_function_until_match()
    def __init__(self, is_neigh_precomp=True):
        self.length = 40
        self.epsilon = 2**-31
        self.number_of_activations = 10
        self.number_of_mutations_from_mutator = 40
        self.population_size = 200

        self.tolerance = ConjunctionTolerance(self.length, self.epsilon)
        self.tau = (self.epsilon / self.length)**3 * log(1/self.epsilon)

        self.representation_class = None

        if is_neigh_precomp:
            self.representation_class = get_set_of_all_representations_with_length(self.length)
            self.mutation_neighborhood = PrecompMonotoneConjunctionNeighborhood(self.representation_class)
        else:
            self.mutation_neighborhood = MonotoneConjunctionNeighborhood()

        self.mutation_probability = ConjunctionMutationProbability(self.mutation_neighborhood)
Ejemplo n.º 3
0
    def setUp(self):
        self.neighbors_finder = Mock()

        self.conjunction_mutation_probability = ConjunctionMutationProbability(
            self.neighbors_finder)