Ejemplo n.º 1
0
        public bool IsFact(BaseClause clause)
        {
            foreach (BaseClause fact in Facts)
            {
                if (fact.Intersect(clause) == IntersectionType.Include)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        public BaseClause Infer(string goal_rulename, ICollection <BaseClause> unproved_conditions)
        {
            BaseClause conclusion = default;

            foreach (Rule rule in Rules)
            {
                var intersect = rule.Antecedents.All(t => FactsEngine.IsFact(t));

                if (intersect)
                {
                    conclusion = rule.Consequent;
                }
            }

            return(conclusion);
        }
Ejemplo n.º 3
0
 public virtual IntersectionType Intersect(BaseClause clause)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 4
0
        public override IntersectionType Intersect(BaseClause clause)
        {
            //Then check numeric type
            if (double.TryParse(Value, out double currentClauseValue) && double.TryParse(clause.Value, out double innerClauseValue))
            {
                if (clause.Condition == ConditionType.Less)
                {
                    if (currentClauseValue >= innerClauseValue)
                    {
                        return(IntersectionType.MutuallyExclude);
                    }
                    else
                    {
                        return(IntersectionType.None);
                    }
                }

                if (clause.Condition == ConditionType.LessOrEqual)
                {
                    if (currentClauseValue >= innerClauseValue)
                    {
                        return(IntersectionType.MutuallyExclude);
                    }
                    else
                    {
                        return(IntersectionType.None);
                    }
                }

                if (clause.Condition == ConditionType.Equal)
                {
                    if (currentClauseValue <= innerClauseValue)
                    {
                        return(IntersectionType.Include);
                    }
                    else
                    {
                        return(IntersectionType.MutuallyExclude);
                    }
                }


                if (clause.Condition == ConditionType.Greater)
                {
                    if (currentClauseValue <= innerClauseValue)
                    {
                        return(IntersectionType.Include);
                    }
                    else
                    {
                        return(IntersectionType.None);
                    }
                }

                if (clause.Condition == ConditionType.GreaterOrEqual)
                {
                    if (currentClauseValue <= innerClauseValue)
                    {
                        return(IntersectionType.Include);
                    }
                    else
                    {
                        return(IntersectionType.None);
                    }
                }
            }

            return(IntersectionType.None);
        }
Ejemplo n.º 5
0
 public void AddAntecedents(BaseClause clause)
 {
     (Antecedents as Collection <BaseClause>).Add(clause);
 }
Ejemplo n.º 6
0
 public void AddFact(BaseClause baseClause)
 {
     FactsEngine.Facts.Add(baseClause);
 }