Class: ORTools::CpSolverSolutionCallback

Inherits:
Object
  • Object
show all
Defined in:
lib/or_tools/cp_solver_solution_callback.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#response=(value) ⇒ Object (writeonly)

Sets the attribute response

Parameters:

  • value

    the value to set the attribute response to.



3
4
5
# File 'lib/or_tools/cp_solver_solution_callback.rb', line 3

def response=(value)
  @response = value
end

Instance Method Details

#objective_valueObject



16
17
18
# File 'lib/or_tools/cp_solver_solution_callback.rb', line 16

def objective_value
  @response&.objective_value
end

#value(expr) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/or_tools/cp_solver_solution_callback.rb', line 5

def value(expr)
  case expr
  when SatIntVar
    @response&.solution_integer_value(expr)
  when BoolVar
    @response&.solution_boolean_value(expr)
  else
    raise "Unsupported type: #{expr.class.name}"
  end
end