<ahref="symmetry__util_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aid="l00001"name="l00001"></a><spanclass="lineno"> 1</span><spanclass="comment">// Copyright 2010-2021 Google LLC</span></div>
<divclass="line"><aid="l00002"name="l00002"></a><spanclass="lineno"> 2</span><spanclass="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div>
<divclass="line"><aid="l00003"name="l00003"></a><spanclass="lineno"> 3</span><spanclass="comment">// you may not use this file except in compliance with the License.</span></div>
<divclass="line"><aid="l00004"name="l00004"></a><spanclass="lineno"> 4</span><spanclass="comment">// You may obtain a copy of the License at</span></div>
<divclass="line"><aid="l00008"name="l00008"></a><spanclass="lineno"> 8</span><spanclass="comment">// Unless required by applicable law or agreed to in writing, software</span></div>
<divclass="line"><aid="l00009"name="l00009"></a><spanclass="lineno"> 9</span><spanclass="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div>
<divclass="line"><aid="l00010"name="l00010"></a><spanclass="lineno"> 10</span><spanclass="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div>
<divclass="line"><aid="l00011"name="l00011"></a><spanclass="lineno"> 11</span><spanclass="comment">// See the License for the specific language governing permissions and</span></div>
<divclass="line"><aid="l00012"name="l00012"></a><spanclass="lineno"> 12</span><spanclass="comment">// limitations under the License.</span></div>
<divclass="line"><aid="l00025"name="l00025"></a><spanclass="lineno"> 25</span><spanclass="comment">// Given the generator for a permutation group of [0, n-1], tries to identify</span></div>
<divclass="line"><aid="l00026"name="l00026"></a><spanclass="lineno"> 26</span><spanclass="comment">// a grouping of the variables in an p x q matrix such that any permutations</span></div>
<divclass="line"><aid="l00027"name="l00027"></a><spanclass="lineno"> 27</span><spanclass="comment">// of the columns of this matrix is in the given group.</span></div>
<divclass="line"><aid="l00029"name="l00029"></a><spanclass="lineno"> 29</span><spanclass="comment">// The name comes from: "Packing and Partitioning Orbitopes", Volker Kaibel,</span></div>
<divclass="line"><aid="l00030"name="l00030"></a><spanclass="lineno"> 30</span><spanclass="comment">// Marc E. Pfetsch, https://arxiv.org/abs/math/0603678 . Here we just detect it,</span></div>
<divclass="line"><aid="l00031"name="l00031"></a><spanclass="lineno"> 31</span><spanclass="comment">// independently of the constraints on the variables in this matrix. We can also</span></div>
<divclass="line"><aid="l00034"name="l00034"></a><spanclass="lineno"> 34</span><spanclass="comment">// In order to detect orbitope, this basic algorithm requires that the</span></div>
<divclass="line"><aid="l00035"name="l00035"></a><spanclass="lineno"> 35</span><spanclass="comment">// generators of the orbitope must only contain one or more 2-cyle (i.e</span></div>
<divclass="line"><aid="l00036"name="l00036"></a><spanclass="lineno"> 36</span><spanclass="comment">// transpositions). Thus they must be involutions. The list of transpositions in</span></div>
<divclass="line"><aid="l00037"name="l00037"></a><spanclass="lineno"> 37</span><spanclass="comment">// the SparsePermutation must also be listed in a canonical order.</span></div>
<divclass="line"><aid="l00039"name="l00039"></a><spanclass="lineno"> 39</span><spanclass="comment">// TODO(user): Detect more than one orbitope? Note that once detected, the</span></div>
<divclass="line"><aid="l00040"name="l00040"></a><spanclass="lineno"> 40</span><spanclass="comment">// structure can be exploited efficiently, but for now, a more "generic"</span></div>
<divclass="line"><aid="l00041"name="l00041"></a><spanclass="lineno"> 41</span><spanclass="comment">// algorithm based on stabilizator should achieve the same preprocessing power,</span></div>
<divclass="line"><aid="l00042"name="l00042"></a><spanclass="lineno"> 42</span><spanclass="comment">// so I don't know how hard we need to invest in orbitope detection.</span></div>
<divclass="line"><aid="l00044"name="l00044"></a><spanclass="lineno"> 44</span><spanclass="comment">// TODO(user): The heuristic is quite limited for now, but this works on</span></div>
<divclass="line"><aid="l00045"name="l00045"></a><spanclass="lineno"> 45</span><spanclass="comment">// graph20-20-1rand.mps.gz. I suspect the generators provided by the detection</span></div>
<divclass="line"><aid="l00050"name="l00050"></a><spanclass="lineno"> 50</span><spanclass="comment">// Returns a vector of size n such that</span></div>
<divclass="line"><aid="l00051"name="l00051"></a><spanclass="lineno"> 51</span><spanclass="comment">// - orbits[i] == -1 iff i is never touched by the generators (singleton orbit).</span></div>
<divclass="line"><aid="l00052"name="l00052"></a><spanclass="lineno"> 52</span><spanclass="comment">// - orbits[i] = orbit_index, where orbits are numbered from 0 to num_orbits - 1</span></div>
<divclass="line"><aid="l00054"name="l00054"></a><spanclass="lineno"> 54</span><spanclass="comment">// TODO(user): We could reuse the internal memory if needed.</span></div>
<divclass="line"><aid="l00058"name="l00058"></a><spanclass="lineno"> 58</span><spanclass="comment">// Returns the orbits under the given orbitope action.</span></div>
<divclass="line"><aid="l00059"name="l00059"></a><spanclass="lineno"> 59</span><spanclass="comment">// Same results format as in GetOrbits(). Note that here, the orbit index</span></div>
<divclass="line"><aid="l00060"name="l00060"></a><spanclass="lineno"> 60</span><spanclass="comment">// is simply the row index of an element in the orbitope matrix.</span></div>
<divclass="line"><aid="l00064"name="l00064"></a><spanclass="lineno"> 64</span><spanclass="comment">// Given the generators for a permutation group of [0, n-1], update it to</span></div>
<divclass="line"><aid="l00065"name="l00065"></a><spanclass="lineno"> 65</span><spanclass="comment">// a set of generators of the group stabilizing the given element.</span></div>
<divclass="line"><aid="l00067"name="l00067"></a><spanclass="lineno"> 67</span><spanclass="comment">// Note that one can add symmetry breaking constraints by repeatedly doing:</span></div>
<divclass="line"><aid="l00068"name="l00068"></a><spanclass="lineno"> 68</span><spanclass="comment">// 1/ Call GetOrbits() using the current set of generators.</span></div>
<divclass="line"><aid="l00069"name="l00069"></a><spanclass="lineno"> 69</span><spanclass="comment">// 2/ Choose an element x0 in a large orbit (x0, .. xi ..) , and add x0 >= xi</span></div>
<divclass="line"><aid="l00070"name="l00070"></a><spanclass="lineno"> 70</span><spanclass="comment">// for all i.</span></div>
<divclass="line"><aid="l00071"name="l00071"></a><spanclass="lineno"> 71</span><spanclass="comment">// 3/ Update the set of generators to the one stabilizing x0.</span></div>
<divclass="line"><aid="l00073"name="l00073"></a><spanclass="lineno"> 73</span><spanclass="comment">// This is more or less what is described in "Symmetry Breaking Inequalities</span></div>
<divclass="line"><aid="l00074"name="l00074"></a><spanclass="lineno"> 74</span><spanclass="comment">// from the Schreier-Sims Table", Domenico Salvagnin,</span></div>
<divclass="ttc"id="anamespaceoperations__research_1_1sat_html_a1e331438c0fc60e8b00aebd0b66ce658"><divclass="ttname"><ahref="namespaceoperations__research_1_1sat.html#a1e331438c0fc60e8b00aebd0b66ce658">operations_research::sat::GetOrbitopeOrbits</a></div><divclass="ttdeci">std::vector< int > GetOrbitopeOrbits(int n, const std::vector< std::vector< int >>&orbitope)</div><divclass="ttdef"><b>Definition:</b><ahref="symmetry__util_8cc_source.html#l00183">symmetry_util.cc:183</a></div></div>
<divclass="ttc"id="anamespaceoperations__research_1_1sat_html_ae177cbcee937152b1230499662441902"><divclass="ttname"><ahref="namespaceoperations__research_1_1sat.html#ae177cbcee937152b1230499662441902">operations_research::sat::GetOrbits</a></div><divclass="ttdeci">std::vector< int > GetOrbits(int n, const std::vector< std::unique_ptr< SparsePermutation >>&generators)</div><divclass="ttdef"><b>Definition:</b><ahref="symmetry__util_8cc_source.html#l00151">symmetry_util.cc:151</a></div></div>
<divclass="ttc"id="anamespaceoperations__research_1_1sat_html_ae1ba8d73886e6e6403805d215aa0fd16"><divclass="ttname"><ahref="namespaceoperations__research_1_1sat.html#ae1ba8d73886e6e6403805d215aa0fd16">operations_research::sat::BasicOrbitopeExtraction</a></div><divclass="ttdeci">std::vector< std::vector< int >> BasicOrbitopeExtraction(const std::vector< std::unique_ptr< SparsePermutation >>&generators)</div><divclass="ttdef"><b>Definition:</b><ahref="symmetry__util_8cc_source.html#l00028">symmetry_util.cc:28</a></div></div>
<divclass="ttc"id="anamespaceoperations__research_html"><divclass="ttname"><ahref="namespaceoperations__research.html">operations_research</a></div><divclass="ttdoc">Collection of objects used to extend the Constraint Solver library.</div><divclass="ttdef"><b>Definition:</b><ahref="dense__doubly__linked__list_8h_source.html#l00021">dense_doubly_linked_list.h:21</a></div></div>