Class: Fuzzyrb::MamdaniImplication
- Inherits:
-
FuzzyImplication
- Object
- FuzzyImplication
- Fuzzyrb::MamdaniImplication
- Defined in:
- lib/fuzzy_implication.rb
Overview
Regular implication. Result is defuzzification of fuzzy set composed of rules’ conclusions scaled by T-norm.
Instance Method Summary collapse
-
#evaluate(values, params) ⇒ Object
Evaluates the rule.
Methods inherited from FuzzyImplication
Constructor Details
This class inherits a constructor from Fuzzyrb::FuzzyImplication
Instance Method Details
#evaluate(values, params) ⇒ Object
Evaluates the rule. Params includes FuzzyRule
params and:
-
:defuzzification
which can be:CoG
for center of gravity of:firstMaximum
for first maximum.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fuzzy_implication.rb', line 34 def evaluate(values, params) result = @rules.map { |rule| rule.evaluate(values, params) }.inject { |s, r| s + r } if params[:defuzzification] == :CoG return result.centerOfGravity elsif params[:defuzzification] == :firstMaximum return result.firstMaximum else raise Exception.new("Invalid defuzzification method") end end |