Problems

Genetic Engine suports both Single and Multi-Objective problems.

The Problem Interface

class geneticengine.problems.Problem

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.

Single-Objective Problem

class geneticengine.problems.SingleObjectiveProblem(fitness_function, minimize=False)

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.

Multi-Objective Problem

class geneticengine.problems.MultiObjectiveProblem(minimize, fitness_function, best_individual_criteria_function=None, aggregate_fitness=None)

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)