14#ifndef ORTOOLS_SET_COVER_SET_COVER_INVARIANT_H_
15#define ORTOOLS_SET_COVER_SET_COVER_INVARIANT_H_
20#include "absl/log/check.h"
21#include "absl/types/span.h"
34 static_assert(
sizeof(
subset) ==
sizeof(decision_));
35 DCHECK_GE(
subset.value(), 0);
40 return SubsetIndex(decision_ >= 0 ? decision_ : ~decision_);
43 bool decision()
const {
return decision_ >= 0; }
107 lower_bound_ = lower_bound;
119 return is_cost_consistent_ ? cost_ : lower_bound_;
138 return num_free_elements_;
144 return num_non_overcovered_elements_;
152 absl::Span<const SubsetIndex> focus)
const;
159 const std::vector<SetCoverDecision>&
trace()
const {
return trace_; }
168 const SubsetIndex subset =
trace()[i].subset();
169 DCHECK_EQ(
trace()[i].decision(), is_selected_[subset]);
170 if (is_selected_[subset]) {
179 newly_removable_subsets_.clear();
180 newly_non_removable_subsets_.clear();
185 return newly_removable_subsets_;
190 return newly_non_removable_subsets_;
252 std::tuple<Cost, ElementToIntVector> ComputeCostAndCoverage(
287 bool is_cost_consistent_;
303 std::vector<SetCoverDecision> trace_;
328 std::vector<SubsetIndex> newly_removable_subsets_;
332 std::vector<SubsetIndex> newly_non_removable_subsets_;
SetCoverDecision(SubsetIndex subset, bool value)
SubsetIndex subset() const
const SetCoverModel * const_model() const
bool ComputeIsRedundant(SubsetIndex subset) const
void Recompute(ConsistencyLevel target_consistency)
const SubsetBoolVector & is_redundant() const
BaseInt ComputeCardinality() const
const SubsetToIntVector & num_free_elements() const
SetCoverSolutionResponse ExportSolutionAsProto() const
const std::vector< SetCoverDecision > & trace() const
bool CheckConsistency(ConsistencyLevel consistency) const
void LoadSolution(const SubsetBoolVector &solution)
void ImportSolutionFromProto(const SetCoverSolutionResponse &message)
bool Deselect(SubsetIndex subset, ConsistencyLevel consistency)
SetCoverInvariant(SetCoverModel *m)
const SubsetToIntVector & num_coverage_le_1_elements() const
const SubsetBoolVector & is_selected() const
SetCoverModel * model() const
Cost CostOrLowerBound() const
void ReportLowerBound(Cost lower_bound, bool is_cost_consistent)
const std::vector< SubsetIndex > & newly_removable_subsets() const
bool Select(SubsetIndex subset, ConsistencyLevel consistency)
const ElementToIntVector & coverage() const
BaseInt ComputeNumFreeElements(SubsetIndex subset) const
void LoadTraceAndCoverage(const std::vector< SetCoverDecision > &trace, const ElementToIntVector &coverage)
bool is_cost_consistent() const
ElementToIntVector ComputeCoverageInFocus(absl::Span< const SubsetIndex > focus) const
void ClearRemovabilityInformation()
BaseInt num_uncovered_elements() const
const std::vector< SubsetIndex > & newly_non_removable_subsets() const
Select next search node to expand Select next item_i to add this new search node to the search Generate a new search node where item_i is not in the knapsack Check validity of this new partial solution(using propagators) - If valid
util_intops::StrongVector< SubsetIndex, BaseInt > SubsetToIntVector
util_intops::StrongVector< ElementIndex, BaseInt > ElementToIntVector
util_intops::StrongVector< SubsetIndex, bool > SubsetBoolVector
num_free_elements_[subset]