Пример #1
0
        internal void Evaluate_WithThreeGroupCompoundStatementAndEinsteinFunctions_ReturnsExpectedResult()
        {
            // Arrange
            var tnorm   = TriangularNormFactory.EinsteinProduct();
            var tconorm = TriangularConormFactory.EinsteinSum();

            var evaluator = new FuzzyEvaluator(tnorm, tconorm);

            var evaluations = new List <Evaluation>
            {
                // Statement group 1
                new Evaluation(LogicOperators.If(), UnitInterval.Create(0.25)),
                new Evaluation(LogicOperators.And(), UnitInterval.Create(0.0)),
                new Evaluation(LogicOperators.And(), UnitInterval.Create(0.2)),

                // Statement group 2
                new Evaluation(LogicOperators.Or(), UnitInterval.Create(1)),
                new Evaluation(LogicOperators.And(), UnitInterval.Create(0.9)),
                new Evaluation(LogicOperators.And(), UnitInterval.Create(0.8)),

                // Statement group 3
                new Evaluation(LogicOperators.Or(), UnitInterval.Create(0.5)),
                new Evaluation(LogicOperators.And(), UnitInterval.Create(1)),
                new Evaluation(LogicOperators.And(), UnitInterval.Create(1))
            };

            // Act
            var result = evaluator.Evaluate(evaluations);

            // Assert
            Assert.Equal(0.891304347826087, result.Value);
        }
Пример #2
0
        internal void Evaluate_WithVariousValidValues_ReturnsExpectedResult(
            double membershipA,
            double membershipB,
            double expected)
        {
            // Arrange
            var einsteinSum = TriangularConormFactory.EinsteinSum();

            // Act
            var result = einsteinSum.Evaluate(UnitInterval.Create(membershipA), UnitInterval.Create(membershipB));

            // Assert
            Assert.Equal(UnitInterval.Create(expected), result);
        }