small cleanups

This commit is contained in:
Laurent Perron
2023-09-28 14:27:37 +02:00
parent a3a76302c4
commit 81cd6ebd39
6 changed files with 12 additions and 17 deletions

View File

@@ -405,6 +405,7 @@ inline std::vector<absl::Span<const T>> SimpleDynamicPartition::GetParts(
starts.clear();
return result;
}
} // namespace operations_research
#endif // OR_TOOLS_ALGORITHMS_DYNAMIC_PARTITION_H_

View File

@@ -21,11 +21,12 @@
namespace operations_research {
void SetCoverModel::UpdateAllSubsetsList(SubsetIndex new_size) {
const SubsetIndex num_subsets = columns_.size();
CHECK_EQ(num_subsets, new_size);
void SetCoverModel::UpdateAllSubsetsList() {
const SubsetIndex new_size = columns_.size();
const SubsetIndex old_size(all_subsets_.size());
DCHECK_LE(old_size, new_size);
all_subsets_.resize(new_size.value());
for (SubsetIndex subset(num_subsets); subset < new_size; ++subset) {
for (SubsetIndex subset(old_size); subset < new_size; ++subset) {
all_subsets_[subset.value()] = subset;
}
}
@@ -59,7 +60,7 @@ void SetCoverModel::SetSubsetCost(int subset, Cost cost) {
columns_.resize(new_size, SparseColumn());
subset_costs_.resize(new_size, 0.0);
subset_costs_[subset_index] = cost;
UpdateAllSubsetsList(new_size);
UpdateAllSubsetsList();
row_view_is_valid_ = false; // Probably overkill, but better safe than sorry.
}
@@ -68,7 +69,7 @@ void SetCoverModel::AddElementToSubset(int element, int subset) {
const SubsetIndex new_size = std::max(columns_.size(), subset_index + 1);
subset_costs_.resize(new_size, 0.0);
columns_.resize(new_size, SparseColumn());
UpdateAllSubsetsList(new_size);
UpdateAllSubsetsList();
const ElementIndex new_element(element);
columns_[subset_index].push_back(new_element);
num_elements_ = std::max(num_elements_, new_element + 1);
@@ -138,7 +139,7 @@ bool SetCoverModel::ComputeFeasibility() const {
VLOG(1) << "Max possible coverage = "
<< *std::max_element(coverage.begin(), coverage.end());
for (SubsetIndex subset(0); subset < columns_.size(); ++subset) {
CHECK_EQ(all_subsets_[subset.value()], subset);
CHECK_EQ(all_subsets_[subset.value()], subset) << "subset = " << subset;
}
return true;
}

View File

@@ -131,7 +131,7 @@ class SetCoverModel {
private:
// Updates the all_subsets_ vector so that it always contains 0 to
// columns.size() - 1
void UpdateAllSubsetsList(SubsetIndex new_size);
void UpdateAllSubsetsList();
// Number of elements.
ElementIndex num_elements_;

View File

@@ -39,7 +39,6 @@
#include "ortools/util/fp_utils.h"
#include "ortools/util/strong_integers.h"
#include "ortools/util/time_limit.h"
// MOE:end_strip
namespace operations_research {
namespace bop {

View File

@@ -217,7 +217,7 @@ absl::StatusOr<MPSolutionResponse> SatSolveProto(
// the given GlopParameters, so we need to make sure it outlive them.
const glop::GlopParameters glop_params;
std::vector<std::unique_ptr<glop::Preprocessor>> for_postsolve;
if (!params.enumerate_all_solutions()) {
if (!params.enumerate_all_solutions() && params.mip_presolve_level() > 0) {
const glop::ProblemStatus status =
ApplyMipPresolveSteps(glop_params, mp_model, &for_postsolve, &logger);
switch (status) {

View File

@@ -1122,13 +1122,7 @@ class ScipMPCallbackContext : public MPCallbackContext {
ScipConstraintHandlerForMPCallback::ScipConstraintHandlerForMPCallback(
MPCallback* mp_callback)
: ScipConstraintHandler<EmptyStruct>(
// MOE(begin-strip):
{/*name=*/"mp_solver_constraint_handler",
/*description=*/
"A single constraint handler for all MPSolver models."}
// MOE(end-strip-and-replace): ScipConstraintHandlerDescription()
),
: ScipConstraintHandler<EmptyStruct>(ScipConstraintHandlerDescription()),
mp_callback_(mp_callback) {}
std::vector<CallbackRangeConstraint>