Class: AnswerFactory::Machines::SelectNondominated
- Defined in:
- lib/machines/select_nondominated.rb
Instance Attribute Summary
Attributes inherited from Machine
Instance Method Summary collapse
- #screen(batch, overriden_options = {}) ⇒ Object (also: #generate)
Methods inherited from Machine
Constructor Details
This class inherits a constructor from AnswerFactory::Machines::Machine
Instance Method Details
#screen(batch, overriden_options = {}) ⇒ Object Also known as: generate
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/machines/select_nondominated.rb', line 9 def screen(batch, ={}) raise ArgumentError, "SelectNondominated#screen cannot process class #{batch.class}" unless batch.kind_of?(Batch) = @options.merge() criteria = [:comparison_criteria] result = Batch.new batch.each do |a| if criteria.nil? winner = batch.inject(true) {|anded, b| anded && (!a.dominated_by?(b))} else winner = batch.inject(true) {|anded, b| anded && (!a.dominated_by?(b, criteria))} end result << a if winner end return result end |