forked from giacomelli/GeneticSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AndTermination.cs
36 lines (34 loc) · 1.22 KB
/
AndTermination.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
using System.ComponentModel;
using System.Linq;
namespace GeneticSharp
{
/// <summary>
/// An termination where you can combine others ITerminations with a AND logical operator.
/// </summary>
[DisplayName("And")]
public class AndTermination : LogicalOperatorTerminationBase
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="AndTermination"/> class.
/// </summary>
/// <param name="terminations">The terminations.</param>
public AndTermination(params ITermination[] terminations) : base(terminations)
{
}
#endregion
#region Methods
/// <summary>
/// Determines whether the specified geneticAlgorithm reached the termination condition.
/// </summary>
/// <param name="geneticAlgorithm">The genetic algorithm.</param>
/// <returns>
/// True if termination has been reached, otherwise false.
/// </returns>
protected override bool PerformHasReached(IGeneticAlgorithm geneticAlgorithm)
{
return Terminations.All(t => t.HasReached(geneticAlgorithm));
}
#endregion
}
}