14#ifndef OR_TOOLS_SAT_CUTS_H_
15#define OR_TOOLS_SAT_CUTS_H_
43 std::vector<IntegerVariable>
vars;
63 : lp_vars_(lp_vars_.begin(), lp_vars_.end()),
64 integer_trail_(integer_trail),
65 implied_bounds_(implied_bounds) {}
89 std::vector<std::pair<IntegerVariable, IntegerValue>>
terms;
93 IntegerValue
lb = IntegerValue(0);
94 IntegerValue
ub = IntegerValue(0);
98 bool substitute_only_inner_variables, IntegerVariable first_slack,
109 const std::vector<SlackInfo>& info);
131 BestImpliedBoundInfo ComputeBestImpliedBound(
135 absl::flat_hash_set<IntegerVariable> lp_vars_;
136 mutable absl::flat_hash_map<IntegerVariable, BestImpliedBoundInfo> cache_;
145 mutable std::vector<std::pair<IntegerVariable, IntegerValue>> tmp_terms_;
177IntegerValue
GetFactorT(IntegerValue rhs_remainder, IntegerValue divisor,
180 IntegerValue rhs_remainder, IntegerValue divisor, IntegerValue t,
181 IntegerValue max_scaling);
228 std::vector<int> relevant_indices_;
229 std::vector<double> relevant_lp_values_;
230 std::vector<IntegerValue> relevant_coeffs_;
231 std::vector<IntegerValue> relevant_bound_diffs_;
232 std::vector<IntegerValue> divisors_;
233 std::vector<std::pair<int, IntegerValue>> adjusted_coeffs_;
234 std::vector<IntegerValue> remainders_;
235 std::vector<bool> change_sign_at_postprocessing_;
236 std::vector<IntegerValue> rs_;
237 std::vector<IntegerValue> best_rs_;
239 int num_lifted_booleans_ = 0;
240 std::vector<std::pair<IntegerVariable, IntegerValue>> tmp_terms_;
249 const std::vector<double>& lp_values,
258 const std::string
Info() {
return absl::StrCat(
"lift=", num_lifting_); }
263 double dist_to_max_value;
264 IntegerValue positive_coeff;
267 std::vector<Term> terms_;
268 std::vector<bool> in_cut_;
270 LinearConstraint cut_;
279 const LinearConstraint& constraint,
281 const IntegerTrail& integer_trail);
287 const IntegerTrail& integer_trail);
303 const LinearConstraint& preprocessed_constraint,
305 const IntegerTrail& integer_trail);
324 const LinearConstraint& constraint,
326 const IntegerTrail& integer_trail);
332 const LinearConstraint& preprocessed_constraint,
334 const IntegerTrail& integer_trail);
344 std::vector<LinearConstraint>* knapsack_constraints,
345 IntegerTrail* integer_trail);
357 const LinearConstraint& constraint,
359 const std::vector<IntegerValue>& cut_vars_original_coefficients,
361 LinearConstraint* cut);
414 const std::vector<LinearConstraint>& base_constraints,
415 const std::vector<IntegerVariable>& vars, Model*
model);
421 int linearization_level,
427 int linearization_level, Model*
model);
436 const std::vector<IntegerVariable>& vars, Model*
model);
476 const IntegerVariable target,
const std::vector<LinearExpression>& exprs,
477 const std::vector<IntegerVariable>& z_vars, Model*
model);
481 const LinearExpression& target, IntegerVariable
var,
482 const std::vector<std::pair<IntegerValue, IntegerValue>>& affines,
490 LinearExpression target, IntegerVariable
var,
491 std::vector<std::pair<IntegerValue, IntegerValue>> affines,
492 const std::string cut_name, Model*
model);
498 const std::vector<IntegerVariable>& base_variables, Model*
model);
A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...
const LinearConstraint & cut() const
LinearConstraint * mutable_cut()
bool TrySimpleKnapsack(const LinearConstraint base_ct, const std::vector< double > &lp_values, const std::vector< IntegerValue > &lower_bounds, const std::vector< IntegerValue > &upper_bounds)
void AddLpVariable(IntegerVariable var)
void ProcessUpperBoundedConstraintWithSlackCreation(bool substitute_only_inner_variables, IntegerVariable first_slack, const absl::StrongVector< IntegerVariable, double > &lp_values, LinearConstraint *cut, std::vector< SlackInfo > *slack_infos)
void ProcessUpperBoundedConstraint(const absl::StrongVector< IntegerVariable, double > &lp_values, LinearConstraint *cut)
bool DebugSlack(IntegerVariable first_slack, const LinearConstraint &initial_cut, const LinearConstraint &cut, const std::vector< SlackInfo > &info)
void RecomputeCacheAndSeparateSomeImpliedBoundCuts(const absl::StrongVector< IntegerVariable, double > &lp_values)
BestImpliedBoundInfo GetCachedImpliedBoundInfo(IntegerVariable var)
ImpliedBoundsProcessor(absl::Span< const IntegerVariable > lp_vars_, IntegerTrail *integer_trail, ImpliedBounds *implied_bounds)
int NumLiftedBooleans() const
void ComputeCut(RoundingOptions options, const std::vector< double > &lp_values, const std::vector< IntegerValue > &lower_bounds, const std::vector< IntegerValue > &upper_bounds, ImpliedBoundsProcessor *ib_processor, LinearConstraint *cut)
ModelSharedTimeLimit * time_limit
void ConvertToKnapsackForm(const LinearConstraint &constraint, std::vector< LinearConstraint > *knapsack_constraints, IntegerTrail *integer_trail)
CutGenerator CreateSquareCutGenerator(IntegerVariable y, IntegerVariable x, int linearization_level, Model *model)
LinearConstraint GetPreprocessedLinearConstraint(const LinearConstraint &constraint, const absl::StrongVector< IntegerVariable, double > &lp_values, const IntegerTrail &integer_trail)
bool CanFormValidKnapsackCover(const LinearConstraint &preprocessed_constraint, const absl::StrongVector< IntegerVariable, double > &lp_values, const IntegerTrail &integer_trail)
IntegerValue GetFactorT(IntegerValue rhs_remainder, IntegerValue divisor, IntegerValue max_t)
double GetKnapsackUpperBound(std::vector< KnapsackItem > items, const double capacity)
bool CanBeFilteredUsingCutLowerBound(const LinearConstraint &preprocessed_constraint, const absl::StrongVector< IntegerVariable, double > &lp_values, const IntegerTrail &integer_trail)
const IntegerVariable kNoIntegerVariable(-1)
CutGenerator CreateLinMaxCutGenerator(const IntegerVariable target, const std::vector< LinearExpression > &exprs, const std::vector< IntegerVariable > &z_vars, Model *model)
CutGenerator CreateAllDifferentCutGenerator(const std::vector< IntegerVariable > &vars, Model *model)
LinearConstraint BuildMaxAffineUpConstraint(const LinearExpression &target, IntegerVariable var, const std::vector< std::pair< IntegerValue, IntegerValue > > &affines, Model *model)
bool CanBeFilteredUsingKnapsackUpperBound(const LinearConstraint &constraint, const absl::StrongVector< IntegerVariable, double > &lp_values, const IntegerTrail &integer_trail)
std::function< IntegerValue(IntegerValue)> GetSuperAdditiveRoundingFunction(IntegerValue rhs_remainder, IntegerValue divisor, IntegerValue t, IntegerValue max_scaling)
CutGenerator CreateMaxAffineCutGenerator(LinearExpression target, IntegerVariable var, std::vector< std::pair< IntegerValue, IntegerValue > > affines, const std::string cut_name, Model *model)
CutGenerator CreateKnapsackCoverCutGenerator(const std::vector< LinearConstraint > &base_constraints, const std::vector< IntegerVariable > &vars, Model *model)
bool ConstraintIsTriviallyTrue(const LinearConstraint &constraint, const IntegerTrail &integer_trail)
bool LiftKnapsackCut(const LinearConstraint &constraint, const absl::StrongVector< IntegerVariable, double > &lp_values, const std::vector< IntegerValue > &cut_vars_original_coefficients, const IntegerTrail &integer_trail, TimeLimit *time_limit, LinearConstraint *cut)
CutGenerator CreateCliqueCutGenerator(const std::vector< IntegerVariable > &base_variables, Model *model)
CutGenerator CreatePositiveMultiplicationCutGenerator(IntegerVariable z, IntegerVariable x, IntegerVariable y, int linearization_level, Model *model)
Collection of objects used to extend the Constraint Solver library.
std::vector< double > lower_bounds
std::vector< double > upper_bounds
std::vector< IntegerVariable > vars
std::function< bool(const absl::StrongVector< IntegerVariable, double > &lp_values, LinearConstraintManager *manager)> generate_cuts
std::vector< std::pair< IntegerVariable, IntegerValue > > terms
bool operator>(const KnapsackItem &other) const