Module: Norm

Included in:
Adherence, Function, FuzzyVariable
Defined in:
lib/rfuzzy/norm.rb

Overview

Module with t-norms and s-norms

Constant Summary collapse

NORM_METHODS =
{
	:maxmin => {:t => :t_norm_max_min, :s => :s_norm_max_min},
	:prob => {:t => :t_norm_prob, :s => :s_norm_prob}
}
@@norm_method =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.norm_method(m) ⇒ Object

Sets the method for norms. Valid methods are keys in NORM_METHODS



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rfuzzy/norm.rb', line 11

def Norm.norm_method(m)
	if NORM_METHODS.has_key?(m)
		@@norm_method = m
	else
		sm = ""
		NORM_METHODS.each_key do |k|
			sm << "#{k} "
		end
		raise ArgumentError, "method #{m} is not supported for t-norms and s-norms\nSupported methods: #{sm}"
	end
end

Instance Method Details

#s_norm_max_min(x, y) ⇒ Object

Max/min s-norm



29
30
31
# File 'lib/rfuzzy/norm.rb', line 29

def s_norm_max_min(x,y)
	return [x,y].max
end

#s_norm_prob(x, y) ⇒ Object

Probablistic s-norm



39
40
41
# File 'lib/rfuzzy/norm.rb', line 39

def s_norm_prob(x,y)
	return x+y-x*y
end

#t_norm_max_min(x, y) ⇒ Object

Max/min t-norm



24
25
26
# File 'lib/rfuzzy/norm.rb', line 24

def t_norm_max_min(x,y)
	return [x,y].min
end

#t_norm_prob(x, y) ⇒ Object

Probablistic t-norm



34
35
36
# File 'lib/rfuzzy/norm.rb', line 34

def t_norm_prob(x,y)
	return x*y
end