Esempio n. 1
0
        public void CopyNumbers()
        {
            var levels = new Dictionary<double, IntervalD>
                {
                    {0.0, new IntervalD(1.0, 3.0)},
                    {0.5, new IntervalD(1.5, 2.5)},
                    {1.0, new IntervalD(2.0, 2.0)},
                };
            var x = new DiscreteFuzzyNumber(levels);
            var newLevels = new Dictionary<double, IntervalD>
                {
                    {0.0, new IntervalD(-2.0, 2.0)},
                    {0.25, new IntervalD(-1.5, 1.5)},
                    {0.5, new IntervalD(-1.0, 1.0)},
                    {1.0, new IntervalD(0.0, 0.0)},
                };
            var y = new DiscreteFuzzyNumber(newLevels);

            x.Set(y);

            Assert.That(x.LevelsCount, Is.EqualTo(4));
            Assert.That(x.GetAlphaLevel(0.0), Is.EqualTo(new IntervalD(-2.0, 2.0)));
            Assert.That(x.GetAlphaLevel(0.25), Is.EqualTo(new IntervalD(-1.5, 1.5)));
            Assert.That(x.GetAlphaLevel(0.5), Is.EqualTo(new IntervalD(-1.0, 1.0)));
            Assert.That(x.GetAlphaLevel(1.0), Is.EqualTo(new IntervalD(0.0, 0.0)));
        }
Esempio n. 2
0
        public void ReturnActualAlphaLevels()
        {
            var levels = new Dictionary<double, IntervalD>
                {
                    {0.0, new IntervalD(1.0, 3.0)},
                    {0.5, new IntervalD(0.5, 2.5)},
                    {1.0, new IntervalD(2.0, 2.0)},
                };
            var number = new DiscreteFuzzyNumber(levels);
            var level0_0 = number.GetAlphaLevel(0.0);
            var level0_5 = number.GetAlphaLevel(0.5);
            var level1_0 = number.GetAlphaLevel(1.0);

            Assert.That(level0_0, Is.EqualTo(new IntervalD(1.0, 3.0)));
            Assert.That(level0_5, Is.EqualTo(new IntervalD(0.5, 2.5)));
            Assert.That(level1_0, Is.EqualTo(new IntervalD(2.0, 2.0)));
        }