Пример #1
0
 /// <summary>
 /// Adds a fuzzy rule to the database. 
 /// </summary>
 /// 
 /// <param name="rule">A fuzzy <see cref="Rule"/> to add to the database.</param>
 /// 
 /// <exception cref="NullReferenceException">The fuzzy rule was not initialized.</exception>
 /// <exception cref="ArgumentException">The fuzzy rule name already exists in the rulebase.</exception>
 /// 
 public void AddRule( Rule rule )
 {
     // checking for existing name
     if ( this.rules.ContainsKey( rule.Name ) )
         throw new ArgumentException( "The fuzzy rule name already exists in the rulebase." );
     
     // adding rule
     this.rules.Add( rule.Name, rule );
 }
Пример #2
0
 /// <summary>
 /// Creates a new <see cref="Rule"/> and add it to the <see cref="Rulebase"/> of the 
 /// <see cref="InferenceSystem"/>.
 /// </summary>
 /// 
 /// <param name="name">Name of the <see cref="Rule"/> to create.</param>
 /// <param name="rule">A string representing the fuzzy rule.</param>
 /// 
 /// <returns>The new <see cref="Rule"/> reference. </returns>
 /// 
 public Rule NewRule( string name, string rule )
 {
     Rule r = new Rule( database, name, rule, normOperator, conormOperator );
     this.rulebase.AddRule( r );
     return r;
 }
Пример #3
0
        /// <summary>
        /// Gets all the rules of the rulebase.
        /// </summary>
        /// 
        /// <returns>An array with all the rulebase rules.</returns>
        /// 
        public Rule[] GetRules( )
        {
            Rule[] r = new Rule[rules.Count];

            int i = 0;
            foreach ( KeyValuePair<string, Rule> kvp in rules )
                r[i++] = kvp.Value;

            return r;
        }