deseasion.backend.models.genetic_algorithm module
- class deseasion.backend.models.genetic_algorithm.GAContext(df, features, geo_size, bounds=None, proj='')
Bases:
object
- property df
- property geometries
- property geometries_tree
- property values
- class deseasion.backend.models.genetic_algorithm.GeneticAlgorithm(ctx, size, mutation=None, children=None, filter_clusters=True)
Bases:
object
Genetic algorithm to find the best areas on the decision map.
- Attributes:
population: The population of solution of the genetic algorithm. size (int): The size of the population. iteration (int): The current iteration of the algorithm.
- filter_best()
- iterate()
Iterate the algorithm to the next generation.
- class deseasion.backend.models.genetic_algorithm.Individual(ctx, genes)
Bases:
object
- as_geometry(proj=None)
Return the geometry of the individual.
- check_and_repair_the_geo_size(x, y, alpha1, d1, alpha2, d2, alpha3, d3, alpha4, d4)
- crossover_1(other_parent)
- crossover_2(other_parent)
- crossover_3(other_parent)
- property execution_artifact
- property fitness
Calculate the fitness.
The fitness corresponds of the percentage of the evaluation map covered by the geometry.
- property genes
- property inputs
- local_search()
- mutation_1(other_parent)
Mutate the position (x, y).
- mutation_2(other_parent)
Mutate the vertices (alpha, d).
- classmethod random(ctx)
Create a new random individual.
- class deseasion.backend.models.genetic_algorithm.Population(ctx, individuals)
Bases:
object
- combine(individuals)
Add offsptring to parent population.
- create_children_from_crossover_1(count)
- create_children_from_crossover_2(count)
- create_children_from_crossover_3(count)
- create_children_from_local_search(count)
One parent and one offspring.
- create_children_from_mutation_1(count)
- create_children_from_mutation_2(count)
- classmethod random(ctx, size)
Initialize a population with random individuals.
- Args:
size: the size of the population to generate
- select_roulette(count, replace=False)
Select individuals in the population using the roulette wheel policy.
The probability of selecting an individual depends on its fitness value. An invidiuals with a high fitness will have more chance to be selected than an individual with a low fitness.
- Args:
count: the number of individuals to select replace: allow to select several times the same individual
(default: False)
- Returns:
A new population with selected individuals