forked from giacomelli/GeneticSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrTermination.cs
37 lines (35 loc) · 1.21 KB
/
OrTermination.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
using System.ComponentModel;
using System.Linq;
namespace GeneticSharp.Domain.Terminations
{
/// <summary>
/// An termination where you can combine others ITerminations with a OR logical operator.
/// </summary>
[DisplayName("Or")]
public class OrTermination : LogicalOperatorTerminationBase
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="OrTermination"/> class.
/// </summary>
/// <param name="terminations">The terminations.</param>
public OrTermination(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.Any(t => t.HasReached(geneticAlgorithm));
}
#endregion
}
}