Skip to content

Commit

Permalink
Try again
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Oct 6, 2024
1 parent df5fd62 commit eeb733e
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions ext/or-tools/constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,11 @@ void init_constraint(Rice::Module& m) {

std::atomic<bool> stopped(false);

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

m.GetOrCreate<TimeLimit>()->RegisterExternalBooleanAsLimit(&stopped);
parameters.set_num_search_workers(1);
m.Add(NewSatParameters(parameters));
m.GetOrCreate<TimeLimit>()->RegisterExternalBooleanAsLimit(&stopped);

if (!callback.is_nil()) {
m.Add(NewFeasibleSolutionObserver(
[&](const CpSolverResponse& r) {
// ensure Ruby thread
Expand All @@ -447,14 +446,7 @@ void init_constraint(Rice::Module& m) {
);
}

m.Add(NewSatParameters(parameters));
auto response = SolveCpModel(model.Build(), &m);

if (!callback.is_nil()) {
m.GetOrCreate<TimeLimit>()->RegisterExternalBooleanAsLimit(nullptr);
}

return response;
return SolveCpModel(model.Build(), &m);
})
.define_method(
"_solution_integer_value",
Expand Down

0 comments on commit eeb733e

Please sign in to comment.