OR-Tools  9.0
cp_model_symmetries.h
Go to the documentation of this file.
1 // Copyright 2010-2021 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 #ifndef OR_TOOLS_SAT_CP_MODEL_SYMMETRIES_H_
15 #define OR_TOOLS_SAT_CP_MODEL_SYMMETRIES_H_
16 
17 #include <limits>
18 #include <memory>
19 #include <vector>
20 
25 #include "ortools/util/logging.h"
26 
27 namespace operations_research {
28 namespace sat {
29 
30 // Returns a list of generators of the symmetry group of the given problem. Each
31 // generator is a permutation of the integer range [0, n) where n is the number
32 // of variables of the problem. They are permutations of the (index
33 // representation of the) problem variables.
34 //
35 // Note that we ignore the variables that appear in no constraint, instead of
36 // outputing the full symmetry group involving them.
37 //
38 // TODO(user): On SAT problems it is more powerful to detect permutations also
39 // involving the negation of the problem variables. So that we could find a
40 // symmetry x <-> not(y) for instance.
41 //
42 // TODO(user): As long as we only exploit symmetry involving only Boolean
43 // variables we can make this code more efficient by not detecting symmetries
44 // involing integer variable.
46  const SatParameters& params, const CpModelProto& problem,
47  std::vector<std::unique_ptr<SparsePermutation>>* generators,
48  double deterministic_limit, SolverLogger* logger);
49 
50 // Detects symmetries and fill the symmetry field.
51 void DetectAndAddSymmetryToProto(const SatParameters& params,
52  CpModelProto* proto, SolverLogger* logger);
53 
54 // Basic implementation of some symmetry breaking during presolve.
55 //
56 // Currently this just try to fix variables by detecting symmetries between
57 // Booleans in bool_and, at_most_one or exactly_one constraints.
58 bool DetectAndExploitSymmetriesInPresolve(PresolveContext* context);
59 
60 } // namespace sat
61 } // namespace operations_research
62 
63 #endif // OR_TOOLS_SAT_CP_MODEL_SYMMETRIES_H_
CpModelProto proto
GurobiMPCallbackContext * context
void DetectAndAddSymmetryToProto(const SatParameters &params, CpModelProto *proto, SolverLogger *logger)
bool DetectAndExploitSymmetriesInPresolve(PresolveContext *context)
void FindCpModelSymmetries(const SatParameters &params, const CpModelProto &problem, std::vector< std::unique_ptr< SparsePermutation >> *generators, double deterministic_limit, SolverLogger *logger)
Collection of objects used to extend the Constraint Solver library.