예제 #1
0
        public FuzzyRule(string _ruleString, FuzzySystem _fuzzySystem)
        {
            _ruleString = _ruleString.ToUpper();

            // Split premises and conclusion
            String[] rule = _ruleString.Split(new String[] { " THEN " }, StringSplitOptions.RemoveEmptyEntries);
            if (rule.Length == 2)
            {
                // Compute and add premises
                rule[0] = rule[0].Remove(0, 2); // Remove tje "IF"
                String[] prem = rule[0].Trim().Split(new String[] { " AND " }, StringSplitOptions.RemoveEmptyEntries);
                Premises = new List<FuzzyExpression>();
                foreach (String exp in prem)
                {
                    String[] res = exp.Split(new String[] { " IS " }, StringSplitOptions.RemoveEmptyEntries);
                    if (res.Length == 2)
                    {
                        FuzzyExpression fexp = new FuzzyExpression(_fuzzySystem.LinguisticVariableByName(res[0]), res[1]);
                        Premises.Add(fexp);
                    }
                }
                // Add the conclusion
                String[] conclu = rule[1].Split(new String[] { " IS " }, StringSplitOptions.RemoveEmptyEntries);
                if (conclu.Length == 2)
                {
                    Conclusion = new FuzzyExpression(_fuzzySystem.LinguisticVariableByName(conclu[0]), conclu[1]);
                }
            }
        }
예제 #2
0
 public FuzzyRule(List<FuzzyExpression> _premises, FuzzyExpression _conclusion)
 {
     Premises = _premises;
     Conclusion = _conclusion;
 }