format fix
This commit is contained in:
@@ -169,6 +169,7 @@ class AdjustableKAryHeap {
|
||||
bool Contains(Index index) const {
|
||||
return GetHeapPosition(index) != kNonExistent;
|
||||
}
|
||||
|
||||
// Checks that the heap is well-formed.
|
||||
bool CheckHeapProperty() const {
|
||||
for (HeapIndex i = heap_size() - 1; i >= Arity; --i) {
|
||||
@@ -254,7 +255,6 @@ class AdjustableKAryHeap {
|
||||
std::swap(heap_positions_[index(i)], heap_positions_[index(j)]);
|
||||
}
|
||||
|
||||
|
||||
// Compares two elements based on whether we are dealing with a min- or a
|
||||
// max-heap. Returns true if (data indexed by) i has more priority
|
||||
// than j. Note that we only use operator::<.
|
||||
@@ -262,7 +262,6 @@ class AdjustableKAryHeap {
|
||||
return IsMaxHeap ? data_[j] < data_[i] : data_[i] < data_[j];
|
||||
}
|
||||
|
||||
|
||||
// Since Arity is a (small) constant, we expect compilers to avoid
|
||||
// multiplication instructions and use LEA instructions or a combination
|
||||
// of shifts and arithmetic operations.
|
||||
@@ -281,7 +280,6 @@ class AdjustableKAryHeap {
|
||||
// Gets the parent index of a given index.
|
||||
HeapIndex Parent(HeapIndex index) const { return (index - 1) / Arity; }
|
||||
|
||||
|
||||
// Returns the index of the element at position i in the heap.
|
||||
Index index(HeapIndex i) const { return data_[i].second; }
|
||||
|
||||
@@ -306,6 +304,7 @@ class AdjustableKAryHeap {
|
||||
// either when removing an element (which is not removed from data_), or
|
||||
// adding a new one.
|
||||
HeapIndex heap_size_ = 0;
|
||||
|
||||
// The index for Aggregates not in the heap.
|
||||
const Index kNonExistent = -1;
|
||||
};
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace operations_research {
|
||||
|
||||
|
||||
TEST(AdjustableKAryHeapTest, RandomDataStrongCheck) {
|
||||
const int kSize = 10'000;
|
||||
const double priority_range = kSize / 100;
|
||||
|
||||
@@ -477,16 +477,17 @@ bool GuidedLocalSearch::NextSolution(absl::Span<const SubsetIndex> focus,
|
||||
inv_->MakeFullyUpdated();
|
||||
Cost best_cost = inv_->cost();
|
||||
SubsetBoolVector best_choices = inv_->is_selected();
|
||||
|
||||
for (const SubsetIndex& subset : focus) {
|
||||
const float delta = ComputeDelta(subset);
|
||||
if (delta < kInfinity) {
|
||||
priority_heap_.Insert({delta, subset.value()});
|
||||
}
|
||||
}
|
||||
|
||||
for (int iteration = 0; iteration < num_iterations; ++iteration) {
|
||||
// Improve current solution respective to the current penalties.
|
||||
const SubsetIndex best_subset(priority_heap_.TopIndex());
|
||||
|
||||
if (inv_->is_selected()[best_subset]) {
|
||||
utility_heap_.Insert({0, best_subset.value()});
|
||||
} else {
|
||||
@@ -512,23 +513,27 @@ bool GuidedLocalSearch::NextSolution(absl::Span<const SubsetIndex> focus,
|
||||
inv_->model()->subset_costs()[subset]);
|
||||
priority_heap_.Insert({delta_selected, subset.value()});
|
||||
}
|
||||
|
||||
for (const SubsetIndex subset : {penalized_subset, best_subset}) {
|
||||
const float delta = ComputeDelta(subset);
|
||||
if (delta < kInfinity) {
|
||||
priority_heap_.Insert({delta, subset.value()});
|
||||
}
|
||||
}
|
||||
|
||||
// Get new non removable subsets.
|
||||
// (Delete them from the heap)
|
||||
for (const SubsetIndex subset : inv_->new_non_removable_subsets()) {
|
||||
priority_heap_.Remove(subset.value());
|
||||
}
|
||||
|
||||
if (inv_->cost() < best_cost) {
|
||||
best_cost = inv_->cost();
|
||||
best_choices = inv_->is_selected();
|
||||
}
|
||||
}
|
||||
inv_->LoadSolution(best_choices);
|
||||
|
||||
// Improve the solution by removing redundant subsets.
|
||||
for (const SubsetIndex& subset : focus) {
|
||||
if (inv_->is_selected()[subset] && inv_->ComputeIsRedundant(subset))
|
||||
|
||||
@@ -497,7 +497,6 @@ std::vector<SubsetIndex> ClearMostCoveredElements(std::size_t num_subsets,
|
||||
std::vector<SubsetIndex> ClearMostCoveredElements(
|
||||
absl::Span<const SubsetIndex> focus, std::size_t num_subsets,
|
||||
SetCoverInvariant* inv);
|
||||
|
||||
} // namespace operations_research
|
||||
|
||||
#endif // OR_TOOLS_ALGORITHMS_SET_COVER_HEURISTICS_H_
|
||||
|
||||
@@ -248,6 +248,7 @@ std::vector<T> ComputeDeciles(std::vector<T> values) {
|
||||
return deciles;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SetCoverModel::Stats SetCoverModel::ComputeCostStats() {
|
||||
std::vector<Cost> subset_costs(num_subsets());
|
||||
std::copy(subset_costs_.begin(), subset_costs_.end(), subset_costs.begin());
|
||||
|
||||
@@ -59,6 +59,7 @@ void LogCostAndTiming(std::string name, std::string algo, double cost,
|
||||
LOG(INFO) << ", " << name << ", " << algo << "_cost, " << cost << ", "
|
||||
<< absl::ToInt64Microseconds(duration) << "e-6, s";
|
||||
}
|
||||
|
||||
SetCoverInvariant RunChvatalAndSteepest(std::string name,
|
||||
SetCoverModel* model) {
|
||||
SetCoverInvariant inv(model);
|
||||
@@ -361,7 +362,6 @@ SCP_TEST("scpnrh5.txt", 55, 62, FEWTENTHS);
|
||||
#endif
|
||||
|
||||
#ifdef EXTRA_SCP
|
||||
|
||||
SCP_TEST("scpclr10.txt", 0, 32, FEWMILLIS);
|
||||
SCP_TEST("scpclr11.txt", 0, 30, FEWMILLIS);
|
||||
SCP_TEST("scpclr12.txt", 0, 31, FEWMILLIS);
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
#include "ortools/base/mathutil.h"
|
||||
|
||||
#include "ortools/base/logging.h"
|
||||
#include "ortools/base/mathutil.h"
|
||||
|
||||
namespace operations_research {
|
||||
|
||||
|
||||
@@ -446,7 +446,6 @@ function main() {
|
||||
expand_bootlin_config
|
||||
declare -r QEMU_ARCH=ppc64le ;;
|
||||
|
||||
|
||||
riscv64)
|
||||
expand_bootlin_config
|
||||
declare -r QEMU_ARCH=riscv64 ;;
|
||||
|
||||
Reference in New Issue
Block a user