Records

Evolution

class Logbook

Contains evolution records as a chronological list of dictionaries. Data can be retrieved using the select method with the appropriate names.

property stream: str

A stream of the logbook.

record(**data)

Adds a new entry to the logbook as a list of dictionaries.

Parameters

data – The new entry.

Returns

Nothing.

Return type

None

select(*names)

Returns a list of values for the given names.

Parameters

names – The names of the values to retrieve.

Returns

A list of values for the given names.

Return type

list

pop(index=0)

Retrieves and deletes element at index. The header and the stream will be adjusted to follow the modification.

Parameters

index (int) – The index of the element to retrieve and delete.

Returns

The element at the given index.

Return type

dict

class Statistics(key=None)

Object that compiles statistics on a list of arbitrary objects. When created, the statistics object receives a key argument that is used to get the values on which the statistics will be computed. If not provided, the key argument defaults to the identity function.

The value returned by the key may be a multidimensional object, i.e.: a tuple or a list, as long as the registered statistical function supports it. For example, statistics can be computed directly on multi-objective fitness when using numpy statistical function.

Parameters

key (Optional[Callable]) – A function that takes an object and returns a value on which the statistics will be computed.

register(name, func, *args, **kwargs)

Registers a new statistical function that will be applied to the sequence each time the record method is called.

Parameters
  • name (str) – The name of the statistics function as it would appear in the dictionary of the statistics object.

  • func (Callable) – A function that will compute the desired statistics on the data as preprocessed by the key.

  • args (Optional) – Positional arguments to be passed to the function, optional.

  • kwargs (Optional) – Keyword arguments to be passed to the function, optional.

Returns

Nothing.

Return type

None

compile(data)

Compiles the statistics on the given data.

Parameters

data (Iterable) – The data on which the statistics will be computed.

Returns

A dictionary containing the statistics.

Return type

dict

class MultiStatistics

Object that compiles statistics on a list of arbitrary objects. Allows computation of statistics on multiple keys using a single call to the ‘compile’ method.

register(name, func, *args, **kwargs)

Registers a new statistical function that will be applied to the sequence each time the record method is called.

Parameters
  • name (str) – The name of the statistics function as it would appear in the dictionary of the statistics object.

  • func (Callable) – A function that will compute the desired statistics on the data as preprocessed by the key.

  • args (Optional) – Positional arguments to be passed to the function, optional.

  • kwargs (Optional) – Keyword arguments to be passed to the function, optional.

Returns

Nothing.

Return type

None

compile(data)

Compiles the statistics on the given data.

Parameters

data (Iterable) – The data on which the statistics will be computed.

Returns

A dictionary containing the statistics.

Return type

dict



Individuals

class HallOfFame(maxsize, similar=eq)

The hall of fame contains the best individual that ever lived in the population during the evolution. It is lexicographically sorted at all time so that the first element of the hall of fame is the individual that has the best first fitness value ever seen, according to the weights provided to the fitness at creation time.

Parameters
  • maxsize (int) – The maximum number of individuals to store in the hall of fame.

  • similar (Optional[Callable]) – A function to compare two individuals, optional.

update(population)

Updates the hall of fame with the population by replacing the worst individuals with the best individuals from the population. The size of the hall of fame is kept constant.

Parameters

population (list) – A list of individual with a fitness attribute to update the hall of fame with.

Returns

Nothing.

Return type

None

class ParetoFront(similar=eq)

The Pareto front hall of fame contains all the non-dominated individuals that ever lived in the population. That means that the Pareto front hall of fame can contain an infinity of different individuals.

Parameters

similar (Optional[Callable]) – A function to compare two individuals, optional.

update(population)

Updates the Pareto front hall of fame with the population by adding the individuals from the population that are not dominated by the hall of fame. If any individual in the hall of fame is dominated, it is removed.

Parameters

population (list) – A list of individual with a fitness attribute to update the hall of fame with.

Returns

Nothing.

Return type

None

class History

Maintains a history of the individuals produced in the evolution.

property decorator: Callable

A decorator that adds genealogy history to the individuals.

update(individuals)

Update the genealogy history with the given individuals. This method should be called with the initial population to initialize the history and also after each variation.

Parameters

individuals (list) – The individuals to update the genealogy history with.

Returns

Nothing.

Return type

None

get_genealogy(individual, max_depth=float('inf'))

Get the genealogy of the given individual. The individual must have the ‘history_index’ attribute which is set by the ‘update’ method in order to retrieve its associated genealogy tree. The returned graph contains the parents up to max_depth variations before this individual. The default value of max_depth is up to the beginning of the evolution.

Parameters
  • individual (Individual) – The individual at the root of the genealogy tree.

  • max_depth (float) – The maximum depth of the genealogy tree.

Returns

A dictionary where each key is an individual index and the values are tuples corresponding to the index of the parents.

Return type

dict