Module: Amb::ClassMethods
- Defined in:
- lib/amb/amb.rb
Instance Method Summary collapse
-
#solve(failure_message = "No solution.") ⇒ Object
Class convenience method to search for the first solution to the constraints.
-
#solve_all(failure_message = "No more solutions.") ⇒ Object
Class convenience method to search for all the solutions to the constraints.
Instance Method Details
#solve(failure_message = "No solution.") ⇒ Object
Class convenience method to search for the first solution to the constraints.
152 153 154 155 156 157 158 159 |
# File 'lib/amb/amb.rb', line 152 def solve( = "No solution.") amb = self.new yield(amb) rescue Amb::ExhaustedError => ex puts puts "#{amb.branches_count} branches explored." if $DEBUG amb.report() end |
#solve_all(failure_message = "No more solutions.") ⇒ Object
Class convenience method to search for all the solutions to the constraints.
164 165 166 167 168 169 170 171 172 |
# File 'lib/amb/amb.rb', line 164 def solve_all( = "No more solutions.") amb = self.new yield(amb) amb.failure rescue Amb::ExhaustedError => ex puts puts "#{amb.branches_count} branches explored." if $DEBUG amb.report() end |