public double Compute(InputValues inputs) { if (!KB.CheckIntegrity(out var outputvarname)) { throw new ArgumentException("Invalid KnowledgeBase"); } var aggregation = KB.First().Eval(inputs, Method); var rules = KB.Skip(1); foreach (var rule in rules) { var ruleSet = rule.Eval(inputs, Method); aggregation = new FuzzySet( AggregationMethod.Combine( Method.AggregationOper, aggregation.Membership, ruleSet.Membership)); } return(Defuzzification(aggregation, KB.GetVar(outputvarname).Universe)); }
public void Fire(List <Rule> rules) { Dictionary <string, List <double> > degrees = new Dictionary <string, List <double> >(); for (int i = 0; i < mValues.Count; ++i) { degrees[mValues[i]] = new List <double>(); } for (int i = 0; i < rules.Count; ++i) { Rule rule = rules[i]; Clause consequent = rule.Consequent; if (consequent.Variable == this) { double y = 1; for (int j = 0; j < rule.AntecedentCount; ++j) { Clause antecedent = rule.getAntecedent(j); FuzzySet variable = antecedent.Variable; string value = antecedent.Value; Membership ms = variable.GetMembership(value); double degree = ms.degree(variable.X); if (y > degree) { y = degree; } } degrees[consequent.Value].Add(y); } } Dictionary <string, double> consequent_degrees = getRootSumSquare(degrees); mValX = getAreaCentroid(consequent_degrees); }
internal SimplePredicate(string varName, FuzzySet fs) { this.varName = varName; this.fs = fs; }
public Clause(FuzzySet variable, String condition, String value) { mVariable = variable; mValue = value; mCondition = condition; }
public void Infer(FuzzySet output) { output.Fire(mRules); }
public void AddFuzzySet(string variable, FuzzySet set) { mVariables.Add(variable); mWorkingMemory[variable] = set; }