Esempio n. 1
0
        public RuleCollection ParseRules()
        {
            /** Create a list of rules */
            RuleCollection rules    = new RuleCollection();
            XmlNodeList    ruleNode = xmlDoc.GetElementsByTagName("Rule");

            foreach (XmlNode r in ruleNode)
            {
                /** Conclusion of Rule */
                XmlNode     conclusionNode = r["Conclusion"];
                string      attribute      = conclusionNode["Attribute"].InnerText;
                TypeOfValue value          = (TypeOfValue)Convert.ToInt32(conclusionNode["Value"].InnerText);

                Literal conclusion = new Literal(attribute, value);

                /** Priority of Rule */
                decimal priority = decimal.Parse(r["Priority"].InnerText);

                /** Create a list of conditions */
                LiteralCollection conditions = ParseConditions(r);

                rules.Add(new Rule(rules.Count, conditions, conclusion, priority));
            }
            return(rules);
        }
        public void CopyFrom(LiteralCollection facts)
        {
            int counter = 0;

            foreach (Fact f in facts)
            {
                if (!Contains(f as Literal))
                {
                    f.SetName = "fakt " + ++counter;
                    Add(f);
                }
            }
        }
Esempio n. 3
0
        public override object ConvertTo(ITypeDescriptorContext context,
                                         System.Globalization.CultureInfo culture, object value, Type destType)
        {
            if (destType == typeof(string))
            {
                LiteralCollection literals = (LiteralCollection)value;
                if (literals == null)
                {
                    return("-");
                }

                return(literals.Select(", "));
            }
            return(base.ConvertTo(context, culture, value, destType));
        }
Esempio n. 4
0
        public LiteralCollection ParseConditions(XmlNode ruleNode)
        {
            /** Create a list of conditions */
            LiteralCollection conditions = new LiteralCollection();

            foreach (XmlNode node in ruleNode["ConditionList"])
            {
                /** Condition of Rule */
                string      attribute = node["Attribute"].InnerText;
                TypeOfValue value     = (TypeOfValue)Convert.ToInt32(node["Value"].InnerText);

                Literal cond = new Literal(attribute, value);
                conditions.Add(cond);
            }
            return(conditions);
        }
Esempio n. 5
0
        public LiteralCollection ParseFacts()
        {
            LiteralCollection facts    = new LiteralCollection();
            XmlNodeList       factNode = xmlDoc.GetElementsByTagName("Fact");

            foreach (XmlNode f in factNode)
            {
                /** Fact */
                string      attribute = f["Attribute"].InnerText;
                TypeOfValue value     = (TypeOfValue)Convert.ToInt32(f["Value"].InnerText);

                Fact fact = new Fact(facts.Count, attribute, value);
                facts.Add(fact);
            }
            return(facts);
        }
Esempio n. 6
0
        public ForwardChaining(KnowledgeBase kb)
        {
            this.Rules  = new RuleCollection();
            this.CFacts = new LiteralCollection();
            this.FFacts = new LiteralCollection();

            foreach (Fact f in kb.Facts)
            {
                this.CFacts.Add(f);
            }
            foreach (Rule r in kb.Rules)
            {
                this.Rules.Add(r);
            }

            DetermineIdNextRules();
        }
 public NonMonotonicity(LiteralCollection facts, RuleCollection rules)
     : base(facts, rules)
 {
 }
 public Conflict(LiteralCollection facts, RuleCollection rules)
 {
     this.Facts = facts;
     this.Rules = rules;
 }
Esempio n. 9
0
 public Rebutting(LiteralCollection facts, RuleCollection rules)
     : base(facts, rules)
 {
 }
 public Undermining(LiteralCollection facts, RuleCollection rules)
     : base(facts, rules)
 {
 }
 public LiteralPropertyDescriptor(LiteralCollection coll, int idx)
     : base("warunek " + (idx + 1).ToString(), null)
 {
     this.literals = coll;
     this.index    = idx;
 }
Esempio n. 12
0
 public Attack(LiteralCollection facts, RuleCollection rules)
 {
     this.Facts = facts;
     this.Rules = rules;
 }