Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'gecoder'
- class ArraySum
- include Gecode::Mixin
- def initialize
- weights = [1,1,1,2,3,4,5,6,7,8,9,10]
- selected_weights_is_a set_var([], weights)
- selected_weights.sum.must == 14
- branch_on selected_weights
- end
- end
- ArraySum.new.each_solution do |solution|
- p solution.selected_weights.value.map{ |x| x }
- end
- [1, 2, 3, 8]
- [1, 2, 4, 7]
- [1, 2, 5, 6]
- [1, 3, 4, 6]
- [1, 3, 10]
- [1, 4, 9]
- [1, 5, 8]
- [1, 6, 7]
- [2, 3, 4, 5]
- [2, 3, 9]
- [2, 4, 8]
- [2, 5, 7]
- [3, 4, 7]
- [3, 5, 6]
- [4, 10]
- [5, 9]
- [6, 8]
- [1,1,1,1,1,1,1,1,1,1,1,1,1,1]
- [2,2,2,2,2,2,2]
- ... # and so on
Add Comment
Please, Sign In to add comment