diff --git a/ortools/sat/cp_model_search.cc b/ortools/sat/cp_model_search.cc index 3ee27e31cc..a02ffb0357 100644 --- a/ortools/sat/cp_model_search.cc +++ b/ortools/sat/cp_model_search.cc @@ -294,7 +294,7 @@ SatParameters DiversifySearchParameters(const SatParameters& params, if (params.reduce_memory_usage_in_interleave_mode() && params.interleave_search()) { - // Low memory mode for interleaved search in single thread (4 workers). + // Low memory mode for interleaved search in single thread (5 workers). CHECK_LE(index, 4); if (cp_model.has_objective()) { // Reduced memory, objective. // First strategy (default). @@ -467,7 +467,6 @@ SatParameters DiversifySearchParameters(const SatParameters& params, // Use LNS for the remaining workers. new_params.set_search_branching(SatParameters::AUTOMATIC_SEARCH); new_params.set_use_lns_only(true); - // TODO(user): experiment with linearization_level = 0. *name = absl::StrFormat("lns_%i", index); return new_params; } else { // Normal memory, no objective. diff --git a/ortools/sat/linear_constraint_manager.cc b/ortools/sat/linear_constraint_manager.cc index 934e530a81..c3e48f617d 100644 --- a/ortools/sat/linear_constraint_manager.cc +++ b/ortools/sat/linear_constraint_manager.cc @@ -55,7 +55,7 @@ LinearConstraintManager::~LinearConstraintManager() { if (num_coeff_strenghtening_ > 0) { VLOG(2) << "num_coeff_strenghtening: " << num_coeff_strenghtening_; } - if (log_search_progress_ && num_cuts_ > 0) { + if (sat_parameters_.log_search_progress() && num_cuts_ > 0) { LOG(INFO) << "Total cuts added: " << num_cuts_; for (const auto& entry : type_to_num_cuts_) { LOG(INFO) << "Added " << entry.second << " cuts of type '" << entry.first diff --git a/ortools/sat/linear_constraint_manager.h b/ortools/sat/linear_constraint_manager.h index f75832566b..c392d056c5 100644 --- a/ortools/sat/linear_constraint_manager.h +++ b/ortools/sat/linear_constraint_manager.h @@ -66,8 +66,7 @@ class LinearConstraintManager { : sat_parameters_(*model->GetOrCreate()), integer_trail_(*model->GetOrCreate()), time_limit_(model->GetOrCreate()), - model_(model), - log_search_progress_(sat_parameters_.log_search_progress()) {} + model_(model) {} ~LinearConstraintManager(); // Add a new constraint to the manager. Note that we canonicalize constraints @@ -211,7 +210,6 @@ class LinearConstraintManager { double constraint_active_count_increase_ = 1.0; int32 num_deletable_constraints_ = 0; - const bool log_search_progress_; }; } // namespace sat diff --git a/ortools/sat/model.h b/ortools/sat/model.h index 941c9713c4..c2dfadb7de 100644 --- a/ortools/sat/model.h +++ b/ortools/sat/model.h @@ -39,6 +39,14 @@ class Model { public: Model() {} + ~Model() { + // The order of deletion seems to be platform dependent. + // We force a reverse order on the cleanup vector. + for (int i = cleanup_list_.size() - 1; i >= 0; --i) { + cleanup_list_[i].reset(); + } + } + /** * When there is more than one model in an application, it makes sense to * name them for debugging or logging. @@ -185,6 +193,8 @@ class Model { // Map of FastTypeId to a "singleton" of type T. #if defined(__APPLE__) + // On Mac OS X, hashing is DLL dependent. It breaks cross dll usages of the + // model APIs. This happens in SWIG wrappers. std::map singletons_; #else absl::flat_hash_map singletons_;