-
-
Notifications
You must be signed in to change notification settings - Fork 335
/
MutationBase.cs
36 lines (33 loc) · 1.27 KB
/
MutationBase.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
namespace GeneticSharp
{
/// <summary>
/// Base class for IMutation's implementation.
/// </summary>
public abstract class MutationBase : IMutation
{
#region Properties
/// <summary>
/// Gets or sets a value indicating whether the operator is ordered (if can keep the chromosome order).
/// </summary>
public bool IsOrdered { get; protected set; }
#endregion
#region Methods
/// <summary>
/// Mutate the specified chromosome.
/// </summary>
/// <param name="chromosome">The chromosome.</param>
/// <param name="probability">The probability to mutate each chromosome.</param>
public void Mutate(IChromosome chromosome, float probability)
{
ExceptionHelper.ThrowIfNull("chromosome", chromosome);
PerformMutate(chromosome, probability);
}
/// <summary>
/// Mutate the specified chromosome.
/// </summary>
/// <param name="chromosome">The chromosome.</param>
/// <param name="probability">The probability to mutate each chromosome.</param>
protected abstract void PerformMutate(IChromosome chromosome, float probability);
#endregion
}
}