public void CalculateMembershipDegreeTest()
        {
            var set = new FuzzySet();
            set.RegisterMembershipFunction(Function);

            var value = set.CalculateMembershipDegree(10);

            Assert.AreEqual(value, 0.038461538461538464);
        }
        public void ToStringTest()
        {
            var set = new FuzzySet();
            set.RegisterMembershipFunction(new Func<double, double>(x => x));
            double[] values = { 6, 7, 8, 9, 10 };
            set.AddRange(values);

            var expected = "1/6, 1/7, 1/8, 1/9, 1/10";
            var result = set.ToString();

            Assert.AreEqual(expected, result);
        }
        public void AddRangeTest()
        {
            var set = new FuzzySet();
            set.RegisterMembershipFunction(Function);

            double[] values = { 6, 7, 8, 9, 10, 1, 2, 3, 4, 5 };
            set.AddRange(values);

            Assert.AreEqual(set.Elements.Count, values.Length);

            var cursor = set.Elements.GetEnumerator();
            double i = 1;
            while (cursor.MoveNext())
            {
                Assert.AreEqual(cursor.Current.Value.X, i);
                i += 1;
            }
        }
Beispiel #4
0
        /// <summary>
        /// CreateFuzzySetDeltaError
        /// </summary>
        private void CreateFuzzySetForce()
        {
            //armazena os FuzzySets e seu valor linguistico
            var values = this.FuzzyValues;

            // Valores para delta erro (angulo do pendulo)
            var set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(-110, -70.0, -30.0, x));
            set.AddRange((-70.0).GetRoundedRange(-30.0, Step, RoundDigits));
            this.FuzzySetForce.Add(set);
            values.AddFuzzyValue("FMN", set);

            set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(-60.0, -30.0, 0.0, x));
            set.AddRange((-60.0).GetRoundedRange(0.0, Step, RoundDigits));
            this.FuzzySetForce.Add(set);
            values.AddFuzzyValue("FN", set);

            set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(-15, 0, 15, x));
            set.AddRange((-15.0).GetRoundedRange(15.0, Step, RoundDigits));
            this.FuzzySetForce.Add(set);
            values.AddFuzzyValue("FZ", set);

            set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(0, 30, 60, x));
            set.AddRange(0d.GetRoundedRange(60, Step, RoundDigits));
            this.FuzzySetForce.Add(set);
            values.AddFuzzyValue("FP", set);

            set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(30, 70, 110, x));
            set.AddRange(30d.GetRoundedRange(70, Step, RoundDigits));
            this.FuzzySetForce.Add(set);
            values.AddFuzzyValue("FMP", set);
        }
Beispiel #5
0
        /// <summary>
        /// CreateFuzzySetError
        /// </summary>
        private void CreateFuzzySetError()
        {
            //armazena os FuzzySets e seu valor linguistico
            var values = this.FuzzyValues;

            // Valores para erro (angulo do pendulo)
            var set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(-6.30, -3.15, 0, x));
            set.AddRange((-3.15).GetRoundedRange(0, Step, RoundDigits));
            this.FuzzySetError.Add(set);
            values.AddFuzzyValue("EN", set);

            set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(-0.50, 0, 0.50, x));
            set.AddRange((-0.50).GetRoundedRange(0.50, Step, RoundDigits));
            this.FuzzySetError.Add(set);
            values.AddFuzzyValue("EZ", set);

            set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(0, 3.15, 6.30, x));
            set.AddRange(0d.GetRoundedRange(3.15, Step, RoundDigits));
            this.FuzzySetError.Add(set);
            values.AddFuzzyValue("EP", set);
        }
Beispiel #6
0
        /// <summary>
        /// CreateFuzzySetDeltaError
        /// </summary>
        private void CreateFuzzySetDeltaError()
        {
            //armazena os FuzzySets e seu valor linguistico
            var values = this.FuzzyValues;

            // Valores para delta erro (angulo do pendulo)
            var set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(-4.30, -3.15, -2.0, x));
            set.AddRange((-3.15).GetRoundedRange(-2.0, Step, RoundDigits));
            this.FuzzySetDeltaError.Add(set);
            values.AddFuzzyValue("DMN", set);

            set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(-2.5, -1.25, 0, x));
            set.AddRange((-2.5).GetRoundedRange(0, Step, RoundDigits));
            this.FuzzySetDeltaError.Add(set);
            values.AddFuzzyValue("DN", set);

            set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(-0.5, 0, 0.5, x));
            set.AddRange((-0.5).GetRoundedRange(0.5, Step, RoundDigits));
            this.FuzzySetDeltaError.Add(set);
            values.AddFuzzyValue("DZ", set);

            set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(0.0, 1.25, 2.5, x));
            set.AddRange(0.0.GetRoundedRange(2.5, Step, RoundDigits));
            this.FuzzySetDeltaError.Add(set);
            values.AddFuzzyValue("DP", set);

            set = new FuzzySet();
            set.RegisterMembershipFunction(
                x => TipicalMembershipFunction.TriangularMembershipFunction(2.0, 3.15, 4.30, x));
            set.AddRange(2.0.GetRoundedRange(3.15, Step, RoundDigits));
            this.FuzzySetDeltaError.Add(set);
            values.AddFuzzyValue("DMP", set);

            //var set = new FuzzySet();
            //set.RegisterMembershipFunction(
            //    x => TipicalMembershipFunction.TriangularMembershipFunction(-6.30, -3.15, -0.30, x));
            //set.AddRange((-3.15).GetRoundedRange(-0.30, Step, RoundDigits));
            //this.FuzzySetDeltaError.Add(set);
            //values.AddFuzzyValue("DN", set);

            //set = new FuzzySet();
            //set.RegisterMembershipFunction(
            //    x => TipicalMembershipFunction.TriangularMembershipFunction(-0.30, 0, 0.30, x));
            //set.AddRange((-0.30).GetRoundedRange(0.30, Step, RoundDigits));
            //this.FuzzySetDeltaError.Add(set);
            //values.AddFuzzyValue("DZ", set);

            //set = new FuzzySet();
            //set.RegisterMembershipFunction(
            //    x => TipicalMembershipFunction.TriangularMembershipFunction(0.30, 3.15, 6.30, x));
            //set.AddRange(0.30.GetRoundedRange(3.15, Step, RoundDigits));
            //this.FuzzySetDeltaError.Add(set);
            //values.AddFuzzyValue("DP", set);
        }