14 #ifndef OR_TOOLS_SAT_LINEAR_CONSTRAINT_MANAGER_H_
15 #define OR_TOOLS_SAT_LINEAR_CONSTRAINT_MANAGER_H_
20 #include "absl/container/flat_hash_map.h"
21 #include "absl/container/flat_hash_set.h"
66 : sat_parameters_(*
model->GetOrCreate<SatParameters>()),
87 std::string extra_info =
"");
112 return constraint_infos_;
118 return lp_constraints_;
151 void ComputeObjectiveParallelism(
const ConstraintIndex ct_index);
156 void RescaleActiveCounts(
double scaling_factor);
160 void PermanentlyRemoveSomeConstraints();
162 const SatParameters& sat_parameters_;
166 bool current_lp_is_changed_ =
false;
169 int64 last_simplification_timestamp_ = 0;
174 std::vector<ConstraintIndex> lp_constraints_;
181 absl::flat_hash_map<size_t, ConstraintIndex> equiv_constraints_;
183 int64 num_simplifications_ = 0;
184 int64 num_merged_constraints_ = 0;
185 int64 num_shortened_constraints_ = 0;
186 int64 num_splitted_constraints_ = 0;
187 int64 num_coeff_strenghtening_ = 0;
190 int64 num_add_cut_calls_ = 0;
191 std::map<std::string, int> type_to_num_cuts_;
193 bool objective_is_defined_ =
false;
194 bool objective_norm_computed_ =
false;
195 double objective_l2_norm_ = 0.0;
215 double constraint_active_count_increase_ = 1.0;
217 int32 num_deletable_constraints_ = 0;
225 template <
typename Element>
228 explicit TopN(
int n) : n_(n) {}
235 void Add(Element e,
double score) {
236 if (heap_.size() < n_) {
237 const int index = elements_.size();
238 heap_.push_back({
index, score});
239 elements_.push_back(std::move(e));
240 if (heap_.size() == n_) {
242 std::make_heap(heap_.begin(), heap_.end());
245 if (score <= heap_.front().score)
return;
246 const int index_to_replace = heap_.front().index;
247 elements_[index_to_replace] = std::move(e);
250 std::pop_heap(heap_.begin(), heap_.end());
251 heap_.back() = {index_to_replace, score};
252 std::push_heap(heap_.begin(), heap_.end());
265 const double operator<(
const HeapElement& other)
const {
266 return score > other.score;
269 std::vector<HeapElement> heap_;
270 std::vector<Element> elements_;
294 struct CutCandidate {
298 TopN<CutCandidate> cuts_;
304 #endif // OR_TOOLS_SAT_LINEAR_CONSTRAINT_MANAGER_H_