Method: ORTools::CpSolver#value

Defined in:
lib/or_tools/cp_solver.rb

#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