using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Text; namespace Esiur.Analysis.Fuzzy { public enum Operation { Intersection, Union } public class OperationSet : INumericalSet { public Operation Operation { get; set; } public INumericalSet[] Sets { get; internal set; } public double AlphaCut { get; set; } = double.MaxValue; public double this[double index] { get { double x = 0; if (Operation == Operation.Union) x = Sets.Max(x => x[index]); else if (Operation == Operation.Intersection) x = Sets.Min(x => x[index]); // Alpha might be changed for this instance return x > AlphaCut ? AlphaCut : x; } } public OperationSet(Operation operation, params INumericalSet[] sets) { Sets = sets; if (operation == Operation.Intersection) AlphaCut = sets.Min(x => x.AlphaCut); else if (operation == Operation.Union) AlphaCut = sets.Max(x => x.AlphaCut); Operation = operation; } public INumericalSet Intersection(INumericalSet with) { return new OperationSet(Operation.Intersection, new INumericalSet[] { this, with }); } public INumericalSet Union(INumericalSet with) { return new OperationSet(Operation.Union, new INumericalSet[] { this, with }); } } }