Пример #1
0
        public void Apply_With_No_Point()
        {
            var msf = new MembershipFunction();

            var sut = new MinMsfScalingStrategy();

            var result = sut.Apply(msf, 0.5);

            Assert.AreEqual(0, result.Count);
        }
Пример #2
0
        public void Apply_With_Triangle_3()
        {
            var msf = new MembershipFunction { { -7, 0 }, { -5, 1 }, { 0, 0 } };

            var sut = new MinMsfScalingStrategy();

            var result = sut.Apply(msf, 0.5);

            Assert.AreEqual(4, result.Count);
            Assert.AreEqual(0, msf.Apply(-7), 0.000000000001);
            Assert.AreEqual(0.5, msf.Apply(-6), 0.000000000001);
            Assert.AreEqual(0.5, msf.Apply(-2.5), 0.000000000001);
            Assert.AreEqual(0, msf.Apply(0), 0.000000000001);
        }
Пример #3
0
        public void Apply_With_Triangle()
        {
            var msf = new MembershipFunction{ { 0, 0 }, { 1, 1 }, { 2, 0 } };

            var sut = new MinMsfScalingStrategy();

            var result = sut.Apply(msf, 0.5);

            Assert.AreEqual(4, result.Count);

            Assert.IsTrue(result.Contains(new KeyValuePair<double, double>(0, 0)));
            Assert.IsTrue(result.Contains(new KeyValuePair<double, double>(0.5, 0.5)));
            Assert.IsTrue(result.Contains(new KeyValuePair<double, double>(1.5, 0.5)));
            Assert.IsTrue(result.Contains(new KeyValuePair<double, double>(2, 0)));
        }
Пример #4
0
        public void Apply_With_One_Point()
        {
            var msf = new MembershipFunction{{0, 0.7}};

            var sut = new MinMsfScalingStrategy();

            var result1 = sut.Apply(msf, 0.5);
            var result2 = sut.Apply(msf, 0.9);

            Assert.AreEqual(1, result1.Count);
            foreach (var point in result1)
                Assert.AreEqual(0.5, point.Value);

            Assert.AreEqual(1, result2.Count);
            foreach (var point in result2)
                Assert.AreEqual(0.7, point.Value);
        }
Пример #5
0
        public void ToStringTest()
        {
            var sut = new MinMsfScalingStrategy();

            Assert.AreEqual("Minumum Msf Scaling", sut.ToString());
        }