Class: RBF::Optimizer
- Inherits:
-
Object
- Object
- RBF::Optimizer
- Defined in:
- lib/rbf/optimizer.rb
Defined Under Namespace
Classes: Algorithm
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #algorithms ⇒ Object
-
#initialize(options = {}) ⇒ Optimizer
constructor
A new instance of Optimizer.
- #optimize(tree) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Optimizer
Returns a new instance of Optimizer.
37 38 39 |
# File 'lib/rbf/optimizer.rb', line 37 def initialize (={}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
35 36 37 |
# File 'lib/rbf/optimizer.rb', line 35 def @options end |
Class Method Details
.optimization(name, &block) ⇒ Object
31 32 33 |
# File 'lib/rbf/optimizer.rb', line 31 def self.optimization (name, &block) (@@optimizations ||= []) << [name, block] end |
Instance Method Details
#algorithms ⇒ Object
54 55 56 57 58 |
# File 'lib/rbf/optimizer.rb', line 54 def algorithms @@optimizations.map {|(name, block)| Algorithm.new(self, &block) unless [name] == false }.compact end |
#optimize(tree) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rbf/optimizer.rb', line 41 def optimize (tree) result = tree.clone begin changed = algorithms.any? {|algo| algo.optimize(result) } end while changed result end |