geneticengine.problems

Submodules

Attributes

P

__ALL__

Classes

Fitness

Problem

Represents the Optimization Problem being solved.

SequentialObjectiveProblem

SequentialObjectiveProblem is defined by a list of objectives that are intended to be either maximized/minimized in order.

SingleObjectiveProblem

A problem that is characterized by a single value.

MultiObjectiveProblem

Represents the Optimization Problem being solved.

LazyMultiObjectiveProblem

LazyMultiObjectiveProblem is used for problems whose number of objectives is not known a-priori.

Package Contents

class geneticengine.problems.Fitness

Bases: NamedTuple

maximizing_aggregate: float
fitness_components: list[float]
__str__()
geneticengine.problems.P
class geneticengine.problems.Problem(fitness_function, minimize, target=None)

Bases: abc.ABC, Generic[P]

Represents the Optimization Problem being solved.

Parameters:
  • fitness_function (Callable[[P], list[float]])

  • minimize (list[bool])

  • target (Optional[list[float]])

minimize: list[bool]
target: list[float] | None
ff
evaluate(phenotype)
Parameters:

phenotype (P)

Return type:

Fitness

key_function(a)

Returns the (maximizing) fitness of the individual as a single float.

Parameters:

a (Fitness)

Return type:

float

abstractmethod is_better(a, b)

Returns whether the first fitness is better than the second.

Parameters:
Return type:

bool

number_of_objectives()
Return type:

int

is_solved(fitness)
Parameters:

fitness (Fitness)

Return type:

bool

class geneticengine.problems.SequentialObjectiveProblem(fitness_function, minimize, target=None)

Bases: Problem[P]

SequentialObjectiveProblem is defined by a list of objectives that are intended to be either maximized/minimized in order.

Parameters:
  • fitness_function (Callable[[P], list[float]])

  • minimize (list[bool])

  • target (Optional[list[float]])

is_better(a, b)

Returns whether the first fitness is better than the second.

Parameters:
Return type:

bool

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

Bases: SequentialObjectiveProblem[P]

A problem that is characterized by a single value.

Parameters:
  • fitness_function (Callable[[P], float])

  • minimize (bool)

  • target (Optional[float])

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

Bases: Problem[P]

Represents the Optimization Problem being solved.

Parameters:
  • fitness_function (Callable[[P], list[float]])

  • minimize (list[bool])

  • target (Optional[list[float]])

is_better(a, b)

To be better in a multi-objective setting, it needs to be better in all objectives.

Parameters:
Return type:

bool

class geneticengine.problems.LazyMultiObjectiveProblem(fitness_function, minimize=False, target=None)

Bases: MultiObjectiveProblem

LazyMultiObjectiveProblem is used for problems whose number of objectives is not known a-priori.

Parameters:
  • fitness_function (Callable[[P], list[float]])

  • minimize (bool)

  • target (Optional[float])

initialized = False
future_minimize = False
future_target = None
evaluate(phenotype)
Parameters:

phenotype (P)

Return type:

Fitness

number_of_objectives()
Return type:

int

geneticengine.problems.__ALL__