Class: Adherence
Overview
Adherence. Basically it’s a Float in range [0;1] allowing norm operations.
Constant Summary
Constants included from Norm
Instance Method Summary collapse
-
#and(other, method = :auto) ⇒ Object
Performs t-norm on itself and other.
-
#initialize(val) ⇒ Adherence
constructor
Constructor.
-
#not ⇒ Object
Performs negation.
-
#or(other, method = :auto) ⇒ Object
Performs s-norm on itself and other.
- #to_f ⇒ Object
Methods included from Norm
norm_method, #s_norm_max_min, #s_norm_prob, #t_norm_max_min, #t_norm_prob
Constructor Details
#initialize(val) ⇒ Adherence
Constructor. Usage .new(Float value)
Value must be [0;1]
8 9 10 11 12 13 |
# File 'lib/rfuzzy/adherence.rb', line 8 def initialize(val) if val < 0 || val > 1 raise ArgumentError, "Adherence must be in [0;1]" end @adh = val end |
Instance Method Details
#and(other, method = :auto) ⇒ Object
Performs t-norm on itself and other. Usage: <tt>.and(Adherence other, Symbol method) <tt>.and(Adherence other)
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rfuzzy/adherence.rb', line 22 def and(other, method = :auto) if(method == :auto) unless @@norm_method.nil? method = @@norm_method else raise ArgumentError, "Specify method, or call Norm::norm_method" end end return Adherence.new(self.method(NORM_METHODS[method][:t]).call(self.to_f, other.to_f)) end |
#not ⇒ Object
Performs negation.
48 49 50 |
# File 'lib/rfuzzy/adherence.rb', line 48 def not return Adherence.new(1 - @value) end |
#or(other, method = :auto) ⇒ Object
Performs s-norm on itself and other. Usage: <tt>.or(Adherence other, Symbol method) <tt>.or(Adherence other)
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rfuzzy/adherence.rb', line 36 def or(other, method = :auto) if(method == :auto) unless @@norm_method.nil? method = @@norm_method else raise ArgumentError, "Specify method, or call Norm::norm_method" end end return Adherence.new(self.method(NORM_METHODS[method][:s]).call(self.to_f, other.to_f)) end |
#to_f ⇒ Object
15 16 17 |
# File 'lib/rfuzzy/adherence.rb', line 15 def to_f return @adh end |