Skip to content

Commit

Permalink
Revert "Added stop_search method - closes #46"
Browse files Browse the repository at this point in the history
This reverts commit 6df118b.
  • Loading branch information
ankane committed Apr 23, 2023
1 parent 8ec7843 commit 0337641
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 15 deletions.
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
## 0.10.2 (unreleased)

- Added `stop_search` method to `CpSolverSolutionCallback`

## 0.10.1 (2023-03-20)

- Added `domain` method to `SatIntVar`
Expand Down
8 changes: 1 addition & 7 deletions ext/or-tools/constraint.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#include <google/protobuf/text_format.h>
#include <ortools/sat/cp_model.h>
#include <ortools/util/time_limit.h>

#include "ext.h"

using operations_research::Domain;
using operations_research::TimeLimit;
using operations_research::sat::BoolVar;
using operations_research::sat::Constraint;
using operations_research::sat::CpModelBuilder;
Expand Down Expand Up @@ -405,19 +403,15 @@ void init_constraint(Rice::Module& m) {
[](Object self, CpModelBuilder& model, SatParameters& parameters, Object callback) {
Model m;

std::atomic<bool> stopped(false);
m.GetOrCreate<TimeLimit>()->RegisterExternalBooleanAsLimit(&stopped);

if (!callback.is_nil()) {
// TODO figure out how to use callback with multiple cores
parameters.set_num_search_workers(1);

m.Add(NewFeasibleSolutionObserver(
[callback, &stopped](const CpSolverResponse& r) {
[callback](const CpSolverResponse& r) {
// TODO find a better way to do this
callback.call("response=", r);
callback.call("on_solution_callback");
stopped = callback.attr_get("@stopped");
})
);
}
Expand Down
4 changes: 0 additions & 4 deletions lib/or_tools/cp_solver_solution_callback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,5 @@ def value(expr)
def objective_value
@response.objective_value
end

def stop_search
@stopped = true
end
end
end

0 comments on commit 0337641

Please sign in to comment.