示例#1
0
 public void T6RuleApply()
 {
     testRule = LinguisticRule.fromJson(TestJsonRule);
     MFSetup();
     testRule.Apply(TestLingVars);
     Debug.Log("[Rule Application Test Resut] : " + testRule.membershipValue.fuzzy);
 }
示例#2
0
 public void T2ConstructComplete()
 {
     testRule = new LinguisticRule(testRuleValue, testActualRule, TestImplication, TestOperator);
     Assert.AreEqual(testRule.rule,
                     testActualRule);
     Assert.AreEqual(testRule.fOperator, TestOperator);
     Assert.AreEqual(testRule.implicationM, TestImplication);
 }
示例#3
0
        public void T7Implication()
        {
            testRule = LinguisticRule.fromJson(TestJsonRule);
            MFSetup();
            testRule.Apply(TestLingVars);

            Debug.Log("[Implication Result at Index " + testNVal + "] : " + testRule.Implication(testNVal, testMF));
        }
示例#4
0
 public void T3ParseJson()
 {
     testRule = LinguisticRule.fromJson(TestJsonRule);
     Assert.AreEqual(
         TestOperator,
         testRule.fOperator);
     Assert.AreEqual(
         TestImplication,
         testRule.implicationM);
     Assert.AreEqual(
         testActualRule,
         testRule.rule);
     Debug.Log("[Test Rule]\n" + testRule.encodeLinguisticJson().Print(true));
 }
示例#5
0
        public void T2ConstructFromJson()
        {
            LinguisticVariable =
                LinguisticVariable.fromJson(JsonLingVar);
            Assert.AreEqual(
                Version,
                LinguisticVariable.JsonVersion);
            Assert.AreEqual(Name, LinguisticVariable.Name);
            foreach (MembershipFunction MF in MFs)
            {
                Assert.IsTrue(
                    LinguisticVariable.membershipFunctions.Exists(
                        mf => mf.membershipValue.linguistic.Equals(
                            MF.membershipValue.linguistic
                            )
                        )
                    );

                Assert.AreEqual(
                    MF.expression,
                    LinguisticVariable.
                    membershipFunctions.Find(
                        mf => mf.membershipValue.linguistic.Equals(
                            MF.membershipValue.linguistic)
                        ).expression
                    );
            }
            foreach (LinguisticRule LR in LRs)
            {
                Assert.IsTrue(
                    LinguisticVariable.linguisticRules.Exists(
                        lr => lr.rule.Equals(
                            LR.rule
                            )
                        )
                    );
                LinguisticRule CorespLR = LinguisticVariable.linguisticRules.Find(
                    mf => mf.membershipValue.linguistic.Equals(
                        LR.membershipValue.linguistic)
                    );
                Assert.AreEqual(LR.rule,
                                CorespLR.rule);
                Assert.AreEqual(LR.implicationM,
                                CorespLR.implicationM);
                Assert.AreEqual(LR.fOperator,
                                CorespLR.fOperator);
            }
        }
示例#6
0
        public void T8Implicate()
        {
            testRule = LinguisticRule.fromJson(TestJsonRule);
            MFSetup();
            testRule.Apply(TestLingVars);
            testRule.Implicate(testMF, 1);

            string LogMsg = "[Implicate Test Result]\n";

            for (int i = 0; i < testRule.implData.data.Count; i++)
            {
                LogMsg += "Index " + (testRule.implData.StartAxis + testRule.implData.spacing * i) +
                          " -> " + testRule.implData.data[i] + "\n";
            }
            Debug.Log(LogMsg);
        }
示例#7
0
 public void T4LinguisticEncode()
 {
     testRule = LinguisticRule.fromJson(TestJsonRule);
     Assert.AreEqual(
         testRuleValue,
         testRule.encodeLinguisticJson().GetField("Value").str
         );
     Assert.AreEqual(
         TestImplication,
         FuzzyImplication.TryParse(
             testRule.encodeLinguisticJson().
             GetField("Implication").str)
         );
     Assert.AreEqual(
         FuzzyOperator.nameOf(TestOperator),
         testRule.encodeLinguisticJson().
         GetField("Operator").str
         );
     Assert.AreEqual(
         testActualRule,
         testRule.encodeLinguisticJson().GetField("Rule").str
         );
 }
示例#8
0
 public void T1Construct()
 {
     testRule = new LinguisticRule(testRuleValue, testActualRule);
     Assert.AreEqual(testRule.rule,
                     testActualRule);
 }
示例#9
0
 public void T5NumericRule()
 {
     testRule = LinguisticRule.fromJson(TestJsonRule);
     MFSetup();
     Debug.Log("[Numeric Rule Test Result] = " + testRule.numericRule(TestLingVars));
 }