示例#1
0
        public void OrTest()
        {
            var x    = Fuzzy.Create(0.9);
            var y    = Fuzzy.Create(0.7);
            var xOrY = x || y;

            Assert.Equal(x, xOrY);
        }
示例#2
0
        public void XorTest()
        {
            var x     = Fuzzy.Create(0.9);
            var y     = Fuzzy.Create(0.3);
            var xXorY = x ^ y;

            Assert.Equal(Fuzzy.Create(0.7), xXorY);
        }
示例#3
0
        public void AndTest()
        {
            var x     = Fuzzy.Create(0.9);
            var y     = Fuzzy.Create(0.7);
            var xAndY = x && y;

            Assert.Equal(y, xAndY);
        }
示例#4
0
        public void OrTest1()
        {
            Func <Context, Fuzzy> first = context => Fuzzy.Create(context.Value);

            Fuzzy second(Context context) => Fuzzy.Create(context.Value).Not();

            var context = new Context()
            {
                Value = 0.7
            };

            var firstFunc  = STMNT.Is(first.Or(second));
            var secondFunc = STMNT.Is(first).Or(second);

            var resultFirst  = firstFunc(context);
            var resultSecond = secondFunc(context);

            Assert.Equal(resultFirst.Value, resultSecond.Value);
        }
示例#5
0
 public void CreateTest()
 {
     Assert.Equal(0.5, Fuzzy.Create(0.5).Value, MathConstants.Precision);
     Assert.Equal(0.0, Fuzzy.Create(-1.0).Value, MathConstants.Precision);
     Assert.Equal(1.0, Fuzzy.Create(2.0).Value, MathConstants.Precision);
 }
示例#6
0
 public void CreateMaxTest()
 {
     Assert.Equal(0.1, Fuzzy.Create(10, 100).Value, MathConstants.Precision);
     Assert.Equal(0.0, Fuzzy.Create(-1.0, 100).Value, MathConstants.Precision);
     Assert.Equal(1.0, Fuzzy.Create(200.0, 100).Value, MathConstants.Precision);
 }
 public static Fuzzy ToFuzzy(this double value) => Fuzzy.Create(value);
 public static Fuzzy ToFuzzy(this bool value) => Fuzzy.Create(value);