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"
33#include "ortools/sat/sat_parameters.pb.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_;
191 : sat_parameters_(*model->GetOrCreate<SatParameters>()),
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_;
307 void ComputeObjectiveParallelism(ConstraintIndex ct_index);
312 void RescaleActiveCounts(
double scaling_factor);
316 void PermanentlyRemoveSomeConstraints();
319 void FillDerivedFields(ConstraintInfo* info);
321 const SatParameters& sat_parameters_;
325 bool current_lp_is_changed_ =
false;
328 int64_t last_simplification_timestamp_ = 0;
333 std::vector<ConstraintIndex> lp_constraints_;
340 absl::flat_hash_map<size_t, ConstraintIndex> equiv_constraints_;
342 int64_t num_constraint_updates_ = 0;
343 int64_t num_simplifications_ = 0;
344 int64_t num_merged_constraints_ = 0;
345 int64_t num_shortened_constraints_ = 0;
346 int64_t num_split_constraints_ = 0;
347 int64_t num_coeff_strenghtening_ = 0;
349 int64_t num_cuts_ = 0;
350 int64_t num_add_cut_calls_ = 0;
351 absl::btree_map<std::string, int> type_to_num_cuts_;
353 bool objective_is_defined_ =
false;
354 bool objective_norm_computed_ =
false;
355 double objective_l2_norm_ = 0.0;
364 double sum_of_squared_objective_coeffs_ = 0.0;
365 absl::flat_hash_map<IntegerVariable, double> objective_map_;
380 double constraint_active_count_increase_ = 1.0;
382 int32_t num_deletable_constraints_ = 0;
405 struct CutCandidate {
409 TopN<CutCandidate, double> cuts_;
~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
bool ChangeLp(glop::BasisState *solution_state, int *num_new_constraints=nullptr)
int64_t num_shortened_constraints() const
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()
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