14#ifndef OR_TOOLS_SAT_LINEAR_CONSTRAINT_MANAGER_H_
15#define OR_TOOLS_SAT_LINEAR_CONSTRAINT_MANAGER_H_
22#include "absl/container/btree_map.h"
23#include "absl/container/flat_hash_map.h"
24#include "absl/strings/string_view.h"
25#include "absl/types/span.h"
98 absl::Span<const IntegerVariable> orbit);
107 absl::Span<const IntegerVariable>
Orbit(
int i)
const {
return orbits_[
i]; }
133 bool has_symmetry_ =
false;
134 int64_t num_overflows_ = 0;
141 std::vector<IntegerVariable> orbit_sum_vars_;
193 time_limit_(model->GetOrCreate<
TimeLimit>()),
207 bool* folded =
nullptr);
215 std::string extra_info =
"");
238 int* num_new_constraints =
nullptr);
247 return constraint_infos_;
253 return lp_constraints_;
258 return expanded_lp_solution_;
261 return expanded_reduced_costs_;
270 return num_shortened_constraints_;
278 return type_to_num_cuts_;
293 const auto it = reduced_costs_map_.find(l);
294 if (it == reduced_costs_map_.end())
return 0;
295 return absl::int128(it->second.value());
301 reduced_costs_gap_ = 0;
302 reduced_costs_map_.clear();
306 reduced_costs_map_[l] = coeff;
330 void ComputeObjectiveParallelism(ConstraintIndex ct_index);
335 void RescaleActiveCounts(
double scaling_factor);
339 void PermanentlyRemoveSomeConstraints();
342 void FillDerivedFields(ConstraintInfo* info);
348 bool current_lp_is_changed_ =
false;
351 int64_t last_simplification_timestamp_ = 0;
356 std::vector<ConstraintIndex> lp_constraints_;
363 absl::flat_hash_map<size_t, ConstraintIndex> equiv_constraints_;
366 absl::int128 reduced_costs_gap_ = 0;
367 absl::flat_hash_map<Literal, IntegerValue> reduced_costs_map_;
369 int64_t num_constraint_updates_ = 0;
370 int64_t num_simplifications_ = 0;
371 int64_t num_merged_constraints_ = 0;
372 int64_t num_shortened_constraints_ = 0;
373 int64_t num_split_constraints_ = 0;
374 int64_t num_coeff_strenghtening_ = 0;
376 int64_t num_cuts_ = 0;
377 int64_t num_add_cut_calls_ = 0;
378 absl::btree_map<std::string, int> type_to_num_cuts_;
380 bool objective_is_defined_ =
false;
381 bool objective_norm_computed_ =
false;
382 double objective_l2_norm_ = 0.0;
391 double sum_of_squared_objective_coeffs_ = 0.0;
392 absl::flat_hash_map<IntegerVariable, double> objective_map_;
407 double constraint_active_count_increase_ = 1.0;
409 int32_t num_deletable_constraints_ = 0;
432 struct CutCandidate {
436 TopN<CutCandidate, double> cuts_;
absl::int128 ReducedCostsGap() const
~LinearConstraintManager()
LinearConstraintManager(Model *model)
int64_t num_coeff_strenghtening() const
ConstraintIndex Add(LinearConstraint ct, bool *added=nullptr, bool *folded=nullptr)
int64_t num_constraint_updates() const
int64_t num_constraints() const
Stats.
const std::vector< ConstraintIndex > & LpConstraints() const
absl::int128 GetLiteralReducedCost(Literal l) const
bool ChangeLp(glop::BasisState *solution_state, int *num_new_constraints=nullptr)
void SetLiteralReducedCost(Literal l, IntegerValue coeff)
int64_t num_shortened_constraints() const
void ClearReducedCostsInfo()
int64_t num_add_cut_calls() const
bool AddCut(LinearConstraint ct, std::string type_name, std::string extra_info="")
int64_t num_split_constraints() const
bool UpdateConstraintUb(glop::RowIndex index_in_lp, IntegerValue new_ub)
int64_t num_merged_constraints() const
bool DebugCheckConstraint(const LinearConstraint &cut)
bool UpdateConstraintLb(glop::RowIndex index_in_lp, IntegerValue new_lb)
These must be level zero bounds.
const util_intops::StrongVector< ConstraintIndex, ConstraintInfo > & AllConstraints() const
All the constraints managed by this class.
void AddAllConstraintsToLp()
const absl::btree_map< std::string, int > & type_to_num_cuts() const
const util_intops::StrongVector< IntegerVariable, double > & ReducedCosts()
void SetReducedCostsGap(absl::int128 gap)
const util_intops::StrongVector< IntegerVariable, double > & LpValues()
To simplify CutGenerator api.
DEFINE_STRONG_INDEX_TYPE(ConstraintIndex)
void SetObjectiveCoefficient(IntegerVariable var, IntegerValue coeff)
int64_t num_simplifications() const
int NumOrbits() const
Accessors by orbit index in [0, num_orbits).
LinearConstraintSymmetrizer(Model *model)
IntegerVariable OrbitSumVar(int i) const
bool FoldLinearConstraint(LinearConstraint *ct, bool *folded=nullptr)
int OrbitIndex(IntegerVariable var) const
void AddSymmetryOrbit(IntegerVariable sum_var, absl::Span< const IntegerVariable > orbit)
~LinearConstraintSymmetrizer()
absl::Span< const IntegerVariable > Orbit(int i) const
bool IsOrbitSumVar(IntegerVariable var) const
Returns true iff var is one of the sum_var passed to AddSymmetryOrbit().
bool AppearInFoldedProblem(IntegerVariable var) const
Simple class to add statistics by name and print them at the end.
void TransferToManager(LinearConstraintManager *manager)
Empty the local pool and add all its content to the manager.
void AddCut(LinearConstraint ct, absl::string_view name, const util_intops::StrongVector< IntegerVariable, double > &lp_solution)
Adds a cut to the local pool.
In SWIG mode, we don't want anything besides these top-level includes.
double objective_parallelism
LinearConstraint constraint
bool objective_parallelism_computed
ModelLpVariableMapping()=default
Same as ModelLpValues for reduced costs.
ModelReducedCosts()=default