14 #ifndef OR_TOOLS_FLATZINC_PRESOLVE_H_
15 #define OR_TOOLS_FLATZINC_PRESOLVE_H_
21 #include "absl/container/flat_hash_map.h"
22 #include "absl/container/flat_hash_set.h"
23 #include "absl/strings/match.h"
51 struct AffineMapping {
58 : variable(nullptr),
coefficient(0), offset(0), constraint(nullptr) {}
59 AffineMapping(IntegerVariable* v, int64_t c, int64_t o,
Constraint*
ct)
68 struct Array2DIndexMapping {
69 IntegerVariable* variable1;
71 IntegerVariable* variable2;
73 Constraint* constraint;
80 constraint(nullptr) {}
81 Array2DIndexMapping(IntegerVariable* v1, int64_t c, IntegerVariable* v2,
82 int64_t o, Constraint*
ct)
91 void SubstituteEverywhere(Model*
model);
92 void SubstituteAnnotation(Annotation* ann);
95 void PresolveBool2Int(Constraint*
ct);
96 void PresolveStoreAffineMapping(Constraint*
ct);
97 void PresolveStoreFlatteningMapping(Constraint*
ct);
98 void PresolveSimplifyElement(Constraint*
ct);
99 void PresolveSimplifyExprElement(Constraint*
ct);
102 void UpdateRuleStats(
const std::string& rule_name) {
103 successful_rules_[rule_name]++;
112 void AddVariableSubstitution(IntegerVariable* from, IntegerVariable* to);
113 IntegerVariable* FindRepresentativeOfVar(IntegerVariable*
var);
114 absl::flat_hash_map<const IntegerVariable*, IntegerVariable*>
115 var_representative_map_;
116 std::vector<IntegerVariable*> var_representative_vector_;
119 absl::flat_hash_map<const IntegerVariable*, AffineMapping> affine_map_;
122 absl::flat_hash_map<const IntegerVariable*, Array2DIndexMapping>
127 std::map<std::string, int> successful_rules_;
129 SolverLogger* logger_;
A constraint is the main modeling object.
Presolver(SolverLogger *logger)
Collection of objects used to extend the Constraint Solver library.