Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.18.2 (unreleased)

- Added `best_objective_bound` method to `CpSolver` and `CpSolverSolutionCallback`

## 0.18.1 (2026-10-02)

- Added support for breaks for routing
Expand Down
1 change: 1 addition & 0 deletions ext/or-tools/constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ void init_constraint(Rice::Module& m) {

Rice::define_class_under<CpSolverResponse>(m, "CpSolverResponse")
.define_method("objective_value", &CpSolverResponse::objective_value)
.define_method("best_objective_bound", &CpSolverResponse::best_objective_bound)
.define_method("num_conflicts", &CpSolverResponse::num_conflicts)
.define_method("num_branches", &CpSolverResponse::num_branches)
.define_method("wall_time", &CpSolverResponse::wall_time)
Expand Down
2 changes: 1 addition & 1 deletion lib/or_tools/cp_solver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module ORTools
class CpSolver
extend Forwardable

def_delegators :@response, :objective_value, :num_conflicts, :num_branches, :wall_time
def_delegators :@response, :objective_value, :best_objective_bound, :num_conflicts, :num_branches, :wall_time

def solve(model, observer = nil)
@response = _solve(model, parameters, observer)
Expand Down
4 changes: 4 additions & 0 deletions lib/or_tools/cp_solver_solution_callback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def objective_value
@response&.objective_value
end

def best_objective_bound
@response&.best_objective_bound
end

def stop_search
@stopped = true
end
Expand Down
1 change: 1 addition & 0 deletions test/constraint_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def test_optimization
y = 3
z = 5
EOS
assert_equal 35, solver.best_objective_bound
end

# https://developers.google.com/optimization/cp/cryptarithmetic
Expand Down
1 change: 1 addition & 0 deletions test/solution_printer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_objective_solution_printer
solver.parameters.enumerate_all_solutions = true
solution_printer = ORTools::ObjectiveSolutionPrinter.new
assert_nil solution_printer.objective_value
assert_nil solution_printer.best_objective_bound

stdout, _ = capture_io do
solver.solve(model, solution_printer)
Expand Down