Exemplo n.º 1
0
        internal void Evaluate_WithThreeGroupCompoundStatementAndOtherFunctions_ReturnsExpectedResult()
        {
            // Arrange
            var tnorm   = TriangularNormFactory.Lukasiewicz();
            var tconorm = TriangularConormFactory.ProbabilisticSum();

            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.85, Math.Round(result.Value, 2));
        }
Exemplo n.º 2
0
        internal void Evaluate_WithVariousValidValues_ReturnsExpectedResult(
            double membershipA,
            double membershipB,
            double expected)
        {
            // Arrange
            var algebraicProduct = TriangularConormFactory.ProbabilisticSum();

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

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