OR-Tools  8.2
cp_model_symmetries.h
Go to the documentation of this file.
1 // Copyright 2010-2018 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 
22 #include "ortools/sat/cp_model.pb.h"
24 #include "ortools/sat/sat_parameters.pb.h"
25 
26 namespace operations_research {
27 namespace sat {
28 
29 // Returns a list of generators of the symmetry group of the given problem. Each
30 // generator is a permutation of the integer range [0, n) where n is the number
31 // of variables of the problem. They are permutations of the (index
32 // representation of the) problem variables.
33 //
34 // Note that we ignore the variables that appear in no constraint, instead of
35 // outputing the full symmetry group involving them.
36 //
37 // TODO(user): On SAT problems it is more powerful to detect permutations also
38 // involving the negation of the problem variables. So that we could find a
39 // symmetry x <-> not(y) for instance.
40 //
41 // TODO(user): As long as we only exploit symmetry involving only Boolean
42 // variables we can make this code more efficient by not detecting symmetries
43 // involing integer variable.
45  const SatParameters& params, const CpModelProto& problem,
46  std::vector<std::unique_ptr<SparsePermutation>>* generators,
47  double deterministic_limit = std::numeric_limits<double>::infinity());
48 
49 // Detects symmetries and fill the symmetry field.
50 void DetectAndAddSymmetryToProto(const SatParameters& params,
51  CpModelProto* proto);
52 
53 // Basic implementation of some symmetry breaking during presolve.
54 //
55 // Currently this just try to fix variables by detecting symmetries between
56 // Booleans in bool_and, at_most_one or exactly_one constraints.
57 bool DetectAndExploitSymmetriesInPresolve(PresolveContext* context);
58 
59 } // namespace sat
60 } // namespace operations_research
61 
62 #endif // OR_TOOLS_SAT_CP_MODEL_SYMMETRIES_H_
CpModelProto proto
GurobiMPCallbackContext * context
bool DetectAndExploitSymmetriesInPresolve(PresolveContext *context)
void DetectAndAddSymmetryToProto(const SatParameters &params, CpModelProto *proto)
void FindCpModelSymmetries(const SatParameters &params, const CpModelProto &problem, std::vector< std::unique_ptr< SparsePermutation >> *generators, double deterministic_limit)
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...