private static IFuzzyNumber Operation(Func<double, double, double> f, IFuzzyNumber y, IFuzzyNumber x) { var resultLevels = new Dictionary<double, IntervalD>(); y.ForeachLevel((alpha, leftLevel) => { var rightLevel = x.GetAlphaLevel(alpha); var leftProduct = f(leftLevel.X, rightLevel.X); var leftRightProduct = f(leftLevel.X, rightLevel.Y); var rightLeftProduct = f(leftLevel.Y, rightLevel.X); var rightProduct = f(leftLevel.Y, rightLevel.Y); var left = Math.Min(Math.Min(leftProduct, leftRightProduct), Math.Min(rightProduct, rightLeftProduct)); var right = Math.Max(Math.Max(leftProduct, leftRightProduct), Math.Max(rightProduct, rightLeftProduct)); resultLevels.Add(alpha, new IntervalD(left, right)); }); return new DiscreteFuzzyNumber(resultLevels); }
public IFuzzyNumber Sum(IFuzzyNumber x) { var resultLevels = new Dictionary<double, IntervalD>(); foreach (var leftlevel in _alphaLevels) { var rightLevel = x.GetAlphaLevel(leftlevel.Key); resultLevels.Add(leftlevel.Key, rightLevel + leftlevel.Value); } return new DiscreteFuzzyNumber(resultLevels); }