geneticengine.problems
Submodules
Package Contents
Classes
An Abstract class that SingleObjectiveProblem and MultiObjectiveProblem |
|
SingleObjectiveProblem is a class that extends the Problem class. |
|
MultiObjectiveProblem is a class that extends the Problem class. |
Functions
This wrapper takes a SingleObjectiveProblem and adds a penalty for |
Attributes
- class geneticengine.problems.Fitness
Bases:
NamedTuple
- maximizing_aggregate: float
- fitness_components: list[float]
- __str__()
Return str(self).
- geneticengine.problems.P
- class geneticengine.problems.Problem
Bases:
abc.ABC
An Abstract class that SingleObjectiveProblem and MultiObjectiveProblem extends to.
- Parameters:
minimize (bool | list[bool]) – When switch on, the fitness function is reversed, so that a higher result from the fitness function corresponds to a less fit solution.
fitness_function (Callable[[P], float] | Callable[[P], list[float]]) – The fitness function. Should take in any valid individual and return a float or a list of floats, depending if its a single objetive problem or a multi objective problem.
- minimize: list[bool] | bool
- epsilon: float
- key_function(a)
Returns the (maximizing) fitness of the individual as a single float.
- Parameters:
a (Fitness)
- Return type:
float
- is_better(a, b)
Returns whether the first fitness is better than the second.
- abstract number_of_objectives()
- Return type:
int
- class geneticengine.problems.SingleObjectiveProblem(fitness_function, minimize=False)
Bases:
Problem
SingleObjectiveProblem is a class that extends the Problem class.
- Parameters:
minimize (bool) – When switch on, the fitness function is reversed, so that a higher result from the fitness function corresponds to a less fit solution.
fitness_function (Callable[[P], float]) – The fitness function. Should take in any valid individual and return a float.
- number_of_objectives()
- Return type:
int
- class geneticengine.problems.MultiObjectiveProblem(minimize, fitness_function, best_individual_criteria_function=None, aggregate_fitness=None)
Bases:
Problem
MultiObjectiveProblem is a class that extends the Problem class.
- Parameters:
minimize (list[bool] | bool) – When switch on, the fitness function is reversed, so that a higher result from the fitness function corresponds to a less fit solution. When a list is passed, each element of the list corresponds to a fitness component. When a bool is passed all the fitness component of the problem are minimized or maximized. when giving a bool, the selection algorithm must have that into consideration and create a list of bools with the same size as the number of the fitness components of an Individual.
fitness_function (Callable[[P], list[bool]]) – The fitness function. Should take in any valid individual and return a list of float.
best_individual_criteria_function (Optional(Callable[[P], float]) – This function allow the user to choose how to find the best individual in a generation (default = None , this means that the individual with the best fitness is the one considered as the best in that generation)
aggregate_fitness (Callable[[list[float]], float] | None)
- minimize: list[bool] | bool
- ff: dict[str, Any]
- number_of_objectives()
- Return type:
int
- geneticengine.problems.wrap_depth_minimization(p)
This wrapper takes a SingleObjectiveProblem and adds a penalty for bigger trees.
- Parameters:
- Return type: