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 void Set(IFuzzyNumber source) { _alphaLevels.Clear(); source.ForeachLevel((alpha, interval) => _alphaLevels.Add(alpha, new IntervalD(interval))); }