diff --git a/ortools/sat/synchronization.cc b/ortools/sat/synchronization.cc index bdfdad7759..c89241de66 100644 --- a/ortools/sat/synchronization.cc +++ b/ortools/sat/synchronization.cc @@ -393,6 +393,7 @@ void SharedResponseManager::Synchronize() { IntegerValue(inner_objective_lower_bound_); synchronized_inner_objective_upper_bound_ = IntegerValue(inner_objective_upper_bound_); + synchronized_best_status_ = best_status_; } IntegerValue SharedResponseManager::SynchronizedInnerObjectiveLowerBound() { @@ -693,8 +694,8 @@ void SharedResponseManager::NewSolution( bool SharedResponseManager::ProblemIsSolved() const { absl::MutexLock mutex_lock(&mutex_); - return best_status_ == CpSolverStatus::OPTIMAL || - best_status_ == CpSolverStatus::INFEASIBLE; + return synchronized_best_status_ == CpSolverStatus::OPTIMAL || + synchronized_best_status_ == CpSolverStatus::INFEASIBLE; } std::string ExtractSubSolverName(const std::string& improvement_info) { diff --git a/ortools/sat/synchronization.h b/ortools/sat/synchronization.h index a97fbe5216..07574f0e60 100644 --- a/ortools/sat/synchronization.h +++ b/ortools/sat/synchronization.h @@ -368,6 +368,8 @@ class SharedResponseManager { double relative_gap_limit_ ABSL_GUARDED_BY(mutex_) = 0.0; CpSolverStatus best_status_ ABSL_GUARDED_BY(mutex_) = CpSolverStatus::UNKNOWN; + CpSolverStatus synchronized_best_status_ ABSL_GUARDED_BY(mutex_) = + CpSolverStatus::UNKNOWN; std::vector unsat_cores_ ABSL_GUARDED_BY(mutex_); SharedSolutionRepository solutions_ ABSL_GUARDED_BY(mutex_);