コード例 #1
0
        public void AfterSumLevelsCountIsSameAsInFirstNumber()
        {
            var levelsLeft = 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 x = new DiscreteFuzzyNumber(levelsLeft);
            var levelsRight = 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 y = new DiscreteFuzzyNumber(levelsRight);

            var sum = x.Sum(y);

            Assert.That(sum.LevelsCount, Is.EqualTo(3));
        }
コード例 #2
0
        public void CorrectlySumNumbers()
        {
            var levelsLeft = 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 x = new DiscreteFuzzyNumber(levelsLeft);
            var levelsRight = 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 y = new DiscreteFuzzyNumber(levelsRight);

            var sum = x.Sum(y);

            Assert.That(sum.GetAlphaLevel(0.0), Is.EqualTo(new IntervalD(1.0 + 1.0, 3.0 + 3.0)));
            Assert.That(sum.GetAlphaLevel(0.5), Is.EqualTo(new IntervalD(0.5 + 0.5, 2.5 + 2.5)));
            Assert.That(sum.GetAlphaLevel(1.0), Is.EqualTo(new IntervalD(2.0 + 2.0, 2.0 + 2.0)));
        }