Module: Pikk
- Defined in:
- lib/pikk.rb,
lib/pikk/main.rb,
lib/pikk/version.rb
Constant Summary collapse
Class Method Summary collapse
Class Method Details
.pool(list = [{}], iteration: 50, pp: false) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pikk/main.rb', line 14 def pool(list = [{}], iteration: 50, pp: false) raise ArgumentError, 'Input is empty!' if list == [{}] $iteration = iteration arr = calculate_prob(list) $iteration.times do selected_object = pick_from(arr) selected_object[:count] += 1 end pp ? to_table(arr) : arr.sort_by { |h| h[:weight] }.reverse end |
.single_select(list = [{}]) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/pikk/main.rb', line 5 def single_select(list = [{}]) raise ArgumentError, 'Input is empty!' if list == [{}] arr = calculate_prob(list) selected_object = pick_from(arr) return selected_object end |