another fix for #1918

This commit is contained in:
Laurent Perron
2020-08-21 11:00:41 +02:00
parent 4518ac6b12
commit 23bc8205f5
4 changed files with 13 additions and 6 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -66,8 +66,7 @@ class LinearConstraintManager {
: sat_parameters_(*model->GetOrCreate<SatParameters>()),
integer_trail_(*model->GetOrCreate<IntegerTrail>()),
time_limit_(model->GetOrCreate<TimeLimit>()),
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

View File

@@ -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<T> 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</*typeid*/ size_t, void*> singletons_;
#else
absl::flat_hash_map</*typeid*/ size_t, void*> singletons_;