This commit is contained in:
Laurent Perron
2022-02-11 16:30:54 +01:00
parent fca9e871d3
commit d01f5be5a7
3 changed files with 10 additions and 6 deletions

View File

@@ -204,7 +204,10 @@ void NeighborhoodGeneratorHelper::RecomputeHelperData() {
int reduced_ct_index = 0;
for (int ct_index = 0; ct_index < constraints.size(); ++ct_index) {
// We remove the interval constraints since we should have an equivalent
// linear constraint somewhere else.
// linear constraint somewhere else. This is not the case if we have a fixed
// size optional interval variable. But it should not matter as the
// intervals are replaced by their underlying variables in the scheduling
// constrainst.
if (constraints[ct_index].constraint_case() == ConstraintProto::kInterval) {
continue;
}
@@ -295,6 +298,8 @@ void NeighborhoodGeneratorHelper::RecomputeHelperData() {
//
// TODO(user): Exploit connected component while generating fragments.
// TODO(user): Do not generate fragment not touching the objective.
if (!shared_response_->LoggingIsEnabled()) return;
std::vector<int> component_sizes;
for (const std::vector<int>& component : components_) {
component_sizes.push_back(component.size());

View File

@@ -16,10 +16,8 @@
#include <cstdint>
#include <limits>
#if !defined(__PORTABLE_PLATFORM__)
#include "ortools/base/file.h"
#include "ortools/sat/cp_model_mapping.h"
#endif // __PORTABLE_PLATFORM__
#include "absl/container/btree_map.h"
@@ -29,6 +27,7 @@
#include "ortools/base/integral_types.h"
#include "ortools/base/stl_util.h"
#include "ortools/sat/cp_model.pb.h"
#include "ortools/sat/cp_model_mapping.h"
#include "ortools/sat/cp_model_utils.h"
#include "ortools/sat/integer.h"
#include "ortools/sat/linear_programming_constraint.h"
@@ -148,13 +147,12 @@ void SharedResponseManager::LogPeriodicMessage(const std::string& prefix,
const double freq = parameters_.log_frequency_in_seconds();
if (freq <= 0.0 || last_logging_time == nullptr) return;
const absl::Time now = absl::Now();
if (now - *last_logging_time <
absl::Milliseconds(static_cast<int64_t>(freq * 1000))) {
if (now - *last_logging_time < absl::Seconds(freq)) {
return;
}
*last_logging_time = now;
absl::MutexLock mutex_lock(&mutex_);
*last_logging_time = now;
SOLVER_LOG(logger_, absl::StrFormat("#%-5s %6.2fs %s", prefix,
wall_timer_.Get(), message));
}

View File

@@ -330,6 +330,7 @@ class SharedResponseManager {
void LogMessage(const std::string& prefix, const std::string& message);
void LogPeriodicMessage(const std::string& prefix, const std::string& message,
absl::Time* last_logging_time);
bool LoggingIsEnabled() const { return logger_->LoggingIsEnabled(); }
// This is here for the few codepath that needs to modify the returned
// response directly. Note that this do not work in parallel.