<ahref="linear__programming__constraint_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="l00044"name="l00044"></a><spanclass="lineno"> 44</span><spanclass="comment">// Stores for each IntegerVariable its temporary LP solution.</span></div>
<divclass="line"><aid="l00046"name="l00046"></a><spanclass="lineno"> 46</span><spanclass="comment">// This is shared between all LinearProgrammingConstraint because in the corner</span></div>
<divclass="line"><aid="l00047"name="l00047"></a><spanclass="lineno"> 47</span><spanclass="comment">// case where we have many different LinearProgrammingConstraint and a lot of</span></div>
<divclass="line"><aid="l00048"name="l00048"></a><spanclass="lineno"> 48</span><spanclass="comment">// variable, we could theoretically use up a quadratic amount of memory</span></div>
<divclass="line"><aid="l00057"name="l00057"></a><spanclass="lineno"> 57</span><spanclass="comment">// Helper struct to combine info generated from solving LP.</span></div>
<divclass="line"><aid="l00064"name="l00064"></a><spanclass="lineno"> 64</span><spanclass="comment">// Simple class to combine linear expression efficiently. First in a sparse</span></div>
<divclass="line"><aid="l00065"name="l00065"></a><spanclass="lineno"> 65</span><spanclass="comment">// way that switch to dense when the number of non-zeros grows.</span></div>
<divclass="line"><aid="l00068"name="l00068"></a><spanclass="lineno"> 68</span><spanclass="comment">// This must be called with the correct size before any other functions are</span></div>
<divclass="line"><aid="l00072"name="l00072"></a><spanclass="lineno"> 72</span><spanclass="comment">// Does vector[col] += value and return false in case of overflow.</span></div>
<divclass="line"><aid="l00075"name="l00075"></a><spanclass="lineno"> 75</span><spanclass="comment">// Similar to Add() but for multiplier * terms.</span></div>
<divclass="line"><aid="l00076"name="l00076"></a><spanclass="lineno"> 76</span><spanclass="comment">// Returns false in case of overflow.</span></div>
<divclass="line"><aid="l00081"name="l00081"></a><spanclass="lineno"> 81</span><spanclass="comment">// This is not const only because non_zeros is sorted. Note that sorting the</span></div>
<divclass="line"><aid="l00082"name="l00082"></a><spanclass="lineno"> 82</span><spanclass="comment">// non-zeros make the result deterministic whether or not we were in sparse</span></div>
<divclass="line"><aid="l00085"name="l00085"></a><spanclass="lineno"> 85</span><spanclass="comment">// TODO(user): Ideally we should convert to IntegerVariable as late as</span></div>
<divclass="line"><aid="l00086"name="l00086"></a><spanclass="lineno"> 86</span><spanclass="comment">// possible. Prefer to use GetTerms().</span></div>
<divclass="line"><aid="l00091"name="l00091"></a><spanclass="lineno"> 91</span><spanclass="comment">// Similar to ConvertToLinearConstraint().</span></div>
<divclass="line"><aid="l00102"name="l00102"></a><spanclass="lineno"> 102</span><spanclass="comment">// If is_sparse is true we maintain the non_zeros positions and bool vector</span></div>
<divclass="line"><aid="l00103"name="l00103"></a><spanclass="lineno"> 103</span><spanclass="comment">// of dense_vector_. Otherwise we don't. Note that we automatically switch</span></div>
<divclass="line"><aid="l00104"name="l00104"></a><spanclass="lineno"> 104</span><spanclass="comment">// from sparse to dense as needed.</span></div>
<divclass="line"><aid="l00109"name="l00109"></a><spanclass="lineno"> 109</span><spanclass="comment">// The dense representation of the vector.</span></div>
<divclass="line"><aid="l00113"name="l00113"></a><spanclass="lineno"> 113</span><spanclass="comment">// A SAT constraint that enforces a set of linear inequality constraints on</span></div>
<divclass="line"><aid="l00114"name="l00114"></a><spanclass="lineno"> 114</span><spanclass="comment">// integer variables using an LP solver.</span></div>
<divclass="line"><aid="l00116"name="l00116"></a><spanclass="lineno"> 116</span><spanclass="comment">// The propagator uses glop's revised simplex for feasibility and propagation.</span></div>
<divclass="line"><aid="l00117"name="l00117"></a><spanclass="lineno"> 117</span><spanclass="comment">// It uses the Reduced Cost Strengthening technique, a classic in mixed integer</span></div>
<divclass="line"><aid="l00118"name="l00118"></a><spanclass="lineno"> 118</span><spanclass="comment">// programming, for instance see the thesis of Tobias Achterberg,</span></div>
<divclass="line"><aid="l00122"name="l00122"></a><spanclass="lineno"> 122</span><spanclass="comment">// Per-constraint bounds propagation is NOT done by this constraint,</span></div>
<divclass="line"><aid="l00123"name="l00123"></a><spanclass="lineno"> 123</span><spanclass="comment">// it should be done by redundant constraints, as reduced cost propagation</span></div>
<divclass="line"><aid="l00124"name="l00124"></a><spanclass="lineno"> 124</span><spanclass="comment">// may miss some filtering.</span></div>
<divclass="line"><aid="l00126"name="l00126"></a><spanclass="lineno"> 126</span><spanclass="comment">// Note that this constraint works with double floating-point numbers, so one</span></div>
<divclass="line"><aid="l00127"name="l00127"></a><spanclass="lineno"> 127</span><spanclass="comment">// could be worried that it may filter too much in case of precision issues.</span></div>
<divclass="line"><aid="l00128"name="l00128"></a><spanclass="lineno"> 128</span><spanclass="comment">// However, by default, we interpret the LP result by recomputing everything</span></div>
<divclass="line"><aid="l00129"name="l00129"></a><spanclass="lineno"> 129</span><spanclass="comment">// in integer arithmetic, so we are exact.</span></div>
<divclass="line"><aid="l00138"name="l00138"></a><spanclass="lineno"> 138</span><spanclass="comment">// Add a new linear constraint to this LP.</span></div>
<divclass="line"><aid="l00141"name="l00141"></a><spanclass="lineno"> 141</span><spanclass="comment">// Set the coefficient of the variable in the objective. Calling it twice will</span></div>
<divclass="line"><aid="l00142"name="l00142"></a><spanclass="lineno"> 142</span><spanclass="comment">// overwrite the previous value.</span></div>
<divclass="line"><aid="l00145"name="l00145"></a><spanclass="lineno"> 145</span><spanclass="comment">// The main objective variable should be equal to the linear sum of</span></div>
<divclass="line"><aid="l00146"name="l00146"></a><spanclass="lineno"> 146</span><spanclass="comment">// the arguments passed to SetObjectiveCoefficient().</span></div>
<divclass="line"><aid="l00149"name="l00149"></a><spanclass="lineno"> 149</span><spanclass="comment">// Register a new cut generator with this constraint.</span></div>
<divclass="line"><aid="l00152"name="l00152"></a><spanclass="lineno"> 152</span><spanclass="comment">// Returns the LP value and reduced cost of a variable in the current</span></div>
<divclass="line"><aid="l00153"name="l00153"></a><spanclass="lineno"> 153</span><spanclass="comment">// solution. These functions should only be called when HasSolution() is true.</span></div>
<divclass="line"><aid="l00155"name="l00155"></a><spanclass="lineno"> 155</span><spanclass="comment">// Note that this solution is always an OPTIMAL solution of an LP above or</span></div>
<divclass="line"><aid="l00156"name="l00156"></a><spanclass="lineno"> 156</span><spanclass="comment">// at the current decision level. We "erase" it when we backtrack over it.</span></div>
<divclass="line"><aid="l00177"name="l00177"></a><spanclass="lineno"> 177</span><spanclass="comment">// Returns a IntegerLiteral guided by the underlying LP constraints.</span></div>
<divclass="line"><aid="l00179"name="l00179"></a><spanclass="lineno"> 179</span><spanclass="comment">// This looks at all unassigned 0-1 variables, takes the one with</span></div>
<divclass="line"><aid="l00180"name="l00180"></a><spanclass="lineno"> 180</span><spanclass="comment">// a support value closest to 0.5, and tries to assign it to 1.</span></div>
<divclass="line"><aid="l00181"name="l00181"></a><spanclass="lineno"> 181</span><spanclass="comment">// If all 0-1 variables have an integer support, returns kNoLiteralIndex.</span></div>
<divclass="line"><aid="l00182"name="l00182"></a><spanclass="lineno"> 182</span><spanclass="comment">// Tie-breaking is done using the variable natural order.</span></div>
<divclass="line"><aid="l00184"name="l00184"></a><spanclass="lineno"> 184</span><spanclass="comment">// TODO(user): This fixes to 1, but for some problems fixing to 0</span></div>
<divclass="line"><aid="l00185"name="l00185"></a><spanclass="lineno"> 185</span><spanclass="comment">// or to the std::round(support value) might work better. When this is the</span></div>
<divclass="line"><aid="l00189"name="l00189"></a><spanclass="lineno"> 189</span><spanclass="comment">// Returns a IntegerLiteral guided by the underlying LP constraints.</span></div>
<divclass="line"><aid="l00191"name="l00191"></a><spanclass="lineno"> 191</span><spanclass="comment">// This computes the mean of reduced costs over successive calls,</span></div>
<divclass="line"><aid="l00192"name="l00192"></a><spanclass="lineno"> 192</span><spanclass="comment">// and tries to fix the variable which has the highest reduced cost.</span></div>
<divclass="line"><aid="l00193"name="l00193"></a><spanclass="lineno"> 193</span><spanclass="comment">// Tie-breaking is done using the variable natural order.</span></div>
<divclass="line"><aid="l00194"name="l00194"></a><spanclass="lineno"> 194</span><spanclass="comment">// Only works for 0/1 variables.</span></div>
<divclass="line"><aid="l00196"name="l00196"></a><spanclass="lineno"> 196</span><spanclass="comment">// TODO(user): Try to get better pseudocosts than averaging every time</span></div>
<divclass="line"><aid="l00197"name="l00197"></a><spanclass="lineno"> 197</span><spanclass="comment">// the heuristic is called. MIP solvers initialize this with strong branching,</span></div>
<divclass="line"><aid="l00198"name="l00198"></a><spanclass="lineno"> 198</span><spanclass="comment">// then keep track of the pseudocosts when doing tree search. Also, this</span></div>
<divclass="line"><aid="l00199"name="l00199"></a><spanclass="lineno"> 199</span><spanclass="comment">// version only branches on var >= 1 and keeps track of reduced costs from var</span></div>
<divclass="line"><aid="l00200"name="l00200"></a><spanclass="lineno"> 200</span><spanclass="comment">// = 1 to var = 0. This works better than the conventional MIP where the</span></div>
<divclass="line"><aid="l00201"name="l00201"></a><spanclass="lineno"> 201</span><spanclass="comment">// chosen variable will be argmax_var min(pseudocost_var(0->1),</span></div>
<divclass="line"><aid="l00202"name="l00202"></a><spanclass="lineno"> 202</span><spanclass="comment">// pseudocost_var(1->0)), probably because we are doing DFS search where MIP</span></div>
<divclass="line"><aid="l00203"name="l00203"></a><spanclass="lineno"> 203</span><spanclass="comment">// does BFS. This might depend on the model, more trials are necessary. We</span></div>
<divclass="line"><aid="l00204"name="l00204"></a><spanclass="lineno"> 204</span><spanclass="comment">// could also do exponential smoothing instead of decaying every N calls, i.e.</span></div>
<divclass="line"><aid="l00205"name="l00205"></a><spanclass="lineno"> 205</span><spanclass="comment">// pseudo = a * pseudo + (1-a) reduced.</span></div>
<divclass="line"><aid="l00208"name="l00208"></a><spanclass="lineno"> 208</span><spanclass="comment">// Returns a IntegerLiteral guided by the underlying LP constraints.</span></div>
<divclass="line"><aid="l00210"name="l00210"></a><spanclass="lineno"> 210</span><spanclass="comment">// This computes the mean of reduced costs over successive calls,</span></div>
<divclass="line"><aid="l00211"name="l00211"></a><spanclass="lineno"> 211</span><spanclass="comment">// and tries to fix the variable which has the highest reduced cost.</span></div>
<divclass="line"><aid="l00212"name="l00212"></a><spanclass="lineno"> 212</span><spanclass="comment">// Tie-breaking is done using the variable natural order.</span></div>
<divclass="line"><aid="l00215"name="l00215"></a><spanclass="lineno"> 215</span><spanclass="comment">// Average number of nonbasic variables with zero reduced costs.</span></div>
<divclass="line"><aid="l00224"name="l00224"></a><spanclass="lineno"> 224</span><spanclass="comment">// Returns some statistics about this LP.</span></div>
<divclass="line"><aid="l00228"name="l00228"></a><spanclass="lineno"> 228</span><spanclass="comment">// Helper methods for branching. Returns true if branching on the given</span></div>
<divclass="line"><aid="l00229"name="l00229"></a><spanclass="lineno"> 229</span><spanclass="comment">// variable helps with more propagation or finds a conflict.</span></div>
<divclass="line"><aid="l00233"name="l00233"></a><spanclass="lineno"> 233</span><spanclass="comment">// Helper method to fill reduced cost / dual ray reason in 'integer_reason'.</span></div>
<divclass="line"><aid="l00234"name="l00234"></a><spanclass="lineno"> 234</span><spanclass="comment">// Generates a set of IntegerLiterals explaining why the best solution can not</span></div>
<divclass="line"><aid="l00235"name="l00235"></a><spanclass="lineno"> 235</span><spanclass="comment">// be improved using reduced costs. This is used to generate explanations for</span></div>
<divclass="line"><aid="l00236"name="l00236"></a><spanclass="lineno"> 236</span><spanclass="comment">// both infeasibility and bounds deductions.</span></div>
<divclass="line"><aid="l00240"name="l00240"></a><spanclass="lineno"> 240</span><spanclass="comment">// Reinitialize the LP from a potentially new set of constraints.</span></div>
<divclass="line"><aid="l00241"name="l00241"></a><spanclass="lineno"> 241</span><spanclass="comment">// This fills all data structure and properly rescale the underlying LP.</span></div>
<divclass="line"><aid="l00243"name="l00243"></a><spanclass="lineno"> 243</span><spanclass="comment">// Returns false if the problem is UNSAT (it can happen when presolve is off</span></div>
<divclass="line"><aid="l00244"name="l00244"></a><spanclass="lineno"> 244</span><spanclass="comment">// and some LP constraint are trivially false).</span></div>
<divclass="line"><aid="l00247"name="l00247"></a><spanclass="lineno"> 247</span><spanclass="comment">// Solve the LP, returns false if something went wrong in the LP solver.</span></div>
<divclass="line"><aid="l00250"name="l00250"></a><spanclass="lineno"> 250</span><spanclass="comment">// Add a "MIR" cut obtained by first taking the linear combination of the</span></div>
<divclass="line"><aid="l00251"name="l00251"></a><spanclass="lineno"> 251</span><spanclass="comment">// row of the matrix according to "integer_multipliers" and then trying</span></div>
<divclass="line"><aid="l00252"name="l00252"></a><spanclass="lineno"> 252</span><spanclass="comment">// some integer rounding heuristic.</span></div>
<divclass="line"><aid="l00254"name="l00254"></a><spanclass="lineno"> 254</span><spanclass="comment">// Return true if a new cut was added to the cut manager.</span></div>
<divclass="line"><aid="l00260"name="l00260"></a><spanclass="lineno"> 260</span><spanclass="comment">// Second half of AddCutFromConstraints().</span></div>
<divclass="line"><aid="l00267"name="l00267"></a><spanclass="lineno"> 267</span><spanclass="comment">// Computes and adds the corresponding type of cuts.</span></div>
<divclass="line"><aid="l00268"name="l00268"></a><spanclass="lineno"> 268</span><spanclass="comment">// This can currently only be called at the root node.</span></div>
<divclass="line"><aid="l00273"name="l00273"></a><spanclass="lineno"> 273</span><spanclass="comment">// Updates the bounds of the LP variables from the CP bounds.</span></div>
<divclass="line"><aid="l00276"name="l00276"></a><spanclass="lineno"> 276</span><spanclass="comment">// Use the dual optimal lp values to compute an EXACT lower bound on the</span></div>
<divclass="line"><aid="l00277"name="l00277"></a><spanclass="lineno"> 277</span><spanclass="comment">// objective. Fills its reason and perform reduced cost strenghtening.</span></div>
<divclass="line"><aid="l00278"name="l00278"></a><spanclass="lineno"> 278</span><spanclass="comment">// Returns false in case of conflict.</span></div>
<divclass="line"><aid="l00281"name="l00281"></a><spanclass="lineno"> 281</span><spanclass="comment">// Same as FillDualRayReason() but perform the computation EXACTLY. Returns</span></div>
<divclass="line"><aid="l00282"name="l00282"></a><spanclass="lineno"> 282</span><spanclass="comment">// false in the case that the problem is not provably infeasible with exact</span></div>
<divclass="line"><aid="l00286"name="l00286"></a><spanclass="lineno"> 286</span><spanclass="comment">// Returns number of non basic variables with zero reduced costs.</span></div>
<divclass="line"><aid="l00289"name="l00289"></a><spanclass="lineno"> 289</span><spanclass="comment">// From a set of row multipliers (at LP scale), scale them back to the CP</span></div>
<divclass="line"><aid="l00290"name="l00290"></a><spanclass="lineno"> 290</span><spanclass="comment">// world and then make them integer (eventually multiplying them by a new</span></div>
<divclass="line"><aid="l00291"name="l00291"></a><spanclass="lineno"> 291</span><spanclass="comment">// scaling factor returned in *scaling).</span></div>
<divclass="line"><aid="l00293"name="l00293"></a><spanclass="lineno"> 293</span><spanclass="comment">// Note that this will loose some precision, but our subsequent computation</span></div>
<divclass="line"><aid="l00294"name="l00294"></a><spanclass="lineno"> 294</span><spanclass="comment">// will still be exact as it will work for any set of multiplier.</span></div>
<divclass="line"><aid="l00300"name="l00300"></a><spanclass="lineno"> 300</span><spanclass="comment">// Computes from an integer linear combination of the integer rows of the LP a</span></div>
<divclass="line"><aid="l00301"name="l00301"></a><spanclass="lineno"> 301</span><spanclass="comment">// new constraint of the form "sum terms <= upper_bound". All computation are</span></div>
<divclass="line"><aid="l00304"name="l00304"></a><spanclass="lineno"> 304</span><spanclass="comment">// Returns false if we encountered any integer overflow.</span></div>
<divclass="line"><aid="l00311"name="l00311"></a><spanclass="lineno"> 311</span><spanclass="comment">// Simple heuristic to try to minimize |upper_bound - ImpliedLB(terms)|. This</span></div>
<divclass="line"><aid="l00312"name="l00312"></a><spanclass="lineno"> 312</span><spanclass="comment">// should make the new constraint tighter and correct a bit the imprecision</span></div>
<divclass="line"><aid="l00313"name="l00313"></a><spanclass="lineno"> 313</span><spanclass="comment">// introduced by rounding the floating points values.</span></div>
<divclass="line"><aid="l00319"name="l00319"></a><spanclass="lineno"> 319</span><spanclass="comment">// Shortcut for an integer linear expression type.</span></div>
<divclass="line"><aid="l00322"name="l00322"></a><spanclass="lineno"> 322</span><spanclass="comment">// Converts a dense representation of a linear constraint to a sparse one</span></div>
<divclass="line"><aid="l00323"name="l00323"></a><spanclass="lineno"> 323</span><spanclass="comment">// expressed in terms of IntegerVariable.</span></div>
<divclass="line"><aid="l00328"name="l00328"></a><spanclass="lineno"> 328</span><spanclass="comment">// Compute the implied lower bound of the given linear expression using the</span></div>
<divclass="line"><aid="l00329"name="l00329"></a><spanclass="lineno"> 329</span><spanclass="comment">// current variable bound. Return kMinIntegerValue in case of overflow.</span></div>
<divclass="line"><aid="l00332"name="l00332"></a><spanclass="lineno"> 332</span><spanclass="comment">// Tests for possible overflow in the propagation of the given linear</span></div>
<divclass="line"><aid="l00336"name="l00336"></a><spanclass="lineno"> 336</span><spanclass="comment">// Reduce the coefficient of the constraint so that we cannot have overflow</span></div>
<divclass="line"><aid="l00337"name="l00337"></a><spanclass="lineno"> 337</span><spanclass="comment">// in the propagation of the given linear constraint. Note that we may loose</span></div>
<divclass="line"><aid="l00338"name="l00338"></a><spanclass="lineno"> 338</span><spanclass="comment">// some strength by doing so.</span></div>
<divclass="line"><aid="l00340"name="l00340"></a><spanclass="lineno"> 340</span><spanclass="comment">// We make sure that any partial sum involving any variable value in their</span></div>
<divclass="line"><aid="l00341"name="l00341"></a><spanclass="lineno"> 341</span><spanclass="comment">// domain do not exceed 2 ^ max_pow.</span></div>
<divclass="line"><aid="l00344"name="l00344"></a><spanclass="lineno"> 344</span><spanclass="comment">// Fills integer_reason_ with the reason for the implied lower bound of the</span></div>
<divclass="line"><aid="l00345"name="l00345"></a><spanclass="lineno"> 345</span><spanclass="comment">// given linear expression. We relax the reason if we have some slack.</span></div>
<divclass="line"><aid="l00349"name="l00349"></a><spanclass="lineno"> 349</span><spanclass="comment">// Fills the deductions vector with reduced cost deductions that can be made</span></div>
<divclass="line"><aid="l00350"name="l00350"></a><spanclass="lineno"> 350</span><spanclass="comment">// from the current state of the LP solver. The given delta should be the</span></div>
<divclass="line"><aid="l00351"name="l00351"></a><spanclass="lineno"> 351</span><spanclass="comment">// difference between the cp objective upper bound and lower bound given by</span></div>
<divclass="line"><aid="l00352"name="l00352"></a><spanclass="lineno"> 352</span><spanclass="comment">// the lp.</span></div>
<divclass="line"><aid="l00355"name="l00355"></a><spanclass="lineno"> 355</span><spanclass="comment">// Returns the variable value on the same scale as the CP variable value.</span></div>
<divclass="line"><aid="l00358"name="l00358"></a><spanclass="lineno"> 358</span><spanclass="comment">// Gets or creates an LP variable that mirrors a CP variable.</span></div>
<divclass="line"><aid="l00359"name="l00359"></a><spanclass="lineno"> 359</span><spanclass="comment">// The variable should be a positive reference.</span></div>
<divclass="line"><aid="l00362"name="l00362"></a><spanclass="lineno"> 362</span><spanclass="comment">// This must be called on an OPTIMAL LP and will update the data for</span></div>
<divclass="line"><aid="l00369"name="l00369"></a><spanclass="lineno"> 369</span><spanclass="comment">// Updates the simplex iteration limit for the next visit.</span></div>
<divclass="line"><aid="l00370"name="l00370"></a><spanclass="lineno"> 370</span><spanclass="comment">// As per current algorithm, we use a limit which is dependent on size of the</span></div>
<divclass="line"><aid="l00371"name="l00371"></a><spanclass="lineno"> 371</span><spanclass="comment">// problem and drop it significantly if degeneracy is detected. We use</span></div>
<divclass="line"><aid="l00372"name="l00372"></a><spanclass="lineno"> 372</span><spanclass="comment">// DUAL_FEASIBLE status as a signal to correct the prediction. The next limit</span></div>
<divclass="line"><aid="l00373"name="l00373"></a><spanclass="lineno"> 373</span><spanclass="comment">// is capped by 'min_iter' and 'max_iter'. Note that this is enabled only for</span></div>
<divclass="line"><aid="l00374"name="l00374"></a><spanclass="lineno"> 374</span><spanclass="comment">// linearization level 2 and above.</span></div>
<divclass="line"><aid="l00378"name="l00378"></a><spanclass="lineno"> 378</span><spanclass="comment">// This epsilon is related to the precision of the value/reduced_cost returned</span></div>
<divclass="line"><aid="l00379"name="l00379"></a><spanclass="lineno"> 379</span><spanclass="comment">// by the LP once they have been scaled back into the CP domain. So for large</span></div>
<divclass="line"><aid="l00380"name="l00380"></a><spanclass="lineno"> 380</span><spanclass="comment">// domain or cost coefficient, we may have some issues.</span></div>
<divclass="line"><aid="l00386"name="l00386"></a><spanclass="lineno"> 386</span><spanclass="comment">// Anything coming from the LP with a magnitude below that will be assumed to</span></div>
<divclass="line"><aid="l00387"name="l00387"></a><spanclass="lineno"> 387</span><spanclass="comment">// be zero.</span></div>
<divclass="line"><aid="l00390"name="l00390"></a><spanclass="lineno"> 390</span><spanclass="comment">// Class responsible for managing all possible constraints that may be part</span></div>
<divclass="line"><aid="l00391"name="l00391"></a><spanclass="lineno"> 391</span><spanclass="comment">// of the LP.</span></div>
<divclass="line"><aid="l00394"name="l00394"></a><spanclass="lineno"> 394</span><spanclass="comment">// Initial problem in integer form.</span></div>
<divclass="line"><aid="l00395"name="l00395"></a><spanclass="lineno"> 395</span><spanclass="comment">// We always sort the inner vectors by increasing glop::ColIndex.</span></div>
<divclass="line"><aid="l00432"name="l00432"></a><spanclass="lineno"> 432</span><spanclass="comment">// Structures used for mirroring IntegerVariables inside the underlying LP</span></div>
<divclass="line"><aid="l00433"name="l00433"></a><spanclass="lineno"> 433</span><spanclass="comment">// solver: an integer variable var is mirrored by mirror_lp_variable_[var].</span></div>
<divclass="line"><aid="l00434"name="l00434"></a><spanclass="lineno"> 434</span><spanclass="comment">// Note that these indices are dense in [0, mirror_lp_variable_.size()] so</span></div>
<divclass="line"><aid="l00435"name="l00435"></a><spanclass="lineno"> 435</span><spanclass="comment">// they can be used as vector indices.</span></div>
<divclass="line"><aid="l00437"name="l00437"></a><spanclass="lineno"> 437</span><spanclass="comment">// TODO(user): This should be absl::StrongVector<glop::ColIndex,</span></div>
<divclass="line"><aid="l00442"name="l00442"></a><spanclass="lineno"> 442</span><spanclass="comment">// We need to remember what to optimize if an objective is given, because</span></div>
<divclass="line"><aid="l00443"name="l00443"></a><spanclass="lineno"> 443</span><spanclass="comment">// then we will switch the objective between feasibility and optimization.</span></div>
<divclass="line"><aid="l00459"name="l00459"></a><spanclass="lineno"> 459</span><spanclass="comment">// The dispatcher for all LP propagators of the model, allows to find which</span></div>
<divclass="line"><aid="l00460"name="l00460"></a><spanclass="lineno"> 460</span><spanclass="comment">// LinearProgrammingConstraint has a given IntegerVariable.</span></div>
<divclass="line"><aid="l00467"name="l00467"></a><spanclass="lineno"> 467</span><spanclass="comment">// Repository of IntegerSumLE that needs to be kept around for the lazy</span></div>
<divclass="line"><aid="l00468"name="l00468"></a><spanclass="lineno"> 468</span><spanclass="comment">// reasons. Those are new integer constraint that are created each time we</span></div>
<divclass="line"><aid="l00469"name="l00469"></a><spanclass="lineno"> 469</span><spanclass="comment">// solve the LP to a dual-feasible solution. Propagating these constraints</span></div>
<divclass="line"><aid="l00470"name="l00470"></a><spanclass="lineno"> 470</span><spanclass="comment">// both improve the objective lower bound but also perform reduced cost</span></div>
<divclass="line"><aid="l00475"name="l00475"></a><spanclass="lineno"> 475</span><spanclass="comment">// Last OPTIMAL solution found by a call to the underlying LP solver.</span></div>
<divclass="line"><aid="l00476"name="l00476"></a><spanclass="lineno"> 476</span><spanclass="comment">// On IncrementalPropagate(), if the bound updates do not invalidate this</span></div>
<divclass="line"><aid="l00477"name="l00477"></a><spanclass="lineno"> 477</span><spanclass="comment">// solution, Propagate() will not find domain reductions, no need to call it.</span></div>
<divclass="line"><aid="l00485"name="l00485"></a><spanclass="lineno"> 485</span><spanclass="comment">// If non-empty, this is the last known optimal lp solution at root-node. If</span></div>
<divclass="line"><aid="l00486"name="l00486"></a><spanclass="lineno"> 486</span><spanclass="comment">// the variable bounds changed, or cuts where added, it is possible that this</span></div>
<divclass="line"><aid="l00487"name="l00487"></a><spanclass="lineno"> 487</span><spanclass="comment">// solution is no longer optimal though.</span></div>
<divclass="line"><aid="l00490"name="l00490"></a><spanclass="lineno"> 490</span><spanclass="comment">// True if the last time we solved the exact same LP at level zero, no cuts</span></div>
<divclass="line"><aid="l00491"name="l00491"></a><spanclass="lineno"> 491</span><spanclass="comment">// and no lazy constraints where added.</span></div>
<divclass="line"><aid="l00494"name="l00494"></a><spanclass="lineno"> 494</span><spanclass="comment">// Same as lp_solution_ but this vector is indexed differently.</span></div>
<divclass="line"><aid="l00497"name="l00497"></a><spanclass="lineno"> 497</span><spanclass="comment">// Linear constraints cannot be created or modified after this is registered.</span></div>
<divclass="line"><aid="l00502"name="l00502"></a><spanclass="lineno"> 502</span><spanclass="comment">// Store some statistics for HeuristicLPReducedCostAverage().</span></div>
<divclass="line"><aid="l00511"name="l00511"></a><spanclass="lineno"> 511</span><spanclass="comment">// All the entries before rev_rc_start_ in the sorted positions correspond</span></div>
<divclass="line"><aid="l00512"name="l00512"></a><spanclass="lineno"> 512</span><spanclass="comment">// to fixed variables and can be ignored.</span></div>
<divclass="line"><aid="l00517"name="l00517"></a><spanclass="lineno"> 517</span><spanclass="comment">// Defined as average number of nonbasic variables with zero reduced costs.</span></div>
<divclass="line"><aid="l00521"name="l00521"></a><spanclass="lineno"> 521</span><spanclass="comment">// Used by the strong branching heuristic.</span></div>
<divclass="line"><aid="l00525"name="l00525"></a><spanclass="lineno"> 525</span><spanclass="comment">// Sum of all simplex iterations performed by this class. This is useful to</span></div>
<divclass="line"><aid="l00526"name="l00526"></a><spanclass="lineno"> 526</span><spanclass="comment">// test the incrementality and compare to other solvers.</span></div>
<divclass="line"><aid="l00529"name="l00529"></a><spanclass="lineno"> 529</span><spanclass="comment">// Some stats on the LP statuses encountered.</span></div>
<divclass="line"><aid="l00534"name="l00534"></a><spanclass="lineno"> 534</span><spanclass="comment">// A class that stores which LP propagator is associated to each variable.</span></div>
<divclass="line"><aid="l00535"name="l00535"></a><spanclass="lineno"> 535</span><spanclass="comment">// We need to give the hash_map a name so it can be used as a singleton in our</span></div>
<divclass="line"><aid="l00538"name="l00538"></a><spanclass="lineno"> 538</span><spanclass="comment">// Important: only positive variable do appear here.</span></div>
<divclass="line"><aid="l00546"name="l00546"></a><spanclass="lineno"> 546</span><spanclass="comment">// A class that stores the collection of all LP constraints in a model.</span></div>
<divclass="line"><aid="l00553"name="l00553"></a><spanclass="lineno"> 553</span><spanclass="comment">// Cut generator for the circuit constraint, where in any feasible solution, the</span></div>
<divclass="line"><aid="l00554"name="l00554"></a><spanclass="lineno"> 554</span><spanclass="comment">// arcs that are present (variable at 1) must form a circuit through all the</span></div>
<divclass="line"><aid="l00555"name="l00555"></a><spanclass="lineno"> 555</span><spanclass="comment">// nodes of the graph. Self arc are forbidden in this case.</span></div>
<divclass="line"><aid="l00557"name="l00557"></a><spanclass="lineno"> 557</span><spanclass="comment">// In more generality, this currently enforce the resulting graph to be strongly</span></div>
<divclass="line"><aid="l00558"name="l00558"></a><spanclass="lineno"> 558</span><spanclass="comment">// connected. Note that we already assume basic constraint to be in the lp, so</span></div>
<divclass="line"><aid="l00559"name="l00559"></a><spanclass="lineno"> 559</span><spanclass="comment">// we do not add any cuts for components of size 1.</span></div>
<divclass="line"><aid="l00564"name="l00564"></a><spanclass="lineno"> 564</span><spanclass="comment">// Almost the same as CreateStronglyConnectedGraphCutGenerator() but for each</span></div>
<divclass="line"><aid="l00565"name="l00565"></a><spanclass="lineno"> 565</span><spanclass="comment">// components, computes the demand needed to serves it, and depending on whether</span></div>
<divclass="line"><aid="l00566"name="l00566"></a><spanclass="lineno"> 566</span><spanclass="comment">// it contains the depot (node zero) or not, compute the minimum number of</span></div>
<divclass="line"><aid="l00567"name="l00567"></a><spanclass="lineno"> 567</span><spanclass="comment">// vehicle that needs to cross the component border.</span></div>
<divclass="ttc"id="aclassoperations__research_1_1_rev_repository_html"><divclass="ttname"><ahref="classoperations__research_1_1_rev_repository.html">operations_research::RevRepository< int ></a></div></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#l00105">time_limit.h:105</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1sat_1_1_model_html"><divclass="ttname"><ahref="classoperations__research_1_1sat_1_1_model.html">operations_research::sat::Model</a></div><divclass="ttdoc">Class that owns everything related to a particular optimization model.</div><divclass="ttdef"><b>Definition:</b><ahref="sat_2model_8h_source.html#l00038">sat/model.h:38</a></div></div>
<divclass="ttc"id="anamespaceoperations__research_1_1sat_html_ae9e5d88686fd52d3bd1a89d7754ca18c"><divclass="ttname"><ahref="namespaceoperations__research_1_1sat.html#ae9e5d88686fd52d3bd1a89d7754ca18c">operations_research::sat::CreateStronglyConnectedGraphCutGenerator</a></div><divclass="ttdeci">CutGenerator CreateStronglyConnectedGraphCutGenerator(int num_nodes, const std::vector< int >&tails, const std::vector< int >&heads, const std::vector< Literal >&literals, Model *model)</div><divclass="ttdef"><b>Definition:</b><ahref="linear__programming__constraint_8cc_source.html#l02553">linear_programming_constraint.cc:2553</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>