BOAST 0.9999 → 0.99991

Sign up to get free protection for your applications and to get access to all the features.
data/BOAST.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'BOAST'
3
- s.version = "0.9999"
3
+ s.version = "0.99991"
4
4
  s.author = "Brice Videau"
5
5
  s.email = "brice.videau@imag.fr"
6
6
  s.homepage = "https://forge.imag.fr/projects/boast/"
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
32
32
  lib/BOAST/ControlStructure.rb
33
33
  lib/BOAST/Print.rb
34
34
  lib/BOAST/State.rb
35
+ lib/BOAST/Optimization.rb
35
36
  )
36
37
  s.has_rdoc = true
37
38
  s.license = 'BSD'
data/lib/BOAST.rb CHANGED
@@ -20,4 +20,5 @@ require 'BOAST/Pragma.rb'
20
20
  require 'BOAST/CKernel.rb'
21
21
  require 'BOAST/Parens.rb'
22
22
  require 'BOAST/BOAST_OpenCL.rb'
23
+ require 'BOAST/Optimization.rb'
23
24
  require 'BOAST/Print.rb'
@@ -0,0 +1,74 @@
1
+ module BOAST
2
+
3
+ class OptimizationParameter
4
+ attr_reader :name
5
+ attr_reader :values
6
+ def initialize( name, values )
7
+ @name = name
8
+ @values = values
9
+ end
10
+ end
11
+
12
+ class BooleanParameter < OptimizationParameter
13
+ def initialize( name )
14
+ super( name, [false, true] )
15
+ end
16
+ end
17
+
18
+ OP = OptimizationParameter
19
+ BP = BooleanParameter
20
+
21
+ class GenericOptimization
22
+
23
+ attr_accessor :repeat
24
+ attr_reader :parameters
25
+
26
+
27
+ def size
28
+ return @parameters.size
29
+ end
30
+
31
+ def points
32
+ pts=[]
33
+ params2 = @parameters.dup
34
+ param = params2.shift
35
+ optim2 = GenericOptimization::new(*params2)
36
+ param.values.each{ |val|
37
+ pts.push({param.name.to_sym => val})
38
+ }
39
+ if optim2.size == 0 then
40
+ return pts
41
+ else
42
+ pts3=[]
43
+ pts.each{ |p1|
44
+ optim2.each { |p2|
45
+ pts3.push(p1.dup.update(p2))
46
+ }
47
+ }
48
+ return pts3
49
+ end
50
+ end
51
+
52
+ def each(&block)
53
+ return self.points.each(&block)
54
+ end
55
+
56
+ def each_random(&block)
57
+ return self.points.shuffle.each(&block)
58
+ end
59
+
60
+ def initialize( *parameters )
61
+ if parameters.length == 1 and parameters[0].is_a?(Hash) then
62
+ @parameters = []
63
+ parameters[0].each { |key, value|
64
+ @parameters.push( OptimizationParameter::new(key, value) )
65
+ }
66
+ else
67
+ @parameters = parameters
68
+ end
69
+ @repeat = 3
70
+ end
71
+
72
+ end
73
+
74
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BOAST
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.9999'
4
+ version: '0.99991'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -92,6 +92,7 @@ files:
92
92
  - lib/BOAST/ControlStructure.rb
93
93
  - lib/BOAST/Print.rb
94
94
  - lib/BOAST/State.rb
95
+ - lib/BOAST/Optimization.rb
95
96
  homepage: https://forge.imag.fr/projects/boast/
96
97
  licenses:
97
98
  - BSD