예제 #1
0
        internal void IsConvex_WhenPointsNotConvex_ReturnsFalse()
        {
            // Arrange
            var function = TrapezoidalFunction.Create(0, 1, 2, 3);
            var fuzzySet = new FuzzySet("some_fuzzy_state", function);

            // Act
            var result = fuzzySet.IsConvex;

            // Assert
            Assert.False(result);
        }
예제 #2
0
        internal void FuzzySetCollection_WhenUpperBoundLessThanHighestBoundOfFunctions_Throws()
        {
            // Arrange
            var fuzzySet1 = new FuzzySet("set1", TrapezoidalFunction.Create(1, 2, 3, 4));
            var fuzzySet2 = new FuzzySet("set1", SingletonFunction.Create(1));

            var fuzzySetCollection = new List <FuzzySet> {
                fuzzySet1, fuzzySet2
            };

            // Act
            // Assert
            Assert.Throws <ArgumentOutOfRangeException>(() => new LinguisticVariable("test", fuzzySetCollection, 1, 3));
        }
예제 #3
0
 /// <summary>
 /// Returns a <see cref="LinguisticVariable"/> representing water temperature.
 /// </summary>
 /// <returns>
 /// The <see cref="LinguisticVariable"/>.
 /// </returns>
 public static LinguisticVariable WaterTemp()
 {
     return(new LinguisticVariable(
                InputVariable.WaterTemp,
                new List <FuzzySet>
     {
         new FuzzySet(TestKit.WaterTemp.Frozen, SingletonFunction.Create(0)),
         new FuzzySet(TestKit.WaterTemp.Freezing, TriangularFunction.Create(0, 5, 10)),
         new FuzzySet(TestKit.WaterTemp.Cold, TrapezoidalFunction.Create(5, 10, 15, 20)),
         new FuzzySet(TestKit.WaterTemp.Warm, TrapezoidalFunction.Create(15, 25, 35, 40)),
         new FuzzySet(TestKit.WaterTemp.Hot, TrapezoidalFunction.Create(35, 60, 80, 100)),
         new FuzzySet(TestKit.WaterTemp.Boiling, TrapezoidalFunction.CreateWithRightEdge(95, 100))
     },
                -20,
                200));
 }
        internal void Create_GetMembershipWithVariousInputs_ReturnsExpectedResult(
            double x1,
            double x2,
            double x3,
            double x4,
            double input,
            double expected)
        {
            // Arrange
            var function = TrapezoidalFunction.Create(x1, x2, x3, x4);

            // Act
            var result = function.GetMembership(input);

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