<ahref="simplification_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="l00014"name="l00014"></a><spanclass="lineno"> 14</span><spanclass="comment">// Implementation of a pure SAT presolver. This roughly follows the paper:</span></div>
<divclass="line"><aid="l00016"name="l00016"></a><spanclass="lineno"> 16</span><spanclass="comment">// "Effective Preprocessing in SAT through Variable and Clause Elimination",</span></div>
<divclass="line"><aid="l00017"name="l00017"></a><spanclass="lineno"> 17</span><spanclass="comment">// Niklas Een and Armin Biere, published in the SAT 2005 proceedings.</span></div>
<divclass="line"><aid="l00047"name="l00047"></a><spanclass="lineno"> 47</span><spanclass="comment">// The idea is that any presolve algorithm can just update this class, and at</span></div>
<divclass="line"><aid="l00048"name="l00048"></a><spanclass="lineno"> 48</span><spanclass="comment">// the end, this class will recover a solution of the initial problem from a</span></div>
<divclass="line"><aid="l00049"name="l00049"></a><spanclass="lineno"> 49</span><spanclass="comment">// solution of the presolved problem.</span></div>
<divclass="line"><aid="l00054"name="l00054"></a><spanclass="lineno"> 54</span><spanclass="comment">// The postsolver will process the Add() calls in reverse order. If the given</span></div>
<divclass="line"><aid="l00055"name="l00055"></a><spanclass="lineno"> 55</span><spanclass="comment">// clause has all its literals at false, it simply sets the literal x to true.</span></div>
<divclass="line"><aid="l00056"name="l00056"></a><spanclass="lineno"> 56</span><spanclass="comment">// Note that x must be a literal of the given clause.</span></div>
<divclass="line"><aid="l00059"name="l00059"></a><spanclass="lineno"> 59</span><spanclass="comment">// Tells the postsolver that the given literal must be true in any solution.</span></div>
<divclass="line"><aid="l00060"name="l00060"></a><spanclass="lineno"> 60</span><spanclass="comment">// We currently check that the variable is not already fixed.</span></div>
<divclass="line"><aid="l00062"name="l00062"></a><spanclass="lineno"> 62</span><spanclass="comment">// TODO(user): this as almost the same effect as adding an unit clause, and we</span></div>
<divclass="line"><aid="l00063"name="l00063"></a><spanclass="lineno"> 63</span><spanclass="comment">// should probably remove this to simplify the code.</span></div>
<divclass="line"><aid="l00066"name="l00066"></a><spanclass="lineno"> 66</span><spanclass="comment">// This assumes that the given variable mapping has been applied to the</span></div>
<divclass="line"><aid="l00067"name="l00067"></a><spanclass="lineno"> 67</span><spanclass="comment">// problem. All the subsequent Add() and FixVariable() will refer to the new</span></div>
<divclass="line"><aid="l00068"name="l00068"></a><spanclass="lineno"> 68</span><spanclass="comment">// problem. During postsolve, the initial solution must also correspond to</span></div>
<divclass="line"><aid="l00069"name="l00069"></a><spanclass="lineno"> 69</span><spanclass="comment">// this new problem. Note that if mapping[v] == -1, then the literal v is</span></div>
<divclass="line"><aid="l00070"name="l00070"></a><spanclass="lineno"> 70</span><spanclass="comment">// assumed to be deleted.</span></div>
<divclass="line"><aid="l00072"name="l00072"></a><spanclass="lineno"> 72</span><spanclass="comment">// This can be called more than once. But each call must refer to the current</span></div>
<divclass="line"><aid="l00073"name="l00073"></a><spanclass="lineno"> 73</span><spanclass="comment">// variables set (after all the previous mapping have been applied).</span></div>
<divclass="line"><aid="l00077"name="l00077"></a><spanclass="lineno"> 77</span><spanclass="comment">// Extracts the current assignment of the given solver and postsolve it.</span></div>
<divclass="line"><aid="l00079"name="l00079"></a><spanclass="lineno"> 79</span><spanclass="comment">// Node(fdid): This can currently be called only once (but this is easy to</span></div>
<divclass="line"><aid="l00080"name="l00080"></a><spanclass="lineno"> 80</span><spanclass="comment">// change since only some CHECK will fail).</span></div>
<divclass="line"><aid="l00084"name="l00084"></a><spanclass="lineno"> 84</span><spanclass="comment">// Getters to the clauses managed by this class.</span></div>
<divclass="line"><aid="l00085"name="l00085"></a><spanclass="lineno"> 85</span><spanclass="comment">// Important: This will always put the associated literal first.</span></div>
<divclass="line"><aid="l00088"name="l00088"></a><spanclass="lineno"> 88</span><spanclass="comment">// TODO(user): we could avoid the copy here, but because clauses_literals_</span></div>
<divclass="line"><aid="l00089"name="l00089"></a><spanclass="lineno"> 89</span><spanclass="comment">// is a deque, we do need a special return class and cannot juste use</span></div>
<divclass="line"><aid="l00090"name="l00090"></a><spanclass="lineno"> 90</span><spanclass="comment">// absl::Span<Literal> for instance.</span></div>
<divclass="line"><aid="l00091"name="l00091"></a><spanclass="lineno"> 91</span><spanclass="keyword">const</span><spanclass="keywordtype">int</span> begin = clauses_start_[i];</div>
<divclass="line"><aid="l00109"name="l00109"></a><spanclass="lineno"> 109</span><spanclass="comment">// The presolve can add new variables, so we need to store the number of</span></div>
<divclass="line"><aid="l00110"name="l00110"></a><spanclass="lineno"> 110</span><spanclass="comment">// original variables in order to return a solution with the correct number</span></div>
<divclass="line"><aid="l00111"name="l00111"></a><spanclass="lineno"> 111</span><spanclass="comment">// of variables.</span></div>
<divclass="line"><aid="l00115"name="l00115"></a><spanclass="lineno"> 115</span><spanclass="comment">// Stores the arguments of the Add() calls: clauses_start_[i] is the index of</span></div>
<divclass="line"><aid="l00116"name="l00116"></a><spanclass="lineno"> 116</span><spanclass="comment">// the first literal of the clause #i in the clauses_literals_ deque.</span></div>
<divclass="line"><aid="l00121"name="l00121"></a><spanclass="lineno"> 121</span><spanclass="comment">// All the added clauses will be mapped back to the initial variables using</span></div>
<divclass="line"><aid="l00122"name="l00122"></a><spanclass="lineno"> 122</span><spanclass="comment">// this reverse mapping. This way, clauses_ and associated_literal_ are only</span></div>
<divclass="line"><aid="l00123"name="l00123"></a><spanclass="lineno"> 123</span><spanclass="comment">// in term of the initial problem.</span></div>
<divclass="line"><aid="l00126"name="l00126"></a><spanclass="lineno"> 126</span><spanclass="comment">// This will stores the fixed variables value and later the postsolved</span></div>
<divclass="line"><aid="l00133"name="l00133"></a><spanclass="lineno"> 133</span><spanclass="comment">// This class holds a SAT problem (i.e. a set of clauses) and the logic to</span></div>
<divclass="line"><aid="l00134"name="l00134"></a><spanclass="lineno"> 134</span><spanclass="comment">// presolve it by a series of subsumption, self-subsuming resolution, and</span></div>
<divclass="line"><aid="l00135"name="l00135"></a><spanclass="lineno"> 135</span><spanclass="comment">// variable elimination by clause distribution.</span></div>
<divclass="line"><aid="l00137"name="l00137"></a><spanclass="lineno"> 137</span><spanclass="comment">// Note that this does propagate unit-clauses, but probably much</span></div>
<divclass="line"><aid="l00138"name="l00138"></a><spanclass="lineno"> 138</span><spanclass="comment">// less efficiently than the propagation code in the SAT solver. So it is better</span></div>
<divclass="line"><aid="l00139"name="l00139"></a><spanclass="lineno"> 139</span><spanclass="comment">// to use a SAT solver to fix variables before using this class.</span></div>
<divclass="line"><aid="l00141"name="l00141"></a><spanclass="lineno"> 141</span><spanclass="comment">// TODO(user): Interact more with a SAT solver to reuse its propagation logic.</span></div>
<divclass="line"><aid="l00143"name="l00143"></a><spanclass="lineno"> 143</span><spanclass="comment">// TODO(user): Forbid the removal of some variables. This way we can presolve</span></div>
<divclass="line"><aid="l00144"name="l00144"></a><spanclass="lineno"> 144</span><spanclass="comment">// only the clause part of a general Boolean problem by not removing variables</span></div>
<divclass="line"><aid="l00145"name="l00145"></a><spanclass="lineno"> 145</span><spanclass="comment">// appearing in pseudo-Boolean constraints.</span></div>
<divclass="line"><aid="l00160"name="l00160"></a><spanclass="lineno"> 160</span><spanclass="comment">// Registers a mapping to encode equivalent literals.</span></div>
<divclass="line"><aid="l00161"name="l00161"></a><spanclass="lineno"> 161</span><spanclass="comment">// See ProbeAndFindEquivalentLiteral().</span></div>
<divclass="line"><aid="l00167"name="l00167"></a><spanclass="lineno"> 167</span><spanclass="comment">// Adds new clause to the SatPresolver.</span></div>
<divclass="line"><aid="l00172"name="l00172"></a><spanclass="lineno"> 172</span><spanclass="comment">// Presolves the problem currently loaded. Returns false if the model is</span></div>
<divclass="line"><aid="l00173"name="l00173"></a><spanclass="lineno"> 173</span><spanclass="comment">// proven to be UNSAT during the presolving.</span></div>
<divclass="line"><aid="l00175"name="l00175"></a><spanclass="lineno"> 175</span><spanclass="comment">// TODO(user): Add support for a time limit and some kind of iterations limit</span></div>
<divclass="line"><aid="l00176"name="l00176"></a><spanclass="lineno"> 176</span><spanclass="comment">// so that this can never take too much time.</span></div>
<divclass="line"><aid="l00179"name="l00179"></a><spanclass="lineno"> 179</span><spanclass="comment">// Same as Presolve() but only allow to remove BooleanVariable whose index</span></div>
<divclass="line"><aid="l00180"name="l00180"></a><spanclass="lineno"> 180</span><spanclass="comment">// is set to true in the given vector.</span></div>
<divclass="line"><aid="l00183"name="l00183"></a><spanclass="lineno"> 183</span><spanclass="comment">// All the clauses managed by this class.</span></div>
<divclass="line"><aid="l00184"name="l00184"></a><spanclass="lineno"> 184</span><spanclass="comment">// Note that deleted clauses keep their indices (they are just empty).</span></div>
<divclass="line"><aid="l00190"name="l00190"></a><spanclass="lineno"> 190</span><spanclass="comment">// The number of variables. This is computed automatically from the clauses</span></div>
<divclass="line"><aid="l00191"name="l00191"></a><spanclass="lineno"> 191</span><spanclass="comment">// added to the SatPresolver.</span></div>
<divclass="line"><aid="l00194"name="l00194"></a><spanclass="lineno"> 194</span><spanclass="comment">// After presolving, Some variables in [0, NumVariables()) have no longer any</span></div>
<divclass="line"><aid="l00195"name="l00195"></a><spanclass="lineno"> 195</span><spanclass="comment">// clause pointing to them. This return a mapping that maps this interval to</span></div>
<divclass="line"><aid="l00196"name="l00196"></a><spanclass="lineno"> 196</span><spanclass="comment">// [0, new_size) such that now all variables are used. The unused variable</span></div>
<divclass="line"><aid="l00197"name="l00197"></a><spanclass="lineno"> 197</span><spanclass="comment">// will be mapped to BooleanVariable(-1).</span></div>
<divclass="line"><aid="l00200"name="l00200"></a><spanclass="lineno"> 200</span><spanclass="comment">// Loads the current presolved problem in to the given sat solver.</span></div>
<divclass="line"><aid="l00201"name="l00201"></a><spanclass="lineno"> 201</span><spanclass="comment">// Note that the variables will be re-indexed according to the mapping given</span></div>
<divclass="line"><aid="l00202"name="l00202"></a><spanclass="lineno"> 202</span><spanclass="comment">// by GetMapping() so that they form a dense set.</span></div>
<divclass="line"><aid="l00204"name="l00204"></a><spanclass="lineno"> 204</span><spanclass="comment">// IMPORTANT: This is not const because it deletes the presolver clauses as</span></div>
<divclass="line"><aid="l00205"name="l00205"></a><spanclass="lineno"> 205</span><spanclass="comment">// they are added to the SatSolver in order to save memory. After this is</span></div>
<divclass="line"><aid="l00206"name="l00206"></a><spanclass="lineno"> 206</span><spanclass="comment">// called, only VariableMapping() will still works.</span></div>
<divclass="line"><aid="l00209"name="l00209"></a><spanclass="lineno"> 209</span><spanclass="comment">// Visible for Testing. Takes a given clause index and looks for clause that</span></div>
<divclass="line"><aid="l00210"name="l00210"></a><spanclass="lineno"> 210</span><spanclass="comment">// can be subsumed or strengthened using this clause. Returns false if the</span></div>
<divclass="line"><aid="l00211"name="l00211"></a><spanclass="lineno"> 211</span><spanclass="comment">// model is proven to be unsat.</span></div>
<divclass="line"><aid="l00214"name="l00214"></a><spanclass="lineno"> 214</span><spanclass="comment">// Visible for testing. Tries to eliminate x by clause distribution.</span></div>
<divclass="line"><aid="l00215"name="l00215"></a><spanclass="lineno"> 215</span><spanclass="comment">// This is also known as bounded variable elimination.</span></div>
<divclass="line"><aid="l00217"name="l00217"></a><spanclass="lineno"> 217</span><spanclass="comment">// It is always possible to remove x by resolving each clause containing x</span></div>
<divclass="line"><aid="l00218"name="l00218"></a><spanclass="lineno"> 218</span><spanclass="comment">// with all the clauses containing not(x). Hence the cross-product name. Note</span></div>
<divclass="line"><aid="l00219"name="l00219"></a><spanclass="lineno"> 219</span><spanclass="comment">// that this function only do that if the number of clauses is reduced.</span></div>
<divclass="line"><aid="l00222"name="l00222"></a><spanclass="lineno"> 222</span><spanclass="comment">// Visible for testing. Just applies the BVA step of the presolve.</span></div>
<divclass="line"><aid="l00230"name="l00230"></a><spanclass="lineno"> 230</span><spanclass="comment">// Internal function used by ProcessClauseToSimplifyOthers().</span></div>
<divclass="line"><aid="l00234"name="l00234"></a><spanclass="lineno"> 234</span><spanclass="comment">// Internal function to add clauses generated during the presolve. The clause</span></div>
<divclass="line"><aid="l00235"name="l00235"></a><spanclass="lineno"> 235</span><spanclass="comment">// must already be sorted with the default Literal order and will be cleared</span></div>
<divclass="line"><aid="l00236"name="l00236"></a><spanclass="lineno"> 236</span><spanclass="comment">// after this call.</span></div>
<divclass="line"><aid="l00244"name="l00244"></a><spanclass="lineno"> 244</span><spanclass="comment">// Call ProcessClauseToSimplifyOthers() on all the clauses in</span></div>
<divclass="line"><aid="l00245"name="l00245"></a><spanclass="lineno"> 245</span><spanclass="comment">// clause_to_process_ and empty the list afterwards. Note that while some</span></div>
<divclass="line"><aid="l00246"name="l00246"></a><spanclass="lineno"> 246</span><spanclass="comment">// clauses are processed, new ones may be added to the list. Returns false if</span></div>
<divclass="line"><aid="l00247"name="l00247"></a><spanclass="lineno"> 247</span><spanclass="comment">// the problem is shown to be UNSAT.</span></div>
<divclass="line"><aid="l00250"name="l00250"></a><spanclass="lineno"> 250</span><spanclass="comment">// Finds the literal from the clause that occur the less in the clause</span></div>
<divclass="line"><aid="l00257"name="l00257"></a><spanclass="lineno"> 257</span><spanclass="comment">// Tests and maybe perform a Simple Bounded Variable addition starting from</span></div>
<divclass="line"><aid="l00258"name="l00258"></a><spanclass="lineno"> 258</span><spanclass="comment">// the given literal as described in the paper: "Automated Reencoding of</span></div>
<divclass="line"><aid="l00259"name="l00259"></a><spanclass="lineno"> 259</span><spanclass="comment">// Boolean Formulas", Norbert Manthey, Marijn J. H. Heule, and Armin Biere,</span></div>
<divclass="line"><aid="l00260"name="l00260"></a><spanclass="lineno"> 260</span><spanclass="comment">// Volume 7857 of the series Lecture Notes in Computer Science pp 102-117,</span></div>
<divclass="line"><aid="l00264"name="l00264"></a><spanclass="lineno"> 264</span><spanclass="comment">// This seems to have a mostly positive effect, except on the crafted problem</span></div>
<divclass="line"><aid="l00265"name="l00265"></a><spanclass="lineno"> 265</span><spanclass="comment">// familly mugrauer_balint--GI.crafted_nxx_d6_cx_numxx where the reduction</span></div>
<divclass="line"><aid="l00266"name="l00266"></a><spanclass="lineno"> 266</span><spanclass="comment">// is big, but apparently the problem is harder to prove UNSAT for the solver.</span></div>
<divclass="line"><aid="l00269"name="l00269"></a><spanclass="lineno"> 269</span><spanclass="comment">// Display some statistics on the current clause database.</span></div>
<divclass="line"><aid="l00272"name="l00272"></a><spanclass="lineno"> 272</span><spanclass="comment">// Returns a hash of the given clause variables (not literal) in such a way</span></div>
<divclass="line"><aid="l00273"name="l00273"></a><spanclass="lineno"> 273</span><spanclass="comment">// that hash1 & not(hash2) == 0 iff the set of variable of clause 1 is a</span></div>
<divclass="line"><aid="l00274"name="l00274"></a><spanclass="lineno"> 274</span><spanclass="comment">// subset of the one of clause2.</span></div>
<divclass="line"><aid="l00277"name="l00277"></a><spanclass="lineno"> 277</span><spanclass="comment">// The "active" variables on which we want to call CrossProduct() are kept</span></div>
<divclass="line"><aid="l00278"name="l00278"></a><spanclass="lineno"> 278</span><spanclass="comment">// in a priority queue so that we process first the ones that occur the least</span></div>
<divclass="line"><aid="l00279"name="l00279"></a><spanclass="lineno"> 279</span><spanclass="comment">// often in the clause database.</span></div>
<divclass="line"><aid="l00285"name="l00285"></a><spanclass="lineno"> 285</span><spanclass="comment">// Interface for the AdjustablePriorityQueue.</span></div>
<divclass="line"><aid="l00289"name="l00289"></a><spanclass="lineno"> 289</span><spanclass="comment">// Priority order. The AdjustablePriorityQueue returns the largest element</span></div>
<divclass="line"><aid="l00290"name="l00290"></a><spanclass="lineno"> 290</span><spanclass="comment">// first, but our weight goes this other way around (smaller is better).</span></div>
<divclass="line"><aid="l00302"name="l00302"></a><spanclass="lineno"> 302</span><spanclass="comment">// Literal priority queue for BVA. The literals are ordered by descending</span></div>
<divclass="line"><aid="l00303"name="l00303"></a><spanclass="lineno"> 303</span><spanclass="comment">// number of occurrences in clauses.</span></div>
<divclass="line"><aid="l00310"name="l00310"></a><spanclass="lineno"> 310</span><spanclass="comment">// Interface for the AdjustablePriorityQueue.</span></div>
<divclass="line"><aid="l00315"name="l00315"></a><spanclass="lineno"> 315</span><spanclass="comment">// The AdjustablePriorityQueue returns the largest element first.</span></div>
<divclass="line"><aid="l00324"name="l00324"></a><spanclass="lineno"> 324</span> std::deque<BvaPqElement> bva_pq_elements_; <spanclass="comment">// deque because we add variables.</span></div>
<divclass="line"><aid="l00334"name="l00334"></a><spanclass="lineno"> 334</span><spanclass="comment">// List of clauses on which we need to call ProcessClauseToSimplifyOthers().</span></div>
<divclass="line"><aid="l00335"name="l00335"></a><spanclass="lineno"> 335</span><spanclass="comment">// See ProcessAllClauses().</span></div>
<divclass="line"><aid="l00339"name="l00339"></a><spanclass="lineno"> 339</span><spanclass="comment">// The set of all clauses.</span></div>
<divclass="line"><aid="l00340"name="l00340"></a><spanclass="lineno"> 340</span><spanclass="comment">// An empty clause means that it has been removed.</span></div>
<divclass="line"><aid="l00341"name="l00341"></a><spanclass="lineno"> 341</span> std::vector<std::vector<Literal>> clauses_; <spanclass="comment">// Indexed by ClauseIndex</span></div>
<divclass="line"><aid="l00343"name="l00343"></a><spanclass="lineno"> 343</span><spanclass="comment">// The cached value of ComputeSignatureOfClauseVariables() for each clause.</span></div>
<divclass="line"><aid="l00344"name="l00344"></a><spanclass="lineno"> 344</span> std::vector<uint64_t> signatures_; <spanclass="comment">// Indexed by ClauseIndex</span></div>
<divclass="line"><aid="l00348"name="l00348"></a><spanclass="lineno"> 348</span><spanclass="comment">// Occurrence list. For each literal, contains the ClauseIndex of the clause</span></div>
<divclass="line"><aid="l00349"name="l00349"></a><spanclass="lineno"> 349</span><spanclass="comment">// that contains it (ordered by clause index).</span></div>
<divclass="line"><aid="l00353"name="l00353"></a><spanclass="lineno"> 353</span><spanclass="comment">// Because we only lazily clean the occurrence list after clause deletions,</span></div>
<divclass="line"><aid="l00354"name="l00354"></a><spanclass="lineno"> 354</span><spanclass="comment">// we keep the size of the occurrence list (without the deleted clause) here.</span></div>
<divclass="line"><aid="l00372"name="l00372"></a><spanclass="lineno"> 372</span><spanclass="comment">// Visible for testing. Returns true iff:</span></div>
<divclass="line"><aid="l00373"name="l00373"></a><spanclass="lineno"> 373</span><spanclass="comment">// - a subsume b (subsumption): the clause a is a subset of b, in which case</span></div>
<divclass="line"><aid="l00374"name="l00374"></a><spanclass="lineno"> 374</span><spanclass="comment">// opposite_literal is set to -1.</span></div>
<divclass="line"><aid="l00375"name="l00375"></a><spanclass="lineno"> 375</span><spanclass="comment">// - b is strengthened by self-subsumption using a (self-subsuming resolution):</span></div>
<divclass="line"><aid="l00376"name="l00376"></a><spanclass="lineno"> 376</span><spanclass="comment">// the clause a with one of its literal negated is a subset of b, in which</span></div>
<divclass="line"><aid="l00377"name="l00377"></a><spanclass="lineno"> 377</span><spanclass="comment">// case opposite_literal is set to this negated literal index. Moreover, this</span></div>
<divclass="line"><aid="l00378"name="l00378"></a><spanclass="lineno"> 378</span><spanclass="comment">// opposite_literal is then removed from b.</span></div>
<divclass="line"><aid="l00380"name="l00380"></a><spanclass="lineno"> 380</span><spanclass="comment">// If num_inspected_literals_ is not nullptr, the "complexity" of this function</span></div>
<divclass="line"><aid="l00381"name="l00381"></a><spanclass="lineno"> 381</span><spanclass="comment">// will be added to it in order to track the amount of work done.</span></div>
<divclass="line"><aid="l00383"name="l00383"></a><spanclass="lineno"> 383</span><spanclass="comment">// TODO(user): when a.size() << b.size(), we should use binary search instead</span></div>
<divclass="line"><aid="l00384"name="l00384"></a><spanclass="lineno"> 384</span><spanclass="comment">// of scanning b linearly.</span></div>
<divclass="line"><aid="l00389"name="l00389"></a><spanclass="lineno"> 389</span><spanclass="comment">// Visible for testing. Returns kNoLiteralIndex except if:</span></div>
<divclass="line"><aid="l00390"name="l00390"></a><spanclass="lineno"> 390</span><spanclass="comment">// - a and b differ in only one literal.</span></div>
<divclass="line"><aid="l00391"name="l00391"></a><spanclass="lineno"> 391</span><spanclass="comment">// - For a it is the given literal l.</span></div>
<divclass="line"><aid="l00392"name="l00392"></a><spanclass="lineno"> 392</span><spanclass="comment">// In which case, returns the LiteralIndex of the literal in b that is not in a.</span></div>
<divclass="line"><aid="l00396"name="l00396"></a><spanclass="lineno"> 396</span><spanclass="comment">// Visible for testing. Computes the resolvant of 'a' and 'b' obtained by</span></div>
<divclass="line"><aid="l00397"name="l00397"></a><spanclass="lineno"> 397</span><spanclass="comment">// performing the resolution on 'x'. If the resolvant is trivially true this</span></div>
<divclass="line"><aid="l00398"name="l00398"></a><spanclass="lineno"> 398</span><spanclass="comment">// returns false, otherwise it returns true and fill 'out' with the resolvant.</span></div>
<divclass="line"><aid="l00400"name="l00400"></a><spanclass="lineno"> 400</span><spanclass="comment">// Note that the resolvant is just 'a' union 'b' with the literals 'x' and</span></div>
<divclass="line"><aid="l00401"name="l00401"></a><spanclass="lineno"> 401</span><spanclass="comment">// not(x) removed. The two clauses are assumed to be sorted, and the computed</span></div>
<divclass="line"><aid="l00402"name="l00402"></a><spanclass="lineno"> 402</span><spanclass="comment">// resolvant will also be sorted.</span></div>
<divclass="line"><aid="l00404"name="l00404"></a><spanclass="lineno"> 404</span><spanclass="comment">// This is the basic operation when a variable is eliminated by clause</span></div>
<divclass="line"><aid="l00409"name="l00409"></a><spanclass="lineno"> 409</span><spanclass="comment">// Same as ComputeResolvant() but just returns the resolvant size.</span></div>
<divclass="line"><aid="l00410"name="l00410"></a><spanclass="lineno"> 410</span><spanclass="comment">// Returns -1 when ComputeResolvant() returns false.</span></div>
<divclass="line"><aid="l00414"name="l00414"></a><spanclass="lineno"> 414</span><spanclass="comment">// Presolver that does literals probing and finds equivalent literals by</span></div>
<divclass="line"><aid="l00415"name="l00415"></a><spanclass="lineno"> 415</span><spanclass="comment">// computing the strongly connected components of the graph:</span></div>
<divclass="line"><aid="l00416"name="l00416"></a><spanclass="lineno"> 416</span><spanclass="comment">// literal l -> literals propagated by l.</span></div>
<divclass="line"><aid="l00418"name="l00418"></a><spanclass="lineno"> 418</span><spanclass="comment">// Clears the mapping if there are no equivalent literals. Otherwise, mapping[l]</span></div>
<divclass="line"><aid="l00419"name="l00419"></a><spanclass="lineno"> 419</span><spanclass="comment">// is the representative of the equivalent class of l. Note that mapping[l] may</span></div>
<divclass="line"><aid="l00420"name="l00420"></a><spanclass="lineno"> 420</span><spanclass="comment">// be equal to l.</span></div>
<divclass="line"><aid="l00422"name="l00422"></a><spanclass="lineno"> 422</span><spanclass="comment">// The postsolver will be updated so it can recover a solution of the mapped</span></div>
<divclass="line"><aid="l00423"name="l00423"></a><spanclass="lineno"> 423</span><spanclass="comment">// problem. Note that this works on any problem the SatSolver can handle, not</span></div>
<divclass="line"><aid="l00424"name="l00424"></a><spanclass="lineno"> 424</span><spanclass="comment">// only pure SAT problem, but the returned mapping do need to be applied to all</span></div>
<divclass="line"><aid="l00431"name="l00431"></a><spanclass="lineno"> 431</span><spanclass="comment">// Given a 'solver' with a problem already loaded, this will try to simplify the</span></div>
<divclass="line"><aid="l00432"name="l00432"></a><spanclass="lineno"> 432</span><spanclass="comment">// problem (i.e. presolve it) before calling solver->Solve(). In the process,</span></div>
<divclass="line"><aid="l00433"name="l00433"></a><spanclass="lineno"> 433</span><spanclass="comment">// because of the way the presolve is implemented, the underlying SatSolver may</span></div>
<divclass="line"><aid="l00434"name="l00434"></a><spanclass="lineno"> 434</span><spanclass="comment">// change (it is why we use this unique_ptr interface). In particular, the final</span></div>
<divclass="line"><aid="l00435"name="l00435"></a><spanclass="lineno"> 435</span><spanclass="comment">// variables and 'solver' state may have nothing to do with the problem</span></div>
<divclass="line"><aid="l00436"name="l00436"></a><spanclass="lineno"> 436</span><spanclass="comment">// originaly present in the solver. That said, if the problem is shown to be</span></div>
<divclass="line"><aid="l00437"name="l00437"></a><spanclass="lineno"> 437</span><spanclass="comment">// SAT, then the returned solution will be in term of the original variables.</span></div>
<divclass="line"><aid="l00439"name="l00439"></a><spanclass="lineno"> 439</span><spanclass="comment">// Note that the full presolve is only executed if the problem is a pure SAT</span></div>
<divclass="line"><aid="l00440"name="l00440"></a><spanclass="lineno"> 440</span><spanclass="comment">// problem with only clauses.</span></div>
<divclass="line"><aid="l00443"name="l00443"></a><spanclass="lineno"> 443</span> std::vector<bool>* solution <spanclass="comment">/* only filled if SAT */</span>,</div>
<divclass="line"><aid="l00444"name="l00444"></a><spanclass="lineno"> 444</span> DratProofHandler* drat_proof_handler <spanclass="comment">/* can be nullptr */</span>,</div>
<divclass="ttc"id="aclassoperations__research_1_1_time_limit_html"><divclass="ttname"><ahref="classoperations__research_1_1_time_limit.html">operations_research::TimeLimit</a></div><divclass="ttdoc">A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00106">time_limit.h:106</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1sat_1_1_sat_presolver_html_a26fc07b3630b79be6914e6387b63a073"><divclass="ttname"><ahref="classoperations__research_1_1sat_1_1_sat_presolver.html#a26fc07b3630b79be6914e6387b63a073">operations_research::sat::SatPresolver::AddBinaryClause</a></div><divclass="ttdeci">void AddBinaryClause(Literal a, Literal b)</div><divclass="ttdef"><b>Definition:</b><ahref="simplification_8cc_source.html#l00171">simplification.cc:171</a></div></div>
<divclass="ttc"id="anamespaceoperations__research_1_1math__opt_html_a5de89a1f6e3f80a49a0d76136d8044e2"><divclass="ttname"><ahref="namespaceoperations__research_1_1math__opt.html#a5de89a1f6e3f80a49a0d76136d8044e2">operations_research::math_opt::swap</a></div><divclass="ttdeci">void swap(IdMap< K, V >&a, IdMap< K, V >&b)</div><divclass="ttdef"><b>Definition:</b><ahref="id__map_8h_source.html#l00262">id_map.h:262</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>