-
-
Notifications
You must be signed in to change notification settings - Fork 335
/
TerminationBase.cs
44 lines (39 loc) · 1.7 KB
/
TerminationBase.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
namespace GeneticSharp
{
/// <summary>
/// Base class for ITerminations implementations.
/// </summary>
public abstract class TerminationBase : ITermination
{
#region Fields
private bool m_hasReached;
#endregion
#region Methods
/// <summary>
/// Determines whether the specified geneticAlgorithm reached the termination condition.
/// </summary>
/// <returns>True if termination has been reached, otherwise false.</returns>
/// <param name="geneticAlgorithm">The genetic algorithm.</param>
public bool HasReached(IGeneticAlgorithm geneticAlgorithm)
{
ExceptionHelper.ThrowIfNull("geneticAlgorithm", geneticAlgorithm);
m_hasReached = PerformHasReached(geneticAlgorithm);
return m_hasReached;
}
/// <summary>
/// Returns a <see cref="System.String"/> that represents the current <see cref="GeneticSharp.LogicalOperatorTerminationBase"/>.
/// </summary>
/// <returns>A <see cref="System.String"/> that represents the current <see cref="GeneticSharp.LogicalOperatorTerminationBase"/>.</returns>
public override string ToString()
{
return "{0} (HasReached: {1})".With(GetType().Name, m_hasReached);
}
/// <summary>
/// Determines whether the specified geneticAlgorithm reached the termination condition.
/// </summary>
/// <returns>True if termination has been reached, otherwise false.</returns>
/// <param name="geneticAlgorithm">The genetic algorithm.</param>
protected abstract bool PerformHasReached(IGeneticAlgorithm geneticAlgorithm);
#endregion
}
}