Class: ORTools::CpSolver
- Inherits:
-
Object
- Object
- ORTools::CpSolver
- Extended by:
- Forwardable
- Defined in:
- lib/or_tools/cp_solver.rb
Instance Method Summary collapse
- #parameters ⇒ Object
- #search_for_all_solutions(model, observer) ⇒ Object
- #solution_info ⇒ Object
- #solve(model, observer = nil) ⇒ Object
- #solve_with_solution_callback(model, observer) ⇒ Object
- #sufficient_assumptions_for_infeasibility ⇒ Object
- #value(var) ⇒ Object
Instance Method Details
#parameters ⇒ Object
52 53 54 |
# File 'lib/or_tools/cp_solver.rb', line 52 def parameters @parameters ||= SatParameters.new end |
#search_for_all_solutions(model, observer) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/or_tools/cp_solver.rb', line 33 def search_for_all_solutions(model, observer) warn "[or-tools] search_for_all_solutions is deprecated; use solve() with solver.parameters.enumerate_all_solutions = true" previous_value = parameters.enumerate_all_solutions begin parameters.enumerate_all_solutions = true solve(model, observer) ensure parameters.enumerate_all_solutions = previous_value end end |
#solution_info ⇒ Object
44 45 46 |
# File 'lib/or_tools/cp_solver.rb', line 44 def solution_info @response.solution_info end |
#solve(model, observer = nil) ⇒ Object
9 10 11 12 |
# File 'lib/or_tools/cp_solver.rb', line 9 def solve(model, observer = nil) @response = _solve(model, parameters, observer) @response.status end |
#solve_with_solution_callback(model, observer) ⇒ Object
28 29 30 31 |
# File 'lib/or_tools/cp_solver.rb', line 28 def solve_with_solution_callback(model, observer) warn "[or-tools] solve_with_solution_callback is deprecated; use solve(model, callback)" solve(model, observer) end |
#sufficient_assumptions_for_infeasibility ⇒ Object
48 49 50 |
# File 'lib/or_tools/cp_solver.rb', line 48 def sufficient_assumptions_for_infeasibility @response.sufficient_assumptions_for_infeasibility end |
#value(var) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/or_tools/cp_solver.rb', line 14 def value(var) # could also check solution_size == 0 unless [:feasible, :optimal].include?(@response.status) # could return nil, but raise error like Python library raise Error, "No solution found" end if var.is_a?(BoolVar) _solution_boolean_value(@response, var) else _solution_integer_value(@response, var) end end |