コード例 #1
0
        private GeneratedNewFact FireRule(Rule r)
        {
            LogFile.Log(" Odpalono regułę " + r.Id + ":", ExpertSystemForm.logFileName);

            Fact    C     = new Fact(r.Conclusion, r.Id);
            Literal neg_C = new Literal(C.Attribute, (TypeOfValue)Convert.ToInt32(-1 * (int)C.Value));

            if (!CFacts.Contains(C.IdRule) && !CFacts.Contains(new Fact(neg_C, -1)))
            {
                CFacts.AssertConclusion(C);
                return(GeneratedNewFact.True);
            }

            return(GeneratedNewFact.False);
        }
コード例 #2
0
        private bool RuleIsPositivelyResolved(Rule r)
        {
            foreach (Literal c in r.Conditions)
            {
                if (c.Value != TypeOfValue.Unknown)
                {
                    if (!CFacts.Contains(c))
                    {
                        return(false);
                    }
                }
                else
                {
                    Literal c_false = new Literal(c.Attribute, TypeOfValue.False);

                    if (CFacts.Contains(c.Attribute) && !CFacts.Contains(c_false))
                    {
                        return(false);
                    }
                }
            }
            LogFile.Log("Reguła " + r.Id + " jest spełniona.", ExpertSystemForm.logFileName);
            return(true);
        }