forked from giacomelli/GeneticSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IChromosome.cs
88 lines (78 loc) · 3.02 KB
/
IChromosome.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
namespace GeneticSharp
{
/// <summary>
/// Defines an interface for a chromosome.
/// <remarks>
/// In genetic algorithms, a chromosome (also sometimes called a genome) is a set of parameters
/// which define a proposed solution to the problem that the genetic algorithm is trying to solve.
/// The chromosome is often represented as a simple string, although a wide variety of other data
/// structures are also used.
/// <see href="http://en.wikipedia.org/wiki/Chromosome_(genetic_algorithm)">http://en.wikipedia.org/wiki/Chromosome_(genetic_algorithm)</see>
/// </remarks>
/// </summary>
public interface IChromosome : IComparable<IChromosome>
{
#region Properties
/// <summary>
/// Gets or sets the fitness.
/// </summary>
/// <value>The fitness.</value>
double? Fitness { get; set; }
/// <summary>
/// Gets the length.
/// </summary>
/// <value>The length.</value>
int Length { get; }
#endregion
#region Methods
/// <summary>
/// Generates the gene for the specified index.
/// </summary>
/// <returns>The gene.</returns>
/// <param name="geneIndex">Gene index.</param>
Gene GenerateGene(int geneIndex);
/// <summary>
/// Replaces the gene in the specified index.
/// </summary>
/// <param name="index">The gene index to replace.</param>
/// <param name="gene">The new gene.</param>
void ReplaceGene(int index, Gene gene);
/// <summary>
/// Replaces the genes starting in the specified index.
/// </summary>
/// <remarks>
/// The genes to be replaced can't be greater than the available space between the start index and the end of the chromosome.
/// </remarks>
/// <param name="startIndex">Start index.</param>
/// <param name="genes">The genes.</param>
void ReplaceGenes(int startIndex, Gene[] genes);
/// <summary>
/// Resizes the chromosome to the new length.
/// </summary>
/// <param name="newLength">The new length.</param>
void Resize(int newLength);
/// <summary>
/// Gets the gene in the specified index.
/// </summary>
/// <returns>The gene.</returns>
/// <param name="index">The gene index.</param>
Gene GetGene(int index);
/// <summary>
/// Gets the genes.
/// </summary>
/// <returns>The genes.</returns>
Gene[] GetGenes();
/// <summary>
/// Creates a new chromosome using the same structure of this.
/// </summary>
/// <returns>The new chromosome.</returns>
IChromosome CreateNew();
/// <summary>
/// Creates a clone.
/// </summary>
/// <returns>The chromosome clone.</returns>
IChromosome Clone();
#endregion
}
}