fuzzyrb 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +4 -0
- data/Rakefile +6 -0
- data/examples/compare_models.rb +38 -25
- data/lib/fuzzy.rb +1 -1
- data/lib/fuzzy_set.rb +1 -1
- metadata +3 -3
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -27,4 +27,10 @@ task :default => ["hoe:test"] do
|
|
27
27
|
puts "Use rake -T to see avalaible options."
|
28
28
|
end
|
29
29
|
|
30
|
+
task :stats do
|
31
|
+
require 'rubygems'
|
32
|
+
gem 'rails'
|
33
|
+
require 'code_statistics'
|
34
|
+
CodeStatistics.new(["Code", "lib/"], ["Unit tests", "test/"]).to_s
|
35
|
+
end
|
30
36
|
# vim: syntax=Ruby
|
data/examples/compare_models.rb
CHANGED
@@ -39,6 +39,8 @@
|
|
39
39
|
#
|
40
40
|
# Without uncomenting this line 3dplot seems not to work.
|
41
41
|
|
42
|
+
# TODO: Problem with Mamdani, t_norm = mult, defuzz = firstMaximum
|
43
|
+
|
42
44
|
$:.unshift(File.dirname(__FILE__) + "/../lib/")
|
43
45
|
require 'fuzzy'
|
44
46
|
include Fuzzyrb
|
@@ -68,42 +70,53 @@ rescue LoadError
|
|
68
70
|
@makePlot = false
|
69
71
|
STDERR.puts "If you want to see graphical output you have to install gnuplot from Rubyforge!"
|
70
72
|
end
|
71
|
-
@
|
73
|
+
@ssd = {}
|
74
|
+
|
75
|
+
def plot(x, y, z, title)
|
76
|
+
Gnuplot.open do |gp|
|
77
|
+
Gnuplot::SPlot.new( gp ) do |plot|
|
78
|
+
plot.title title
|
79
|
+
plot.xlabel "a"
|
80
|
+
plot.ylabel "b"
|
81
|
+
plot.set("ticslevel", "0.8")
|
82
|
+
plot.set("isosample", "40,40")
|
83
|
+
|
84
|
+
plot.data << Gnuplot::DataSet.new( [x, y, z] ) do |ds|
|
85
|
+
ds.with = "pm3d"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
72
91
|
def count_error(implication, params)
|
73
92
|
range = 0..10
|
74
93
|
x = range.collect {|v| v.to_f}
|
75
94
|
y = x
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
95
|
+
systems = []
|
96
|
+
diffs = []
|
97
|
+
# pp params
|
98
|
+
for i in x do
|
99
|
+
systems << []
|
100
|
+
diffs << []
|
101
|
+
for j in y do
|
81
102
|
# print " T_Norm: #{t_norm}, implication: #{imp_type}, deffuzification: #{def_type}, difference: "
|
82
103
|
res = implication.evaluate([i, j],params)
|
83
|
-
diff = (res - (i+j))
|
84
|
-
@
|
85
|
-
@
|
86
|
-
puts "[#{i}, #{j}] #{res} - #{i+j} = #{res - (i+j)}"
|
87
|
-
|
104
|
+
diff = (res - (i+j))
|
105
|
+
@ssd[params] ||= 0
|
106
|
+
@ssd[params] += diff * diff
|
107
|
+
# puts "[#{i}, #{j}] #{res} - #{i+j} = #{res - (i+j)}"
|
108
|
+
diffs[i] << diff
|
109
|
+
systems[i] << res
|
88
110
|
end
|
89
111
|
end
|
90
112
|
if @makePlot
|
91
|
-
|
92
|
-
|
93
|
-
plot.title "#{params.inspect}"
|
94
|
-
plot.xlabel "a"
|
95
|
-
plot.ylabel "b"
|
96
|
-
plot.set("ticslevel", "0.8")
|
97
|
-
plot.set("isosample", "40,40")
|
98
|
-
|
99
|
-
plot.data << Gnuplot::DataSet.new( [x, y, z] ) do |ds|
|
100
|
-
ds.with = "pm3d"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
113
|
+
plot(x, y, diffs, "ROZNICE #{params.inspect} #{@ssd[params] / (range.last-range.first + 1)**2 }")
|
114
|
+
plot(x, y, systems, "SYSTEM #{params.inspect}")
|
104
115
|
end
|
105
116
|
end
|
106
117
|
|
118
|
+
# count_error(@ms, :t_norm => :mult, :implication => :mamdani, :defuzzification => :firstMaximum)
|
119
|
+
# exit
|
107
120
|
[:min, :mult].each do |t_norm|
|
108
121
|
count_error(@tss, :t_norm => t_norm, :implication => :takegiSugeno)
|
109
122
|
[:mamdani, :larsen].each do |imp_type|
|
@@ -112,4 +125,4 @@ end
|
|
112
125
|
end
|
113
126
|
end
|
114
127
|
end
|
115
|
-
pp @
|
128
|
+
# pp @ssd
|
data/lib/fuzzy.rb
CHANGED
data/lib/fuzzy_set.rb
CHANGED
@@ -25,7 +25,7 @@ module Fuzzyrb
|
|
25
25
|
|
26
26
|
def min(value)
|
27
27
|
line = Line.new(Point.new(0, value), Point.new(1, value))
|
28
|
-
points = [@points, intersections(line)].flatten.uniq_values.sort
|
28
|
+
points = [@points, intersections(line)].flatten.uniq_values.sort.map { |p| Point.new(p.x, [p.y, value].min)}
|
29
29
|
# reject all points that has higher membership than this fuzzy set
|
30
30
|
res = points.reject { |p| self[p.x] - EPSILON > value }
|
31
31
|
FuzzySet.new(res)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: fuzzyrb
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.2.
|
7
|
-
date:
|
6
|
+
version: 1.2.3
|
7
|
+
date: 2008-01-22 00:00:00 +01:00
|
8
8
|
summary: Fuzzy Sets for Ruby
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -94,5 +94,5 @@ dependencies:
|
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 1.
|
97
|
+
version: 1.4.0
|
98
98
|
version:
|
metadata.gz.sig
CHANGED
Binary file
|