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 CHANGED
Binary file
@@ -1,3 +1,7 @@
1
+ == 1.2.3 / 2007-11-22
2
+
3
+ * MamdaniImplication fixed (minimum was computed badly)
4
+
1
5
  == 1.2.2 / 2007-11-19
2
6
 
3
7
  * Bugfix: little changes in test, so now they can be run in any of the ways:
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
@@ -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
- @sum_of_diffs = {}
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
- z = []
77
- pp params
78
- for i in range do
79
- z << []
80
- for j in range do
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)).abs
84
- @sum_of_diffs[params] ||= 0
85
- @sum_of_diffs[params] += diff
86
- puts "[#{i}, #{j}] #{res} - #{i+j} = #{res - (i+j)}"
87
- z[i] << diff
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
- Gnuplot.open do |gp|
92
- Gnuplot::SPlot.new( gp ) do |plot|
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 @sum_of_diffs
128
+ # pp @ssd
@@ -56,5 +56,5 @@ require 'fuzzy_rule'
56
56
  require 'fuzzy_implication'
57
57
 
58
58
  module Fuzzyrb
59
- VERSION = "1.2.2"
59
+ VERSION = "1.2.3"
60
60
  end
@@ -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.2
7
- date: 2007-11-19 00:00:00 +01:00
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.3.0
97
+ version: 1.4.0
98
98
  version:
metadata.gz.sig CHANGED
Binary file