public bool IsConvex() { if (fun == null) { throw new Exception("incorect membership function"); } System.Random random = new System.Random(); var alfa = new double[10]; for (int i = 0; i < 10; i++) { alfa[i] = random.NextDouble(); } for (int i = 0; i < mSet.Count; i++) { for (int j = 0; j < mSet.Count; j++) { foreach (var singleAlfa in alfa) { var a = mSet[i].Item1; var b = mSet[j].Item1; var c = singleAlfa * a + (1 - singleAlfa) * b; if (fun.Calc(c) < Math.Min(mSet[i].Item2, mSet[j].Item2)) { return(false); } } } } return(true); }
public FuzzySet(double[] input, double[] value, IMembershipFunction memberShipFunction) { mSet.Clear(); for (int i = 0; i < input.Length; i++) { mSet.Add(new Tuple <double, double>(input[i], memberShipFunction.Calc(value[i]))); } fun = memberShipFunction; }