14#ifndef OR_TOOLS_SAT_VAR_DOMINATION_H_
15#define OR_TOOLS_SAT_VAR_DOMINATION_H_
22#include "absl/types/span.h"
70 void Reset(
int num_variables);
96 absl::Span<const int64_t> coeffs);
98 absl::Span<const int> refs,
99 absl::Span<const int64_t> coeffs);
101 absl::Span<const int> refs,
102 absl::Span<const int64_t> coeffs);
126 IntegerVariable
var)
const;
133 struct IntegerVariableWithRank {
138 bool operator<(
const IntegerVariableWithRank& o)
const {
139 return rank < o.rank;
144 void RefinePartition(std::vector<int>* vars);
147 void MakeRankEqualToStartOfPart(absl::Span<IntegerVariableWithRank> span);
148 void FillTempRanks(
bool reverse_references,
149 absl::Span<const int> enforcements,
150 absl::Span<const int> refs,
151 absl::Span<const int64_t> coeffs);
155 absl::Span<const IntegerVariable> InitialDominatingCandidates(
156 IntegerVariable
var)
const;
157 void ProcessTempRanks();
158 void Initialize(absl::Span<IntegerVariableWithRank> span);
161 void FilterUsingTempRanks();
164 void CheckUsingTempRanks();
176 std::vector<IntegerVariableWithRank> tmp_ranks_;
183 std::vector<int> tmp_vars_;
184 std::unique_ptr<SimpleDynamicPartition> partition_;
189 int64_t ct_index_for_signature_ = 0;
193 int num_vars_with_negation_;
198 struct IntegerVariableSpan {
205 std::vector<IntegerVariable> shared_buffer_;
212 std::vector<IntegerVariable> buffer_;
213 std::vector<IntegerVariable> other_buffer_;
229 num_locks_.
assign(2 * num_variables, 0);
230 locking_ct_index_.
assign(2 * num_variables, -1);
239 template <
typename LinearProto>
242 const LinearProto& linear, int64_t min_activity,
243 int64_t max_activity,
int ct_index = -1);
257 return can_freely_decrease_until_[RefToIntegerVariable(ref)].value();
265 static IntegerVariable RefToIntegerVariable(
int ref) {
272 can_freely_decrease_until_;
282 int num_deleted_constraints_ = 0;
288 VarDomination* var_domination);
299 const PresolveContext&
context,
300 DualBoundStrengthening* dual_bound_strengthening);
bool Strengthen(PresolveContext *context)
void Reset(int num_variables)
int64_t CanFreelyDecreaseUntil(int ref) const
void CannotIncrease(absl::Span< const int > refs, int ct_index=-1)
void CannotDecrease(absl::Span< const int > refs, int ct_index=-1)
All constraints should be mapped to one of more call to these functions.
void CannotMove(absl::Span< const int > refs, int ct_index=-1)
int NumDeletedConstraints() const
Reset on each Strengthen() call.
void ProcessLinearConstraint(bool is_objective, const PresolveContext &context, const LinearProto &linear, int64_t min_activity, int64_t max_activity, int ct_index=-1)
Most of the logic here deals with linear constraints.
static int IntegerVariableToRef(IntegerVariable var)
absl::Span< const IntegerVariable > DominatingVariables(int ref) const
void Reset(int num_variables)
static IntegerVariable RefToIntegerVariable(int ref)
std::string DominationDebugString(IntegerVariable var) const
void CanOnlyDominateEachOther(absl::Span< const int > refs)
bool CanFreelyDecrease(int ref) const
void ActivityShouldNotIncrease(absl::Span< const int > enforcements, absl::Span< const int > refs, absl::Span< const int64_t > coeffs)
void ActivityShouldNotChange(absl::Span< const int > refs, absl::Span< const int64_t > coeffs)
void ActivityShouldNotDecrease(absl::Span< const int > enforcements, absl::Span< const int > refs, absl::Span< const int64_t > coeffs)
void assign(size_type n, const value_type &val)
GurobiMPCallbackContext * context
bool RefIsPositive(int ref)
bool ExploitDominanceRelations(const VarDomination &var_domination, PresolveContext *context)
constexpr IntegerValue kMinIntegerValue(-kMaxIntegerValue.value())
void ScanModelForDualBoundStrengthening(const PresolveContext &context, DualBoundStrengthening *dual_bound_strengthening)
Scan the model so that dual_bound_strengthening.Strenghten() works.
void ScanModelForDominanceDetection(PresolveContext &context, VarDomination *var_domination)
int NegatedRef(int ref)
Small utility functions to deal with negative variable/literal references.
bool VariableIsPositive(IntegerVariable i)
In SWIG mode, we don't want anything besides these top-level includes.