Table of Contents

Class Offspring

Namespace
Evolutionary
Assembly
Evolutionary.dll

Provides operators for the Offspring<TIndividual> class.

public static class Offspring
Inheritance
Offspring
Inherited Members

Methods

AddChildren<TIndividual>(Offspring<TIndividual>, IEnumerable<TIndividual>)

Returns a new offspring with the given children appended to the existing children.

public static Offspring<TIndividual> AddChildren<TIndividual>(this Offspring<TIndividual> offspring, IEnumerable<TIndividual> children)

Parameters

offspring Offspring<TIndividual>

The offspring.

children IEnumerable<TIndividual>

The children to add.

Returns

Offspring<TIndividual>

The modified offspring.

Type Parameters

TIndividual

The individuals type.

Eagerly<TIndividual>(Offspring<TIndividual>)

Forces the children to be evaluated eagerly. By default the children are evaluated lazily; hence repeating an operation on the children would also repeat all the preceding operations.

public static Offspring<TIndividual> Eagerly<TIndividual>(this Offspring<TIndividual> offspring)

Parameters

offspring Offspring<TIndividual>

The offspring.

Returns

Offspring<TIndividual>

The modified offspring.

Type Parameters

TIndividual

The individuals type.

Mutate<TIndividual>(Offspring<TIndividual>, int, Func<TIndividual, Random, TIndividual>)

Adds count children that are created by mutating randomly selected parents.

public static Offspring<TIndividual> Mutate<TIndividual>(this Offspring<TIndividual> offspring, int count, Func<TIndividual, Random, TIndividual> mutate)

Parameters

offspring Offspring<TIndividual>

The offspring.

count int

The number of children to create.

mutate Func<TIndividual, Random, TIndividual>

A function that receives a parent and the random number generator, and returns a mutated child.

Returns

Offspring<TIndividual>

The modified offspring.

Type Parameters

TIndividual

The individuals type.

Recombine<TIndividual>(Offspring<TIndividual>, int, Func<TIndividual, TIndividual, Random, IEnumerable<TIndividual>>)

Adds count children that are created by recombining pairs of randomly selected parents.

public static Offspring<TIndividual> Recombine<TIndividual>(this Offspring<TIndividual> offspring, int count, Func<TIndividual, TIndividual, Random, IEnumerable<TIndividual>> recombine)

Parameters

offspring Offspring<TIndividual>

The offspring.

count int

The number of children to create.

recombine Func<TIndividual, TIndividual, Random, IEnumerable<TIndividual>>

A function that receives two parents and the random number generator, and returns one or more children.

Returns

Offspring<TIndividual>

The modified offspring.

Type Parameters

TIndividual

The individuals type.

Recombine<TIndividual>(Offspring<TIndividual>, int, Func<TIndividual, TIndividual, Random, TIndividual>)

Adds count children that are created by recombining pairs of randomly selected parents.

public static Offspring<TIndividual> Recombine<TIndividual>(this Offspring<TIndividual> offspring, int count, Func<TIndividual, TIndividual, Random, TIndividual> recombine)

Parameters

offspring Offspring<TIndividual>

The offspring.

count int

The number of children to create.

recombine Func<TIndividual, TIndividual, Random, TIndividual>

A function that receives two parents and the random number generator, and returns a new child.

Returns

Offspring<TIndividual>

The modified offspring.

Type Parameters

TIndividual

The individuals type.

SelectElite<TIndividual>(Offspring<TIndividual>, int)

Adds the count best individuals of the parent population to the children (elitism). The best individuals are never lost by the following selection.

public static Offspring<TIndividual> SelectElite<TIndividual>(this Offspring<TIndividual> offspring, int count)

Parameters

offspring Offspring<TIndividual>

The offspring.

count int

The number of individuals to preserve.

Returns

Offspring<TIndividual>

The modified offspring.

Type Parameters

TIndividual

The individuals type.

SelectSurvivors<TIndividual>(Offspring<TIndividual>, int)

Reduces the children to the count best individuals. The children are sorted by their fitness.

public static Offspring<TIndividual> SelectSurvivors<TIndividual>(this Offspring<TIndividual> offspring, int count)

Parameters

offspring Offspring<TIndividual>

The offspring.

count int

The number of children that survive.

Returns

Offspring<TIndividual>

The modified offspring.

Type Parameters

TIndividual

The individuals type.

ToPopulation<TIndividual>(Offspring<TIndividual>)

Converts the offspring into a new population. The individuals of the new population are sorted by their fitness.

public static Population<TIndividual> ToPopulation<TIndividual>(this Offspring<TIndividual> offspring)

Parameters

offspring Offspring<TIndividual>

The offspring.

Returns

Population<TIndividual>

The new population.

Type Parameters

TIndividual

The individuals type.

WithChildren<TIndividual>(Offspring<TIndividual>, IEnumerable<TIndividual>)

Returns a new offspring with the given children. The previous children are replaced.

public static Offspring<TIndividual> WithChildren<TIndividual>(this Offspring<TIndividual> offspring, IEnumerable<TIndividual> children)

Parameters

offspring Offspring<TIndividual>

The offspring.

children IEnumerable<TIndividual>

The children.

Returns

Offspring<TIndividual>

The modified offspring.

Type Parameters

TIndividual

The individuals type.