Table of Contents

Class PermutationIndividual

Namespace
AiDotNet.Genetics
Assembly
AiDotNet.dll

Represents an individual encoded as a permutation, suitable for problems like TSP.

public class PermutationIndividual : IEvolvable<PermutationGene, double>
Inheritance
PermutationIndividual
Implements
Inherited Members

Constructors

PermutationIndividual(ICollection<PermutationGene>)

Creates a permutation individual with the specified genes.

public PermutationIndividual(ICollection<PermutationGene> genes)

Parameters

genes ICollection<PermutationGene>

The genes to initialize with.

PermutationIndividual(int, Random)

Creates a new permutation individual with a random permutation of the specified size.

public PermutationIndividual(int size, Random random)

Parameters

size int

The size of the permutation.

random Random

Random number generator for initialization.

Methods

Clone()

Creates a deep clone of this individual.

public IEvolvable<PermutationGene, double> Clone()

Returns

IEvolvable<PermutationGene, double>

A clone of this individual.

GetFitness()

Gets the fitness of this individual.

public double GetFitness()

Returns

double

The fitness score.

GetGenes()

Gets the genes of this individual.

public ICollection<PermutationGene> GetGenes()

Returns

ICollection<PermutationGene>

The collection of genes.

GetPermutation()

Gets the permutation as an array of indices.

public int[] GetPermutation()

Returns

int[]

An array of indices representing the permutation.

InversionMutation(Random)

Applies the inversion mutation by reversing a random subsequence.

public void InversionMutation(Random random)

Parameters

random Random

Random number generator.

OrderCrossover(PermutationIndividual, Random)

Applies the Order Crossover (OX) operator.

public (PermutationIndividual, PermutationIndividual) OrderCrossover(PermutationIndividual other, Random random)

Parameters

other PermutationIndividual

The other parent.

random Random

Random number generator.

Returns

(PermutationIndividual, PermutationIndividual)

Two child permutations created via order crossover.

SetFitness(double)

Sets the fitness of this individual.

public void SetFitness(double fitness)

Parameters

fitness double

The fitness score to set.

SetGenes(ICollection<PermutationGene>)

Sets the genes of this individual.

public void SetGenes(ICollection<PermutationGene> genes)

Parameters

genes ICollection<PermutationGene>

The genes to set.

SwapMutation(Random)

Applies a swap mutation by swapping two random positions.

public void SwapMutation(Random random)

Parameters

random Random

Random number generator.