14 #ifndef OR_TOOLS_SAT_LINEAR_CONSTRAINT_MANAGER_H_ 15 #define OR_TOOLS_SAT_LINEAR_CONSTRAINT_MANAGER_H_ 21 #include "absl/container/flat_hash_map.h" 22 #include "absl/container/flat_hash_set.h" 90 std::string extra_info =
"");
118 return constraint_infos_;
124 return lp_constraints_;
129 return num_shortened_constraints_;
162 void ComputeObjectiveParallelism(
const ConstraintIndex ct_index);
167 void RescaleActiveCounts(
double scaling_factor);
171 void PermanentlyRemoveSomeConstraints();
177 bool current_lp_is_changed_ =
false;
180 int64_t last_simplification_timestamp_ = 0;
185 std::vector<ConstraintIndex> lp_constraints_;
192 absl::flat_hash_map<size_t, ConstraintIndex> equiv_constraints_;
194 int64_t num_simplifications_ = 0;
195 int64_t num_merged_constraints_ = 0;
196 int64_t num_shortened_constraints_ = 0;
197 int64_t num_splitted_constraints_ = 0;
198 int64_t num_coeff_strenghtening_ = 0;
200 int64_t num_cuts_ = 0;
201 int64_t num_add_cut_calls_ = 0;
202 std::map<std::string, int> type_to_num_cuts_;
204 bool objective_is_defined_ =
false;
205 bool objective_norm_computed_ =
false;
206 double objective_l2_norm_ = 0.0;
215 double sum_of_squared_objective_coeffs_ = 0.0;
216 absl::flat_hash_map<IntegerVariable, double> objective_map_;
229 double constraint_active_count_increase_ = 1.0;
231 int32_t num_deletable_constraints_ = 0;
239 template <
typename Element>
242 explicit TopN(
int n) : n_(n) {}
249 void Add(Element e,
double score) {
250 if (heap_.size() < n_) {
251 const int index = elements_.size();
252 heap_.push_back({
index, score});
253 elements_.push_back(std::move(e));
254 if (heap_.size() == n_) {
256 std::make_heap(heap_.begin(), heap_.end());
259 if (score <= heap_.front().score)
return;
260 const int index_to_replace = heap_.front().index;
261 elements_[index_to_replace] = std::move(e);
264 std::pop_heap(heap_.begin(), heap_.end());
265 heap_.back() = {index_to_replace, score};
266 std::push_heap(heap_.begin(), heap_.end());
279 const double operator<(
const HeapElement& other)
const {
280 return score > other.score;
283 std::vector<HeapElement> heap_;
284 std::vector<Element> elements_;
308 struct CutCandidate {
312 TopN<CutCandidate> cuts_;
318 #endif // OR_TOOLS_SAT_LINEAR_CONSTRAINT_MANAGER_H_ const std::vector< Element > & UnorderedElements() const
A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...
Class that owns everything related to a particular optimization model.
int64_t num_coeff_strenghtening() const
const std::vector< ConstraintIndex > & LpConstraints() const
DEFINE_INT_TYPE(ConstraintIndex, int32_t)
const absl::StrongVector< ConstraintIndex, ConstraintInfo > & AllConstraints() const
double objective_parallelism
bool objective_parallelism_computed
void SetObjectiveCoefficient(IntegerVariable var, IntegerValue coeff)
std::string Statistics() const
void TransferToManager(const absl::StrongVector< IntegerVariable, double > &lp_solution, LinearConstraintManager *manager)
void Add(Element e, double score)
bool ChangeLp(const absl::StrongVector< IntegerVariable, double > &lp_solution, glop::BasisState *solution_state)
LinearConstraintManager(Model *model)
ConstraintIndex Add(LinearConstraint ct, bool *added=nullptr)
int64_t num_shortened_constraints() const
void AddCut(LinearConstraint ct, const std::string &name, const absl::StrongVector< IntegerVariable, double > &lp_solution)
Collection of objects used to extend the Constraint Solver library.
LinearConstraint constraint
void AddAllConstraintsToLp()
bool AddCut(LinearConstraint ct, std::string type_name, const absl::StrongVector< IntegerVariable, double > &lp_solution, std::string extra_info="")
bool DebugCheckConstraint(const LinearConstraint &cut)