예제 #1
0
        public Rule[] Infer(FuzzifiedValueContainer fuzzyContainer)
        {
            Rule[] result = new Rule[m_RuleBase.RuleCount()];
            m_RuleBase.ResetFulfillmentValues();

            for (int i = 0; i < m_RuleBase.RuleCount(); i++)
            {
                Rule currentRule = m_RuleBase.GetRule(i);
                for (int j = 0; j < currentRule.ConditionCount(); j++)
                {
                    RuleCondition  currentCondition = currentRule.GetCondition(j);
                    FuzzifiedValue fuzzyVal         = null;
                    if ((fuzzyVal = fuzzyContainer.Get(currentCondition.VariableName, currentCondition.TermName)) != null)
                    {
                        currentCondition.Fulfillment = fuzzyVal.FuzzyValue;
                    }
                    else
                    {
                        LogWriter.Write("Error in rule " + i + " condition " + j);
                    }
                }
                currentRule.CalculateConclusionFulfillments();
                result[i] = currentRule;
            }
            return(result);
        }
예제 #2
0
 public void Add(FuzzifiedValue fuzzyVal)
 {
     if (m_FuzzyValContainer.ContainsKey(fuzzyVal.VariableName))
     {
         Hashtable ht = ( Hashtable )m_FuzzyValContainer[fuzzyVal.VariableName];
         if (!ht.ContainsKey(fuzzyVal.TermName))
         {
             ht.Add(fuzzyVal.TermName, fuzzyVal);
             m_FvKeys.Add(new FvKey(fuzzyVal.VariableName, fuzzyVal.TermName));
         }
     }
     else
     {
         Hashtable ht = new Hashtable();
         ht.Add(fuzzyVal.TermName, fuzzyVal);
         m_FuzzyValContainer.Add(fuzzyVal.VariableName, ht);
         m_FvKeys.Add(new FvKey(fuzzyVal.VariableName, fuzzyVal.TermName));
     }
 }
예제 #3
0
 public void Add( FuzzifiedValue fuzzyVal )
 {
     if ( m_FuzzyValContainer.ContainsKey( fuzzyVal.VariableName ) )
     {
         Hashtable ht = ( Hashtable )m_FuzzyValContainer[fuzzyVal.VariableName];
         if ( !ht.ContainsKey( fuzzyVal.TermName ) )
         {
             ht.Add( fuzzyVal.TermName, fuzzyVal );
             m_FvKeys.Add( new FvKey( fuzzyVal.VariableName, fuzzyVal.TermName ) );
         }
     }
     else
     {
         Hashtable ht = new Hashtable();
         ht.Add( fuzzyVal.TermName, fuzzyVal );
         m_FuzzyValContainer.Add( fuzzyVal.VariableName, ht );
         m_FvKeys.Add( new FvKey( fuzzyVal.VariableName, fuzzyVal.TermName ) );
     }
 }
예제 #4
0
        public FuzzifiedValueContainer Fuzzificate(LinguisticInputValue[] inputs)
        {
            FuzzifiedValueContainer result = new FuzzifiedValueContainer();

            for (int i = 0; i < inputs.Length; i++)
            {
                MfInterface[] memberFunc = GetMembershipFunctions(inputs[i].VariableName);
                if (memberFunc != null)
                {
                    for (int j = 0; j < memberFunc.Length; j++)
                    {
                        FuzzifiedValue fuzzyVal = new FuzzifiedValue(memberFunc[j].VariableName(), memberFunc[j].TermName(), memberFunc[j].FuzzifieValue(inputs[i].CrispValue));
                        result.Add(fuzzyVal);
                    }
                }
                else
                {
                    LogWriter.Write("Could not fuzzificate " + inputs[i].VariableName);
                }
            }
            return(result);
        }
예제 #5
0
        public FuzzifiedValueContainer Fuzzificate( LinguisticInputValue[] inputs )
        {
            FuzzifiedValueContainer result = new FuzzifiedValueContainer();

            for ( int i = 0; i < inputs.Length; i++ )
            {
                MfInterface[] memberFunc = GetMembershipFunctions( inputs[i].VariableName );
                if ( memberFunc != null )
                {
                    for ( int j = 0; j < memberFunc.Length; j++ )
                    {
                        FuzzifiedValue fuzzyVal = new FuzzifiedValue( memberFunc[j].VariableName(), memberFunc[j].TermName(), memberFunc[j].FuzzifieValue( inputs[i].CrispValue ) );
                        result.Add( fuzzyVal );
                    }
                }
                else
                {
                    LogWriter.Write( "Could not fuzzificate " + inputs[i].VariableName );
                }
            }
            return result;
        }