Class: FuzzyRule

Inherits:
Object
  • Object
show all
Defined in:
lib/fuzzy_rule.rb

Instance Method Summary collapse

Constructor Details

#initialize(arguments, result) ⇒ FuzzyRule

Returns a new instance of FuzzyRule.



2
3
4
5
# File 'lib/fuzzy_rule.rb', line 2

def initialize(arguments, result)
  @arguments = arguments
  @result = result
end

Instance Method Details

#evaluate(t_norm, implication, values) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fuzzy_rule.rb', line 7

def evaluate(t_norm, implication, values)
  if t_norm == :min
    val = argumentsValues(values).min
  elsif t_norm == :mult
    val = argumentsValues(values).inject(1) { |mult, v| mult*v}
  elsif
    raise Exception.new("Invalid t_norm")
  end
  if implication == :mamdani
    return @result.min(val)
  elsif implication == :larsen
    return @result.scale(val)
  elsif implication == :takagiSugeno
    #rule value and certainity
    return [@result.call(values), val]
  else
    raise Exception.new("Invalid type")
  end
end