<!-- iframe showing the search results (closed by default) -->
<divid="MSearchResultsWindow">
<iframesrc="javascript:void(0)"frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<divclass="header">
<divclass="headertitle">
<divclass="title">revised_simplex.h</div></div>
</div><!--header-->
<divclass="contents">
<ahref="revised__simplex_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="comment">// Copyright 2010-2018 Google LLC</span></div>
<divclass="line"><aname="l00002"></a><spanclass="lineno"> 2</span> <spanclass="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div>
<divclass="line"><aname="l00003"></a><spanclass="lineno"> 3</span> <spanclass="comment">// you may not use this file except in compliance with the License.</span></div>
<divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment">// You may obtain a copy of the License at</span></div>
<divclass="line"><aname="l00008"></a><spanclass="lineno"> 8</span> <spanclass="comment">// Unless required by applicable law or agreed to in writing, software</span></div>
<divclass="line"><aname="l00009"></a><spanclass="lineno"> 9</span> <spanclass="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div>
<divclass="line"><aname="l00010"></a><spanclass="lineno"> 10</span> <spanclass="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div>
<divclass="line"><aname="l00011"></a><spanclass="lineno"> 11</span> <spanclass="comment">// See the License for the specific language governing permissions and</span></div>
<divclass="line"><aname="l00012"></a><spanclass="lineno"> 12</span> <spanclass="comment">// limitations under the License.</span></div>
<divclass="line"><aname="l00014"></a><spanclass="lineno"> 14</span> <spanclass="comment">// Solves a Linear Programing problem using the Revised Simplex algorithm</span></div>
<divclass="line"><aname="l00015"></a><spanclass="lineno"> 15</span> <spanclass="comment">// as described by G.B. Dantzig.</span></div>
<divclass="line"><aname="l00016"></a><spanclass="lineno"> 16</span> <spanclass="comment">// The general form is:</span></div>
<divclass="line"><aname="l00017"></a><spanclass="lineno"> 17</span> <spanclass="comment">// min c.x where c and x are n-vectors,</span></div>
<divclass="line"><aname="l00018"></a><spanclass="lineno"> 18</span> <spanclass="comment">// subject to Ax = b where A is an mxn-matrix, b an m-vector,</span></div>
<divclass="line"><aname="l00019"></a><spanclass="lineno"> 19</span> <spanclass="comment">// with l <= x <= u, i.e.</span></div>
<divclass="line"><aname="l00020"></a><spanclass="lineno"> 20</span> <spanclass="comment">// l_i <= x_i <= u_i for all i in {1 .. m}.</span></div>
<divclass="line"><aname="l00022"></a><spanclass="lineno"> 22</span> <spanclass="comment">// c.x is called the objective function.</span></div>
<divclass="line"><aname="l00023"></a><spanclass="lineno"> 23</span> <spanclass="comment">// Each row a_i of A is an n-vector, and a_i.x = b_i is a linear constraint.</span></div>
<divclass="line"><aname="l00024"></a><spanclass="lineno"> 24</span> <spanclass="comment">// A is called the constraint matrix.</span></div>
<divclass="line"><aname="l00025"></a><spanclass="lineno"> 25</span> <spanclass="comment">// b is called the right hand side (rhs) of the problem.</span></div>
<divclass="line"><aname="l00026"></a><spanclass="lineno"> 26</span> <spanclass="comment">// The constraints l_i <= x_i <= u_i are called the generalized bounds</span></div>
<divclass="line"><aname="l00027"></a><spanclass="lineno"> 27</span> <spanclass="comment">// of the problem (most introductory textbooks only deal with x_i >= 0, as</span></div>
<divclass="line"><aname="l00028"></a><spanclass="lineno"> 28</span> <spanclass="comment">// did the first version of the Simplex algorithm). Note that l_i and u_i</span></div>
<divclass="line"><aname="l00029"></a><spanclass="lineno"> 29</span> <spanclass="comment">// can be -infinity and +infinity, respectively.</span></div>
<divclass="line"><aname="l00031"></a><spanclass="lineno"> 31</span> <spanclass="comment">// To simplify the entry of data, this code actually handles problems in the</span></div>
<divclass="line"><aname="l00048"></a><spanclass="lineno"> 48</span> <spanclass="comment">// where xT = (x1, x2, x3),</span></div>
<divclass="line"><aname="l00049"></a><spanclass="lineno"> 49</span> <spanclass="comment">// s1 is an m1-vector (m1 being the height of A1),</span></div>
<divclass="line"><aname="l00050"></a><spanclass="lineno"> 50</span> <spanclass="comment">// s2 is an m2-vector (m2 being the height of A2).</span></div>
<divclass="line"><aname="l00052"></a><spanclass="lineno"> 52</span> <spanclass="comment">// The following are very good references for terminology, data structures,</span></div>
<divclass="line"><aname="l00053"></a><spanclass="lineno"> 53</span> <spanclass="comment">// and algorithms. They all contain a wealth of references.</span></div>
<divclass="line"><aname="l00058"></a><spanclass="lineno"> 58</span> <spanclass="comment">// Robert J. Vanderbei, "Linear Programming: Foundations and Extensions,"</span></div>
<divclass="line"><aname="l00067"></a><spanclass="lineno"> 67</span> <spanclass="comment">// Short description of the dual simplex algorithm.</span></div>
<divclass="line"><aname="l00069"></a><spanclass="lineno"> 69</span> <spanclass="comment">// The dual simplex algorithm uses the same data structure as the primal, but</span></div>
<divclass="line"><aname="l00070"></a><spanclass="lineno"> 70</span> <spanclass="comment">// progresses towards the optimal solution in a different way:</span></div>
<divclass="line"><aname="l00071"></a><spanclass="lineno"> 71</span> <spanclass="comment">// * It tries to keep the dual values dual-feasible at all time which means that</span></div>
<divclass="line"><aname="l00072"></a><spanclass="lineno"> 72</span> <spanclass="comment">// the reduced costs are of the correct sign depending on the bounds of the</span></div>
<divclass="line"><aname="l00073"></a><spanclass="lineno"> 73</span> <spanclass="comment">// non-basic variables. As a consequence the values of the basic variable are</span></div>
<divclass="line"><aname="l00074"></a><spanclass="lineno"> 74</span> <spanclass="comment">// out of bound until the optimal is reached.</span></div>
<divclass="line"><aname="l00075"></a><spanclass="lineno"> 75</span> <spanclass="comment">// * A basic leaving variable is selected first (dual pricing) and then a</span></div>
<divclass="line"><aname="l00076"></a><spanclass="lineno"> 76</span> <spanclass="comment">// corresponding entering variable is selected. This is done in such a way</span></div>
<divclass="line"><aname="l00077"></a><spanclass="lineno"> 77</span> <spanclass="comment">// that the dual objective value increases (lower bound on the optimal</span></div>
<divclass="line"><aname="l00079"></a><spanclass="lineno"> 79</span> <spanclass="comment">// * Once the basis pivot is chosen, the variable values and the reduced costs</span></div>
<divclass="line"><aname="l00080"></a><spanclass="lineno"> 80</span> <spanclass="comment">// are updated the same way as in the primal algorithm.</span></div>
<divclass="line"><aname="l00082"></a><spanclass="lineno"> 82</span> <spanclass="comment">// Good references on the Dual simplex algorithm are:</span></div>
<divclass="line"><aname="l00084"></a><spanclass="lineno"> 84</span> <spanclass="comment">// Robert Fourer, "Notes on the Dual simplex Method", March 14, 1994.</span></div>
<divclass="line"><aname="l00087"></a><spanclass="lineno"> 87</span> <spanclass="comment">// Achim Koberstein, "The dual simplex method, techniques for a fast and stable</span></div>
<divclass="line"><aname="l00120"></a><spanclass="lineno"> 120</span> <spanclass="comment">// Holds the statuses of all the variables, including slack variables. There</span></div>
<divclass="line"><aname="l00121"></a><spanclass="lineno"> 121</span> <spanclass="comment">// is no point storing constraint statuses since internally all constraints are</span></div>
<divclass="line"><aname="l00122"></a><spanclass="lineno"> 122</span> <spanclass="comment">// always fixed to zero.</span></div>
<divclass="line"><aname="l00124"></a><spanclass="lineno"> 124</span> <spanclass="comment">// Note that this is the minimal amount of information needed to perform a "warm</span></div>
<divclass="line"><aname="l00125"></a><spanclass="lineno"> 125</span> <spanclass="comment">// start". Using this information and the original linear program, the basis can</span></div>
<divclass="line"><aname="l00126"></a><spanclass="lineno"> 126</span> <spanclass="comment">// be refactorized and all the needed quantities derived.</span></div>
<divclass="line"><aname="l00128"></a><spanclass="lineno"> 128</span> <spanclass="comment">// TODO(user): Introduce another state class to store a complete state of the</span></div>
<divclass="line"><aname="l00129"></a><spanclass="lineno"> 129</span> <spanclass="comment">// solver. Using this state and the original linear program, the solver can be</span></div>
<divclass="line"><aname="l00130"></a><spanclass="lineno"> 130</span> <spanclass="comment">// restarted with as little time overhead as possible. This is especially useful</span></div>
<divclass="line"><aname="l00131"></a><spanclass="lineno"> 131</span> <spanclass="comment">// for strong branching in a MIP context.</span></div>
<divclass="line"><aname="l00133"></a><spanclass="lineno"> 133</span> <spanclass="comment">// TODO(user): A MIP solver will potentially store a lot of BasicStates so</span></div>
<divclass="line"><aname="l00134"></a><spanclass="lineno"> 134</span> <spanclass="comment">// memory usage is important. It is possible to use only 2 bits for one</span></div>
<divclass="line"><aname="l00135"></a><spanclass="lineno"> 135</span> <spanclass="comment">// VariableStatus enum. To achieve this, the FIXED_VALUE status can be</span></div>
<divclass="line"><aname="l00136"></a><spanclass="lineno"> 136</span> <spanclass="comment">// converted to either AT_LOWER_BOUND or AT_UPPER_BOUND and decoded properly</span></div>
<divclass="line"><aname="l00137"></a><spanclass="lineno"> 137</span> <spanclass="comment">// later since this will be used with a given linear program. This way we can</span></div>
<divclass="line"><aname="l00138"></a><spanclass="lineno"> 138</span> <spanclass="comment">// even encode more information by using the reduced cost sign to choose to</span></div>
<divclass="line"><aname="l00139"></a><spanclass="lineno"> 139</span> <spanclass="comment">// which bound the fixed status correspond.</span></div>
<divclass="line"><aname="l00146"></a><spanclass="lineno"> 146</span> <spanclass="comment">// Entry point of the revised simplex algorithm implementation.</span></div>
<divclass="line"><aname="l00151"></a><spanclass="lineno"> 151</span> <spanclass="comment">// Sets or gets the algorithm parameters to be used on the next Solve().</span></div>
<divclass="line"><aname="l00157"></a><spanclass="lineno"> 157</span> <spanclass="comment">// Expects that the linear program is in the equations form Ax = 0 created by</span></div>
<divclass="line"><aname="l00158"></a><spanclass="lineno"> 158</span> <spanclass="comment">// LinearProgram::AddSlackVariablesForAllRows, i.e. the rightmost square</span></div>
<divclass="line"><aname="l00159"></a><spanclass="lineno"> 159</span> <spanclass="comment">// submatrix of A is an identity matrix, all its columns have been marked as</span></div>
<divclass="line"><aname="l00160"></a><spanclass="lineno"> 160</span> <spanclass="comment">// slack variables, and the bounds of all constraints have been set to [0, 0].</span></div>
<divclass="line"><aname="l00161"></a><spanclass="lineno"> 161</span> <spanclass="comment">// Returns ERROR_INVALID_PROBLEM, if these assumptions are violated.</span></div>
<divclass="line"><aname="l00163"></a><spanclass="lineno"> 163</span> <spanclass="comment">// By default, the algorithm tries to exploit the computation done during the</span></div>
<divclass="line"><aname="l00164"></a><spanclass="lineno"> 164</span> <spanclass="comment">// last Solve() call. It will analyze the difference of the new linear program</span></div>
<divclass="line"><aname="l00165"></a><spanclass="lineno"> 165</span> <spanclass="comment">// and try to use the previously computed solution as a warm-start. To disable</span></div>
<divclass="line"><aname="l00166"></a><spanclass="lineno"> 166</span> <spanclass="comment">// this behavior or give explicit warm-start data, use one of the State*()</span></div>
<divclass="line"><aname="l00171"></a><spanclass="lineno"> 171</span> <spanclass="comment">// Do not use the current solution as a warm-start for the next Solve(). The</span></div>
<divclass="line"><aname="l00172"></a><spanclass="lineno"> 172</span> <spanclass="comment">// next Solve() will behave as if the class just got created.</span></div>
<divclass="line"><aname="l00175"></a><spanclass="lineno"> 175</span> <spanclass="comment">// Uses the given state as a warm-start for the next Solve() call.</span></div>
<divclass="line"><aname="l00178"></a><spanclass="lineno"> 178</span> <spanclass="comment">// Advanced usage. Tells the next Solve() that the matrix inside the linear</span></div>
<divclass="line"><aname="l00179"></a><spanclass="lineno"> 179</span> <spanclass="comment">// program will not change compared to the one used the last time Solve() was</span></div>
<divclass="line"><aname="l00180"></a><spanclass="lineno"> 180</span> <spanclass="comment">// called. This allows to bypass the somewhat costly check of comparing both</span></div>
<divclass="line"><aname="l00181"></a><spanclass="lineno"> 181</span> <spanclass="comment">// matrices. Note that this call will be ignored if Solve() was never called</span></div>
<divclass="line"><aname="l00182"></a><spanclass="lineno"> 182</span> <spanclass="comment">// or if ClearStateForNextSolve() was called.</span></div>
<divclass="line"><aname="l00185"></a><spanclass="lineno"> 185</span> <spanclass="comment">// Getters to retrieve all the information computed by the last Solve().</span></div>
<divclass="line"><aname="l00202"></a><spanclass="lineno"> 202</span> <spanclass="comment">// If the problem status is PRIMAL_UNBOUNDED (respectively DUAL_UNBOUNDED),</span></div>
<divclass="line"><aname="l00203"></a><spanclass="lineno"> 203</span> <spanclass="comment">// then the solver has a corresponding primal (respectively dual) ray to show</span></div>
<divclass="line"><aname="l00204"></a><spanclass="lineno"> 204</span> <spanclass="comment">// the unboundness. From a primal (respectively dual) feasible solution any</span></div>
<divclass="line"><aname="l00205"></a><spanclass="lineno"> 205</span> <spanclass="comment">// positive multiple of this ray can be added to the solution and keep it</span></div>
<divclass="line"><aname="l00206"></a><spanclass="lineno"> 206</span> <spanclass="comment">// feasible. Moreover, by doing so, the objective of the problem will improve</span></div>
<divclass="line"><aname="l00207"></a><spanclass="lineno"> 207</span> <spanclass="comment">// and its magnitude will go to infinity.</span></div>
<divclass="line"><aname="l00209"></a><spanclass="lineno"> 209</span> <spanclass="comment">// Note that when the problem is DUAL_UNBOUNDED, the dual ray is also known as</span></div>
<divclass="line"><aname="l00210"></a><spanclass="lineno"> 210</span> <spanclass="comment">// the Farkas proof of infeasibility of the problem.</span></div>
<divclass="line"><aname="l00214"></a><spanclass="lineno"> 214</span> <spanclass="comment">// This is the "dual ray" linear combination of the matrix rows.</span></div>
<divclass="line"><aname="l00217"></a><spanclass="lineno"> 217</span> <spanclass="comment">// Returns the index of the column in the basis and the basis factorization.</span></div>
<divclass="line"><aname="l00218"></a><spanclass="lineno"> 218</span> <spanclass="comment">// Note that the order of the column in the basis is important since it is the</span></div>
<divclass="line"><aname="l00219"></a><spanclass="lineno"> 219</span> <spanclass="comment">// one used by the various solve functions provided by the BasisFactorization</span></div>
<divclass="line"><aname="l00227"></a><spanclass="lineno"> 227</span> <spanclass="comment">// Returns a copy of basis_ vector for outside applications (like cuts) to</span></div>
<divclass="line"><aname="l00228"></a><spanclass="lineno"> 228</span> <spanclass="comment">// have the correspondence between rows and columns of the dictionary.</span></div>
<divclass="line"><aname="l00233"></a><spanclass="lineno"> 233</span> <spanclass="comment">// Returns statistics about this class as a string.</span></div>
<divclass="line"><aname="l00236"></a><spanclass="lineno"> 236</span> <spanclass="comment">// Computes the dictionary B^-1*N on-the-fly row by row. Returns the resulting</span></div>
<divclass="line"><aname="l00237"></a><spanclass="lineno"> 237</span> <spanclass="comment">// matrix as a vector of sparse rows so that it is easy to use it on the left</span></div>
<divclass="line"><aname="l00238"></a><spanclass="lineno"> 238</span> <spanclass="comment">// side in the matrix multiplication. Runs in O(num_non_zeros_in_matrix).</span></div>
<divclass="line"><aname="l00239"></a><spanclass="lineno"> 239</span> <spanclass="comment">// TODO(user): Use row scales as well.</span></div>
<divclass="line"><aname="l00242"></a><spanclass="lineno"> 242</span> <spanclass="comment">// Initializes the matrix for the given 'linear_program' and 'state' and</span></div>
<divclass="line"><aname="l00243"></a><spanclass="lineno"> 243</span> <spanclass="comment">// computes the variable values for basic variables using non-basic variables.</span></div>
<divclass="line"><aname="l00247"></a><spanclass="lineno"> 247</span> <spanclass="comment">// This is used in a MIP context to polish the final basis. We assume that the</span></div>
<divclass="line"><aname="l00248"></a><spanclass="lineno"> 248</span> <spanclass="comment">// columns for which SetIntegralityScale() has been called correspond to</span></div>
<divclass="line"><aname="l00249"></a><spanclass="lineno"> 249</span> <spanclass="comment">// integral variable once multiplied by the given factor.</span></div>
<divclass="line"><aname="l00254"></a><spanclass="lineno"> 254</span> <spanclass="comment">// Propagates parameters_ to all the other classes that need it.</span></div>
<divclass="line"><aname="l00256"></a><spanclass="lineno"> 256</span> <spanclass="comment">// TODO(user): Maybe a better design is for them to have a reference to a</span></div>
<divclass="line"><aname="l00257"></a><spanclass="lineno"> 257</span> <spanclass="comment">// unique parameters object? It will clutter a bit more these classes'</span></div>
<divclass="line"><aname="l00261"></a><spanclass="lineno"> 261</span> <spanclass="comment">// Returns a string containing the same information as with GetSolverStats,</span></div>
<divclass="line"><aname="l00262"></a><spanclass="lineno"> 262</span> <spanclass="comment">// but in a much more human-readable format. For example:</span></div>
<divclass="line"><aname="l00263"></a><spanclass="lineno"> 263</span> <spanclass="comment">// Problem status : Optimal</span></div>
<divclass="line"><aname="l00264"></a><spanclass="lineno"> 264</span> <spanclass="comment">// Solving time : 1.843</span></div>
<divclass="line"><aname="l00265"></a><spanclass="lineno"> 265</span> <spanclass="comment">// Number of iterations : 12345</span></div>
<divclass="line"><aname="l00266"></a><spanclass="lineno"> 266</span> <spanclass="comment">// Time for solvability (first phase) : 1.343</span></div>
<divclass="line"><aname="l00267"></a><spanclass="lineno"> 267</span> <spanclass="comment">// Number of iterations for solvability : 10000</span></div>
<divclass="line"><aname="l00268"></a><spanclass="lineno"> 268</span> <spanclass="comment">// Time for optimization : 0.5</span></div>
<divclass="line"><aname="l00269"></a><spanclass="lineno"> 269</span> <spanclass="comment">// Number of iterations for optimization : 2345</span></div>
<divclass="line"><aname="l00270"></a><spanclass="lineno"> 270</span> <spanclass="comment">// Maximum time allowed in seconds : 6000</span></div>
<divclass="line"><aname="l00271"></a><spanclass="lineno"> 271</span> <spanclass="comment">// Maximum number of iterations : 1000000</span></div>
<divclass="line"><aname="l00272"></a><spanclass="lineno"> 272</span> <spanclass="comment">// Stop after first basis : 0</span></div>
<divclass="line"><aname="l00275"></a><spanclass="lineno"> 275</span> <spanclass="comment">// Returns a string containing formatted information about the variable</span></div>
<divclass="line"><aname="l00276"></a><spanclass="lineno"> 276</span> <spanclass="comment">// corresponding to column col.</span></div>
<divclass="line"><aname="l00279"></a><spanclass="lineno"> 279</span> <spanclass="comment">// Displays a short string with the current iteration and objective value.</span></div>
<divclass="line"><aname="l00282"></a><spanclass="lineno"> 282</span> <spanclass="comment">// Displays the error bounds of the current solution.</span></div>
<divclass="line"><aname="l00291"></a><spanclass="lineno"> 291</span> <spanclass="comment">// Displays the following information:</span></div>
<divclass="line"><aname="l00292"></a><spanclass="lineno"> 292</span> <spanclass="comment">// * Linear Programming problem as a dictionary, taking into</span></div>
<divclass="line"><aname="l00293"></a><spanclass="lineno"> 293</span> <spanclass="comment">// account the iterations that have been made;</span></div>
<divclass="line"><aname="l00297"></a><spanclass="lineno"> 297</span> <spanclass="comment">// A dictionary is in the form:</span></div>
<divclass="line"><aname="l00298"></a><spanclass="lineno"> 298</span> <spanclass="comment">// xB = value + sum_{j in N} pa_ij x_j</span></div>
<divclass="line"><aname="l00299"></a><spanclass="lineno"> 299</span> <spanclass="comment">// z = objective_value + sum_{i in N} rc_i x_i</span></div>
<divclass="line"><aname="l00300"></a><spanclass="lineno"> 300</span> <spanclass="comment">// where the pa's are the coefficients of the matrix after the pivotings</span></div>
<divclass="line"><aname="l00301"></a><spanclass="lineno"> 301</span> <spanclass="comment">// and the rc's are the reduced costs, i.e. the coefficients of the objective</span></div>
<divclass="line"><aname="l00302"></a><spanclass="lineno"> 302</span> <spanclass="comment">// after the pivotings.</span></div>
<divclass="line"><aname="l00303"></a><spanclass="lineno"> 303</span> <spanclass="comment">// Dictionaries are the modern way of presenting the result of an iteration</span></div>
<divclass="line"><aname="l00304"></a><spanclass="lineno"> 304</span> <spanclass="comment">// of the Simplex algorithm in the literature.</span></div>
<divclass="line"><aname="l00307"></a><spanclass="lineno"> 307</span> <spanclass="comment">// Displays the Linear Programming problem as it was input.</span></div>
<divclass="line"><aname="l00310"></a><spanclass="lineno"> 310</span> <spanclass="comment">// Returns the current objective value. This is just the sum of the current</span></div>
<divclass="line"><aname="l00311"></a><spanclass="lineno"> 311</span> <spanclass="comment">// variable values times their current cost.</span></div>
<divclass="line"><aname="l00314"></a><spanclass="lineno"> 314</span> <spanclass="comment">// Returns the current objective of the linear program given to Solve() using</span></div>
<divclass="line"><aname="l00315"></a><spanclass="lineno"> 315</span> <spanclass="comment">// the initial costs, maximization direction, objective offset and objective</span></div>
<divclass="line"><aname="l00319"></a><spanclass="lineno"> 319</span> <spanclass="comment">// Assigns names to variables. Variables in the input will be named</span></div>
<divclass="line"><aname="l00320"></a><spanclass="lineno"> 320</span> <spanclass="comment">// x1..., slack variables will be s1... .</span></div>
<divclass="line"><aname="l00323"></a><spanclass="lineno"> 323</span> <spanclass="comment">// Computes the initial variable status from its type. A constrained variable</span></div>
<divclass="line"><aname="l00324"></a><spanclass="lineno"> 324</span> <spanclass="comment">// is set to the lowest of its 2 bounds in absolute value.</span></div>
<divclass="line"><aname="l00327"></a><spanclass="lineno"> 327</span> <spanclass="comment">// Sets the variable status and derives the variable value according to the</span></div>
<divclass="line"><aname="l00328"></a><spanclass="lineno"> 328</span> <spanclass="comment">// exact status definition. This can only be called for non-basic variables</span></div>
<divclass="line"><aname="l00329"></a><spanclass="lineno"> 329</span> <spanclass="comment">// because the value of a basic variable is computed from the values of the</span></div>
<divclass="line"><aname="l00334"></a><spanclass="lineno"> 334</span> <spanclass="comment">// Checks if the basis_ and is_basic_ arrays are well formed. Also checks that</span></div>
<divclass="line"><aname="l00335"></a><spanclass="lineno"> 335</span> <spanclass="comment">// the variable statuses are consistent with this basis. Returns true if this</span></div>
<divclass="line"><aname="l00336"></a><spanclass="lineno"> 336</span> <spanclass="comment">// is the case. This is meant to be used in debug mode only.</span></div>
<divclass="line"><aname="l00339"></a><spanclass="lineno"> 339</span> <spanclass="comment">// Moves the column entering_col into the basis at position basis_row. Removes</span></div>
<divclass="line"><aname="l00340"></a><spanclass="lineno"> 340</span> <spanclass="comment">// the current basis column at position basis_row from the basis and sets its</span></div>
<divclass="line"><aname="l00341"></a><spanclass="lineno"> 341</span> <spanclass="comment">// status to leaving_variable_status.</span></div>
<divclass="line"><aname="l00345"></a><spanclass="lineno"> 345</span> <spanclass="comment">// Initializes matrix-related internal data. Returns true if this data was</span></div>
<divclass="line"><aname="l00346"></a><spanclass="lineno"> 346</span> <spanclass="comment">// unchanged. If not, also sets only_change_is_new_rows to true if compared</span></div>
<divclass="line"><aname="l00347"></a><spanclass="lineno"> 347</span> <spanclass="comment">// to the current matrix, the only difference is that new rows have been</span></div>
<divclass="line"><aname="l00348"></a><spanclass="lineno"> 348</span> <spanclass="comment">// added (with their corresponding extra slack variables). Similarly, sets</span></div>
<divclass="line"><aname="l00349"></a><spanclass="lineno"> 349</span> <spanclass="comment">// only_change_is_new_cols to true if the only difference is that new columns</span></div>
<divclass="line"><aname="l00350"></a><spanclass="lineno"> 350</span> <spanclass="comment">// have been added, in which case also sets num_new_cols to the number of</span></div>
<divclass="line"><aname="l00351"></a><spanclass="lineno"> 351</span> <spanclass="comment">// new columns.</span></div>
<divclass="line"><aname="l00360"></a><spanclass="lineno"> 360</span> <spanclass="comment">// Checks if the only change to the bounds is the addition of new columns,</span></div>
<divclass="line"><aname="l00361"></a><spanclass="lineno"> 361</span> <spanclass="comment">// and that the new columns have at least one bound equal to zero.</span></div>
<divclass="line"><aname="l00368"></a><spanclass="lineno"> 368</span> <spanclass="comment">// Computes the stopping criterion on the problem objective value.</span></div>
<divclass="line"><aname="l00371"></a><spanclass="lineno"> 371</span> <spanclass="comment">// Initializes the variable statuses using a warm-start basis.</span></div>
<divclass="line"><aname="l00375"></a><spanclass="lineno"> 375</span> <spanclass="comment">// Initializes the starting basis. In most cases it starts by the all slack</span></div>
<divclass="line"><aname="l00376"></a><spanclass="lineno"> 376</span> <spanclass="comment">// basis and tries to apply some heuristics to replace fixed variables.</span></div>
<divclass="line"><aname="l00379"></a><spanclass="lineno"> 379</span> <spanclass="comment">// Sets the initial basis to the given columns, try to factorize it and</span></div>
<divclass="line"><aname="l00380"></a><spanclass="lineno"> 380</span> <spanclass="comment">// recompute the basic variable values.</span></div>
<divclass="line"><aname="l00384"></a><spanclass="lineno"> 384</span> <spanclass="comment">// Entry point for the solver initialization.</span></div>
<divclass="line"><aname="l00387"></a><spanclass="lineno"> 387</span> <spanclass="comment">// Saves the current variable statuses in solution_state_.</span></div>
<divclass="line"><aname="l00390"></a><spanclass="lineno"> 390</span> <spanclass="comment">// Displays statistics on what kinds of variables are in the current basis.</span></div>
<divclass="line"><aname="l00393"></a><spanclass="lineno"> 393</span> <spanclass="comment">// Tries to reduce the initial infeasibility (stored in error_) by using the</span></div>
<divclass="line"><aname="l00394"></a><spanclass="lineno"> 394</span> <spanclass="comment">// singleton columns present in the problem. A singleton column is a column</span></div>
<divclass="line"><aname="l00395"></a><spanclass="lineno"> 395</span> <spanclass="comment">// with only one non-zero. This is used by CreateInitialBasis().</span></div>
<divclass="line"><aname="l00398"></a><spanclass="lineno"> 398</span> <spanclass="comment">// Returns the number of empty rows in the matrix, i.e. rows where all</span></div>
<divclass="line"><aname="l00399"></a><spanclass="lineno"> 399</span> <spanclass="comment">// the coefficients are zero.</span></div>
<divclass="line"><aname="l00402"></a><spanclass="lineno"> 402</span> <spanclass="comment">// Returns the number of empty columns in the matrix, i.e. columns where all</span></div>
<divclass="line"><aname="l00403"></a><spanclass="lineno"> 403</span> <spanclass="comment">// the coefficients are zero.</span></div>
<divclass="line"><aname="l00406"></a><spanclass="lineno"> 406</span> <spanclass="comment">// This method transforms a basis for the first phase, with the optimal</span></div>
<divclass="line"><aname="l00407"></a><spanclass="lineno"> 407</span> <spanclass="comment">// value at zero, into a feasible basis for the initial problem, thus</span></div>
<divclass="line"><aname="l00408"></a><spanclass="lineno"> 408</span> <spanclass="comment">// preparing the execution of phase-II of the algorithm.</span></div>
<divclass="line"><aname="l00411"></a><spanclass="lineno"> 411</span> <spanclass="comment">// If the primal maximum residual is too large, recomputes the basic variable</span></div>
<divclass="line"><aname="l00412"></a><spanclass="lineno"> 412</span> <spanclass="comment">// value from the non-basic ones. This function also perturbs the bounds</span></div>
<divclass="line"><aname="l00413"></a><spanclass="lineno"> 413</span> <spanclass="comment">// during the primal simplex if too many iterations are degenerate.</span></div>
<divclass="line"><aname="l00415"></a><spanclass="lineno"> 415</span> <spanclass="comment">// Only call this on a refactorized basis to have the best precision.</span></div>
<divclass="line"><aname="l00421"></a><spanclass="lineno"> 421</span> <spanclass="comment">// Solves the system B.d = a where a is the entering column (given by col).</span></div>
<divclass="line"><aname="l00422"></a><spanclass="lineno"> 422</span> <spanclass="comment">// Known as FTRAN (Forward transformation) in FORTRAN codes.</span></div>
<divclass="line"><aname="l00423"></a><spanclass="lineno"> 423</span> <spanclass="comment">// See Chvatal's book for more detail (Chapter 7).</span></div>
<divclass="line"><aname="l00426"></a><spanclass="lineno"> 426</span> <spanclass="comment">// Computes a - B.d in error_ and return the maximum std::abs() of its coeffs.</span></div>
<divclass="line"><aname="l00429"></a><spanclass="lineno"> 429</span> <spanclass="comment">// Computes the ratio of the basic variable corresponding to 'row'. A target</span></div>
<divclass="line"><aname="l00430"></a><spanclass="lineno"> 430</span> <spanclass="comment">// bound (upper or lower) is chosen depending on the sign of the entering</span></div>
<divclass="line"><aname="l00431"></a><spanclass="lineno"> 431</span> <spanclass="comment">// reduced cost and the sign of the direction 'd_[row]'. The ratio is such</span></div>
<divclass="line"><aname="l00432"></a><spanclass="lineno"> 432</span> <spanclass="comment">// that adding 'ratio * d_[row]' to the variable value changes it to its</span></div>
<divclass="line"><aname="l00437"></a><spanclass="lineno"> 437</span> <spanclass="comment">// First pass of the Harris ratio test. Returns the harris ratio value which</span></div>
<divclass="line"><aname="l00438"></a><spanclass="lineno"> 438</span> <spanclass="comment">// is an upper bound on the ratio value that the leaving variable can take.</span></div>
<divclass="line"><aname="l00439"></a><spanclass="lineno"> 439</span> <spanclass="comment">// Fills leaving_candidates with the ratio and row index of a super-set of the</span></div>
<divclass="line"><aname="l00440"></a><spanclass="lineno"> 440</span> <spanclass="comment">// columns with a ratio <= harris_ratio.</span></div>
<divclass="line"><aname="l00445"></a><spanclass="lineno"> 445</span> <spanclass="comment">// Chooses the leaving variable, considering the entering column and its</span></div>
<divclass="line"><aname="l00446"></a><spanclass="lineno"> 446</span> <spanclass="comment">// associated reduced cost. If there was a precision issue and the basis is</span></div>
<divclass="line"><aname="l00447"></a><spanclass="lineno"> 447</span> <spanclass="comment">// not refactorized, set refactorize to true. Otherwise, the row number of the</span></div>
<divclass="line"><aname="l00448"></a><spanclass="lineno"> 448</span> <spanclass="comment">// leaving variable is written in *leaving_row, and the step length</span></div>
<divclass="line"><aname="l00449"></a><spanclass="lineno"> 449</span> <spanclass="comment">// is written in *step_length.</span></div>
<divclass="line"><aname="l00456"></a><spanclass="lineno"> 456</span> <spanclass="comment">// Chooses the leaving variable for the primal phase-I algorithm. The</span></div>
<divclass="line"><aname="l00457"></a><spanclass="lineno"> 457</span> <spanclass="comment">// algorithm follows more or less what is described in Istvan Maros's book in</span></div>
<divclass="line"><aname="l00458"></a><spanclass="lineno"> 458</span> <spanclass="comment">// chapter 9.6 and what is done for the dual phase-I algorithm which was</span></div>
<divclass="line"><aname="l00459"></a><spanclass="lineno"> 459</span> <spanclass="comment">// derived from Koberstein's PhD. Both references can be found at the top of</span></div>
<divclass="line"><aname="l00460"></a><spanclass="lineno"> 460</span> <spanclass="comment">// this file.</span></div>
<divclass="line"><aname="l00468"></a><spanclass="lineno"> 468</span> <spanclass="comment">// Chooses an infeasible basic variable. The returned values are:</span></div>
<divclass="line"><aname="l00469"></a><spanclass="lineno"> 469</span> <spanclass="comment">// - leaving_row: the basic index of the infeasible leaving variable</span></div>
<divclass="line"><aname="l00470"></a><spanclass="lineno"> 470</span> <spanclass="comment">// or kNoLeavingVariable if no such row exists: the dual simplex algorithm</span></div>
<divclass="line"><aname="l00471"></a><spanclass="lineno"> 471</span> <spanclass="comment">// has terminated and the optimal has been reached.</span></div>
<divclass="line"><aname="l00472"></a><spanclass="lineno"> 472</span> <spanclass="comment">// - cost_variation: how much do we improve the objective by moving one unit</span></div>
<divclass="line"><aname="l00473"></a><spanclass="lineno"> 473</span> <spanclass="comment">// along this dual edge.</span></div>
<divclass="line"><aname="l00474"></a><spanclass="lineno"> 474</span> <spanclass="comment">// - target_bound: the bound at which the leaving variable should go when</span></div>
<divclass="line"><aname="l00475"></a><spanclass="lineno"> 475</span> <spanclass="comment">// leaving the basis.</span></div>
<divclass="line"><aname="l00480"></a><spanclass="lineno"> 480</span> <spanclass="comment">// Updates the prices used by DualChooseLeavingVariableRow() after a simplex</span></div>
<divclass="line"><aname="l00481"></a><spanclass="lineno"> 481</span> <spanclass="comment">// iteration by using direction_. The prices are stored in</span></div>
<divclass="line"><aname="l00482"></a><spanclass="lineno"> 482</span> <spanclass="comment">// dual_pricing_vector_. Note that this function only takes care of the</span></div>
<divclass="line"><aname="l00483"></a><spanclass="lineno"> 483</span> <spanclass="comment">// entering and leaving column dual feasibility status change and that other</span></div>
<divclass="line"><aname="l00484"></a><spanclass="lineno"> 484</span> <spanclass="comment">// changes will be dealt with by DualPhaseIUpdatePriceOnReducedCostsChange().</span></div>
<divclass="line"><aname="l00487"></a><spanclass="lineno"> 487</span> <spanclass="comment">// Updates the prices used by DualChooseLeavingVariableRow() when the reduced</span></div>
<divclass="line"><aname="l00488"></a><spanclass="lineno"> 488</span> <spanclass="comment">// costs of the given columns have changed.</span></div>
<divclass="line"><aname="l00492"></a><spanclass="lineno"> 492</span> <spanclass="comment">// Same as DualChooseLeavingVariableRow() but for the phase I of the dual</span></div>
<divclass="line"><aname="l00493"></a><spanclass="lineno"> 493</span> <spanclass="comment">// simplex. Here the objective is not to minimize the primal infeasibility,</span></div>
<divclass="line"><aname="l00494"></a><spanclass="lineno"> 494</span> <spanclass="comment">// but the dual one, so the variable is not chosen in the same way. See</span></div>
<divclass="line"><aname="l00495"></a><spanclass="lineno"> 495</span> <spanclass="comment">// "Notes on the Dual simplex Method" or Istvan Maros, "A Piecewise Linear</span></div>
<divclass="line"><aname="l00496"></a><spanclass="lineno"> 496</span> <spanclass="comment">// Dual Phase-1 Algorithm for the Simplex Method", Computational Optimization</span></div>
<divclass="line"><aname="l00497"></a><spanclass="lineno"> 497</span> <spanclass="comment">// and Applications, October 2003, Volume 26, Issue 1, pp 63-81.</span></div>
<divclass="line"><aname="l00503"></a><spanclass="lineno"> 503</span> <spanclass="comment">// Makes sure the boxed variable are dual-feasible by setting them to the</span></div>
<divclass="line"><aname="l00504"></a><spanclass="lineno"> 504</span> <spanclass="comment">// correct bound according to their reduced costs. This is called</span></div>
<divclass="line"><aname="l00505"></a><spanclass="lineno"> 505</span> <spanclass="comment">// Dual feasibility correction in the literature.</span></div>
<divclass="line"><aname="l00507"></a><spanclass="lineno"> 507</span> <spanclass="comment">// Note that this function is also used as a part of the bound flipping ratio</span></div>
<divclass="line"><aname="l00508"></a><spanclass="lineno"> 508</span> <spanclass="comment">// test by flipping the boxed dual-infeasible variables at each iteration.</span></div>
<divclass="line"><aname="l00510"></a><spanclass="lineno"> 510</span> <spanclass="comment">// If update_basic_values is true, the basic variable values are updated.</span></div>
<divclass="line"><aname="l00515"></a><spanclass="lineno"> 515</span> <spanclass="comment">// Computes the step needed to move the leaving_row basic variable to the</span></div>
<divclass="line"><aname="l00516"></a><spanclass="lineno"> 516</span> <spanclass="comment">// given target bound.</span></div>
<divclass="line"><aname="l00520"></a><spanclass="lineno"> 520</span> <spanclass="comment">// Returns true if the basis obtained after the given pivot can be factorized.</span></div>
<divclass="line"><aname="l00523"></a><spanclass="lineno"> 523</span> <spanclass="comment">// Gets the current LU column permutation from basis_representation,</span></div>
<divclass="line"><aname="l00524"></a><spanclass="lineno"> 524</span> <spanclass="comment">// applies it to basis_ and then sets it to the identity permutation since</span></div>
<divclass="line"><aname="l00525"></a><spanclass="lineno"> 525</span> <spanclass="comment">// it will no longer be needed during solves. This function also updates all</span></div>
<divclass="line"><aname="l00526"></a><spanclass="lineno"> 526</span> <spanclass="comment">// the data that depends on the column order in basis_.</span></div>
<divclass="line"><aname="l00529"></a><spanclass="lineno"> 529</span> <spanclass="comment">// Updates the system state according to the given basis pivot.</span></div>
<divclass="line"><aname="l00530"></a><spanclass="lineno"> 530</span> <spanclass="comment">// Returns an error if the update could not be done because of some precision</span></div>
<divclass="line"><aname="l00536"></a><spanclass="lineno"> 536</span> <spanclass="comment">// Displays all the timing stats related to the calling object.</span></div>
<divclass="line"><aname="l00539"></a><spanclass="lineno"> 539</span> <spanclass="comment">// Returns whether or not a basis refactorization is needed at the beginning</span></div>
<divclass="line"><aname="l00540"></a><spanclass="lineno"> 540</span> <spanclass="comment">// of the main loop in Minimize() or DualMinimize(). The idea is that if a</span></div>
<divclass="line"><aname="l00541"></a><spanclass="lineno"> 541</span> <spanclass="comment">// refactorization is going to be needed by one of the components, it is</span></div>
<divclass="line"><aname="l00542"></a><spanclass="lineno"> 542</span> <spanclass="comment">// better to do that as soon as possible so that every component can take</span></div>
<divclass="line"><aname="l00543"></a><spanclass="lineno"> 543</span> <spanclass="comment">// advantage of it.</span></div>
<divclass="line"><aname="l00546"></a><spanclass="lineno"> 546</span> <spanclass="comment">// Calls basis_factorization_.Refactorize() depending on the result of</span></div>
<divclass="line"><aname="l00547"></a><spanclass="lineno"> 547</span> <spanclass="comment">// NeedsBasisRefactorization(). Invalidates any data structure that depends</span></div>
<divclass="line"><aname="l00548"></a><spanclass="lineno"> 548</span> <spanclass="comment">// on the current factorization. Sets refactorize to false.</span></div>
<divclass="line"><aname="l00551"></a><spanclass="lineno"> 551</span> <spanclass="comment">// Minimize the objective function, be it for satisfiability or for</span></div>
<divclass="line"><aname="l00552"></a><spanclass="lineno"> 552</span> <spanclass="comment">// optimization. Used by Solve().</span></div>
<divclass="line"><aname="l00555"></a><spanclass="lineno"> 555</span> <spanclass="comment">// Same as Minimize() for the dual simplex algorithm.</span></div>
<divclass="line"><aname="l00556"></a><spanclass="lineno"> 556</span> <spanclass="comment">// TODO(user): remove duplicate code between the two functions.</span></div>
<divclass="line"><aname="l00559"></a><spanclass="lineno"> 559</span> <spanclass="comment">// Experimental. This is useful in a MIP context. It performs a few degenerate</span></div>
<divclass="line"><aname="l00560"></a><spanclass="lineno"> 560</span> <spanclass="comment">// pivot to try to mimize the fractionality of the optimal basis.</span></div>
<divclass="line"><aname="l00562"></a><spanclass="lineno"> 562</span> <spanclass="comment">// We assume that the columns for which SetIntegralityScale() has been called</span></div>
<divclass="line"><aname="l00563"></a><spanclass="lineno"> 563</span> <spanclass="comment">// correspond to integral variable once scaled by the given factor.</span></div>
<divclass="line"><aname="l00565"></a><spanclass="lineno"> 565</span> <spanclass="comment">// I could only find slides for the reference of this "LP Solution Polishing</span></div>
<divclass="line"><aname="l00566"></a><spanclass="lineno"> 566</span> <spanclass="comment">// to improve MIP Performance", Matthias Miltenberger, Zuse Institute Berlin.</span></div>
<divclass="line"><aname="l00569"></a><spanclass="lineno"> 569</span> <spanclass="comment">// Utility functions to return the current ColIndex of the slack column with</span></div>
<divclass="line"><aname="l00570"></a><spanclass="lineno"> 570</span> <spanclass="comment">// given number. Note that currently, such columns are always present in the</span></div>
<divclass="line"><aname="l00571"></a><spanclass="lineno"> 571</span> <spanclass="comment">// internal representation of a linear program.</span></div>
<divclass="line"><aname="l00574"></a><spanclass="lineno"> 574</span> <spanclass="comment">// Advances the deterministic time in time_limit with the difference between</span></div>
<divclass="line"><aname="l00575"></a><spanclass="lineno"> 575</span> <spanclass="comment">// the current internal deterministic time and the internal deterministic time</span></div>
<divclass="line"><aname="l00576"></a><spanclass="lineno"> 576</span> <spanclass="comment">// during the last call to this method.</span></div>
<divclass="line"><aname="l00577"></a><spanclass="lineno"> 577</span> <spanclass="comment">// TODO(user): Update the internals of revised simplex so that the time</span></div>
<divclass="line"><aname="l00578"></a><spanclass="lineno"> 578</span> <spanclass="comment">// limit is updated at the source and remove this method.</span></div>
<divclass="line"><aname="l00587"></a><spanclass="lineno"> 587</span> <spanclass="comment">// Current number of columns in the problem.</span></div>
<divclass="line"><aname="l00590"></a><spanclass="lineno"> 590</span> <spanclass="comment">// Index of the first slack variable in the input problem. We assume that all</span></div>
<divclass="line"><aname="l00591"></a><spanclass="lineno"> 591</span> <spanclass="comment">// variables with index greater or equal to first_slack_col_ are slack</span></div>
<divclass="line"><aname="l00595"></a><spanclass="lineno"> 595</span> <spanclass="comment">// We're using vectors after profiling and looking at the generated assembly</span></div>
<divclass="line"><aname="l00596"></a><spanclass="lineno"> 596</span> <spanclass="comment">// it's as fast as std::unique_ptr as long as the size is properly reserved</span></div>
<divclass="line"><aname="l00599"></a><spanclass="lineno"> 599</span> <spanclass="comment">// Compact version of the matrix given to Solve().</span></div>
<divclass="line"><aname="l00602"></a><spanclass="lineno"> 602</span> <spanclass="comment">// The transpose of compact_matrix_, it may be empty if it is not needed.</span></div>
<divclass="line"><aname="l00605"></a><spanclass="lineno"> 605</span> <spanclass="comment">// Stop the algorithm and report feasibility if:</span></div>
<divclass="line"><aname="l00606"></a><spanclass="lineno"> 606</span> <spanclass="comment">// - The primal simplex is used, the problem is primal-feasible and the</span></div>
<divclass="line"><aname="l00607"></a><spanclass="lineno"> 607</span> <spanclass="comment">// current objective value is strictly lower than primal_objective_limit_.</span></div>
<divclass="line"><aname="l00608"></a><spanclass="lineno"> 608</span> <spanclass="comment">// - The dual simplex is used, the problem is dual-feasible and the current</span></div>
<divclass="line"><aname="l00609"></a><spanclass="lineno"> 609</span> <spanclass="comment">// objective value is strictly greater than dual_objective_limit_.</span></div>
<divclass="line"><aname="l00613"></a><spanclass="lineno"> 613</span> <spanclass="comment">// Current objective (feasibility for Phase-I, user-provided for Phase-II).</span></div>
<divclass="line"><aname="l00616"></a><spanclass="lineno"> 616</span> <spanclass="comment">// Array of coefficients for the user-defined objective.</span></div>
<divclass="line"><aname="l00617"></a><spanclass="lineno"> 617</span> <spanclass="comment">// Indexed by column number. Used in Phase-II.</span></div>
<divclass="line"><aname="l00620"></a><spanclass="lineno"> 620</span> <spanclass="comment">// Objective offset and scaling factor of the linear program given to Solve().</span></div>
<divclass="line"><aname="l00621"></a><spanclass="lineno"> 621</span> <spanclass="comment">// This is used to display the correct objective values in the logs with</span></div>
<divclass="line"><aname="l00630"></a><spanclass="lineno"> 630</span> <spanclass="comment">// The bound perturbation to be used for basic variable that are slightly</span></div>
<divclass="line"><aname="l00631"></a><spanclass="lineno"> 631</span> <spanclass="comment">// outside their bounds. This contains small values that are non-zero only if</span></div>
<divclass="line"><aname="l00632"></a><spanclass="lineno"> 632</span> <spanclass="comment">// the primal simplex ran into many degenerate iterations.</span></div>
<divclass="line"><aname="l00635"></a><spanclass="lineno"> 635</span> <spanclass="comment">// Used in dual phase I to keep track of the non-basic dual infeasible</span></div>
<divclass="line"><aname="l00636"></a><spanclass="lineno"> 636</span> <spanclass="comment">// columns and their sign of infeasibility (+1 or -1).</span></div>
<divclass="line"><aname="l00640"></a><spanclass="lineno"> 640</span> <spanclass="comment">// Used in dual phase I to hold the price of each possible leaving choices</span></div>
<divclass="line"><aname="l00641"></a><spanclass="lineno"> 641</span> <spanclass="comment">// and the bitset of the possible leaving candidates.</span></div>
<divclass="line"><aname="l00645"></a><spanclass="lineno"> 645</span> <spanclass="comment">// A temporary scattered column that is always reset to all zero after use.</span></div>
<divclass="line"><aname="l00648"></a><spanclass="lineno"> 648</span> <spanclass="comment">// Array of column index, giving the column number corresponding</span></div>
<divclass="line"><aname="l00649"></a><spanclass="lineno"> 649</span> <spanclass="comment">// to a given basis row.</span></div>
<divclass="line"><aname="l00652"></a><spanclass="lineno"> 652</span> <spanclass="comment">// Vector of strings containing the names of variables.</span></div>
<divclass="line"><aname="l00653"></a><spanclass="lineno"> 653</span> <spanclass="comment">// Indexed by column number.</span></div>
<divclass="line"><aname="l00656"></a><spanclass="lineno"> 656</span> <spanclass="comment">// Information about the solution computed by the last Solve().</span></div>
<divclass="line"><aname="l00666"></a><spanclass="lineno"> 666</span> <spanclass="comment">// Flag used by NotifyThatMatrixIsUnchangedForNextSolve() and changing</span></div>
<divclass="line"><aname="l00667"></a><spanclass="lineno"> 667</span> <spanclass="comment">// the behavior of Initialize().</span></div>
<divclass="line"><aname="l00670"></a><spanclass="lineno"> 670</span> <spanclass="comment">// This is known as 'd' in the literature and is set during each pivot to the</span></div>
<divclass="line"><aname="l00671"></a><spanclass="lineno"> 671</span> <spanclass="comment">// right inverse of the basic entering column of A by ComputeDirection().</span></div>
<divclass="line"><aname="l00672"></a><spanclass="lineno"> 672</span> <spanclass="comment">// ComputeDirection() also fills direction_.non_zeros with the position of the</span></div>
<divclass="line"><aname="l00677"></a><spanclass="lineno"> 677</span> <spanclass="comment">// Used to compute the error 'b - A.x' or 'a - B.d'.</span></div>
<divclass="line"><aname="l00680"></a><spanclass="lineno"> 680</span> <spanclass="comment">// Representation of matrix B using eta matrices and LU decomposition.</span></div>
<divclass="line"><aname="l00683"></a><spanclass="lineno"> 683</span> <spanclass="comment">// Classes responsible for maintaining the data of the corresponding names.</span></div>
<divclass="line"><aname="l00691"></a><spanclass="lineno"> 691</span> <spanclass="comment">// Class holding the algorithms to choose the entering column during a simplex</span></div>
<divclass="line"><aname="l00695"></a><spanclass="lineno"> 695</span> <spanclass="comment">// Temporary memory used by DualMinimize().</span></div>
<divclass="line"><aname="l00702"></a><spanclass="lineno"> 702</span> <spanclass="comment">// Number of iterations performed during the first (feasibility) phase.</span></div>
<divclass="line"><aname="l00705"></a><spanclass="lineno"> 705</span> <spanclass="comment">// Number of iterations performed during the second (optimization) phase.</span></div>
<divclass="line"><aname="l00711"></a><spanclass="lineno"> 711</span> <spanclass="comment">// Time spent in the first (feasibility) phase.</span></div>
<divclass="line"><aname="l00714"></a><spanclass="lineno"> 714</span> <spanclass="comment">// Time spent in the second (optimization) phase.</span></div>
<divclass="line"><aname="l00717"></a><spanclass="lineno"> 717</span> <spanclass="comment">// The internal deterministic time during the most recent call to</span></div>
<divclass="line"><aname="l00721"></a><spanclass="lineno"> 721</span> <spanclass="comment">// Statistics about the iterations done by Minimize().</span></div>
<divclass="line"><aname="l00758"></a><spanclass="lineno"> 758</span> <spanclass="comment">// Placeholder for all the function timing stats.</span></div>
<divclass="line"><aname="l00759"></a><spanclass="lineno"> 759</span> <spanclass="comment">// Mutable because we time const functions like ChooseLeavingVariableRow().</span></div>
<divclass="line"><aname="l00762"></a><spanclass="lineno"> 762</span> <spanclass="comment">// Proto holding all the parameters of this algorithm.</span></div>
<divclass="line"><aname="l00764"></a><spanclass="lineno"> 764</span> <spanclass="comment">// Note that parameters_ may actually change during a solve as the solver may</span></div>
<divclass="line"><aname="l00765"></a><spanclass="lineno"> 765</span> <spanclass="comment">// dynamically adapt some values. It is why we store the argument of the last</span></div>
<divclass="line"><aname="l00766"></a><spanclass="lineno"> 766</span> <spanclass="comment">// SetParameters() call in initial_parameters_ so the next Solve() can reset</span></div>
<divclass="line"><aname="l00767"></a><spanclass="lineno"> 767</span> <spanclass="comment">// it correctly.</span></div>
<divclass="line"><aname="l00771"></a><spanclass="lineno"> 771</span> <spanclass="comment">// LuFactorization used to test if a pivot will cause the new basis to</span></div>
<divclass="line"><aname="l00772"></a><spanclass="lineno"> 772</span> <spanclass="comment">// not be factorizable.</span></div>
<divclass="line"><aname="l00775"></a><spanclass="lineno"> 775</span> <spanclass="comment">// Number of degenerate iterations made just before the current iteration.</span></div>
<divclass="line"><aname="l00778"></a><spanclass="lineno"> 778</span> <spanclass="comment">// Indicate if we are in the feasibility_phase (1st phase) or not.</span></div>
<divclass="line"><aname="l00781"></a><spanclass="lineno"> 781</span> <spanclass="comment">// Indicates whether simplex ended due to the objective limit being reached.</span></div>
<divclass="line"><aname="l00782"></a><spanclass="lineno"> 782</span> <spanclass="comment">// Note that it's not enough to compare the final objective value with the</span></div>
<divclass="line"><aname="l00783"></a><spanclass="lineno"> 783</span> <spanclass="comment">// limit due to numerical issues (i.e., the limit which is reached within</span></div>
<divclass="line"><aname="l00784"></a><spanclass="lineno"> 784</span> <spanclass="comment">// given tolerance on the internal objective may no longer be reached when the</span></div>
<divclass="line"><aname="l00785"></a><spanclass="lineno"> 785</span> <spanclass="comment">// objective scaling and offset are taken into account).</span></div>
<divclass="line"><aname="l00788"></a><spanclass="lineno"> 788</span> <spanclass="comment">// Temporary SparseColumn used by ChooseLeavingVariableRow().</span></div>
<divclass="line"><aname="l00791"></a><spanclass="lineno"> 791</span> <spanclass="comment">// Temporary vector used to hold the best leaving column candidates that are</span></div>
<divclass="line"><aname="l00792"></a><spanclass="lineno"> 792</span> <spanclass="comment">// tied using the current choosing criteria. We actually only store the tied</span></div>
<divclass="line"><aname="l00793"></a><spanclass="lineno"> 793</span> <spanclass="comment">// candidate #2, #3, ...; because the first tied candidate is remembered</span></div>
<divclass="line"><aname="l00806"></a><spanclass="lineno"> 806</span> <spanclass="comment">// Hides the details of the dictionary matrix implementation. In the future,</span></div>
<divclass="line"><aname="l00807"></a><spanclass="lineno"> 807</span> <spanclass="comment">// GLOP will support generating the dictionary one row at a time without having</span></div>
<divclass="line"><aname="l00808"></a><spanclass="lineno"> 808</span> <spanclass="comment">// to store the whole matrix in memory.</span></div>
<divclass="line"><aname="l00813"></a><spanclass="lineno"> 813</span> <spanclass="comment">// RevisedSimplex cannot be passed const because we have to call a non-const</span></div>
<divclass="line"><aname="l00815"></a><spanclass="lineno"> 815</span> <spanclass="comment">// TODO(user): Overload this to take RevisedSimplex* alone when the</span></div>
<divclass="line"><aname="l00816"></a><spanclass="lineno"> 816</span> <spanclass="comment">// caller would normally pass a nullptr for col_scales so this and</span></div>
<divclass="line"><aname="l00817"></a><spanclass="lineno"> 817</span> <spanclass="comment">// ComputeDictionary can take a const& argument.</span></div>
<divclass="line"><aname="l00829"></a><spanclass="lineno"> 829</span> <spanclass="comment">// TODO(user): This function is a better fit for the future custom iterator.</span></div>
<divclass="line"><aname="l00839"></a><spanclass="lineno"> 839</span> <spanclass="comment">// TODO(user): When a row-by-row generation of the dictionary is supported,</span></div>
<divclass="line"><aname="l00840"></a><spanclass="lineno"> 840</span> <spanclass="comment">// implement DictionaryIterator class that would call it inside operator*().</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#l00105">time_limit.h:105</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_revised_simplex_html_a04fb52e044ec108e110796e29804cf06"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_revised_simplex.html#a04fb52e044ec108e110796e29804cf06">operations_research::glop::RevisedSimplex::GetParameters</a></div><divclass="ttdeci">const GlopParameters & GetParameters() const</div><divclass="ttdef"><b>Definition:</b><ahref="revised__simplex_8h_source.html#l00153">revised_simplex.h:153</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_revised_simplex_html_a0e35521f3d40e263173626ecc8c21b06"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_revised_simplex.html#a0e35521f3d40e263173626ecc8c21b06">operations_research::glop::RevisedSimplex::GetDualRayRowCombination</a></div><divclass="ttdeci">const DenseRow & GetDualRayRowCombination() const</div><divclass="ttdef"><b>Definition:</b><ahref="revised__simplex_8cc_source.html#l00497">revised_simplex.cc:497</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_revised_simplex_html_a26689abee13abb7fc0d0cf99c1c7809b"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_revised_simplex.html#a26689abee13abb7fc0d0cf99c1c7809b">operations_research::glop::RevisedSimplex::GetReducedCosts</a></div><divclass="ttdeci">const DenseRow & GetReducedCosts() const</div><divclass="ttdef"><b>Definition:</b><ahref="revised__simplex_8cc_source.html#l00455">revised_simplex.cc:455</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_revised_simplex_html_a3854b494976761a458a17523bb4fe5cf"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_revised_simplex.html#a3854b494976761a458a17523bb4fe5cf">operations_research::glop::RevisedSimplex::GetPrimalRay</a></div><divclass="ttdeci">const DenseRow & GetPrimalRay() const</div><divclass="ttdef"><b>Definition:</b><ahref="revised__simplex_8cc_source.html#l00488">revised_simplex.cc:488</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_revised_simplex_html_a66da73868da92948f57a83e261066ca6"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_revised_simplex.html#a66da73868da92948f57a83e261066ca6">operations_research::glop::RevisedSimplex::GetDualRay</a></div><divclass="ttdeci">const DenseColumn & GetDualRay() const</div><divclass="ttdef"><b>Definition:</b><ahref="revised__simplex_8cc_source.html#l00492">revised_simplex.cc:492</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_revised_simplex_html_a866a68af5afd0355fb348f7a59eeff9e"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_revised_simplex.html#a866a68af5afd0355fb348f7a59eeff9e">operations_research::glop::RevisedSimplex::Solve</a></div><divclass="ttdeci">ABSL_MUST_USE_RESULT Status Solve(const LinearProgram &lp, TimeLimit *time_limit)</div><divclass="ttdef"><b>Definition:</b><ahref="revised__simplex_8cc_source.html#l00135">revised_simplex.cc:135</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_revised_simplex_html_ad463af979d0c220bb473d4f8df2ec345"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_revised_simplex.html#ad463af979d0c220bb473d4f8df2ec345">operations_research::glop::RevisedSimplex::GetBasisFactorization</a></div><divclass="ttdeci">const BasisFactorization & GetBasisFactorization() const</div><divclass="ttdef"><b>Definition:</b><ahref="revised__simplex_8cc_source.html#l00504">revised_simplex.cc:504</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_revised_simplex_html_adfbae19f81ecf38f67643dc8b7dcec25"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_revised_simplex.html#adfbae19f81ecf38f67643dc8b7dcec25">operations_research::glop::RevisedSimplex::GetState</a></div><divclass="ttdeci">const BasisState & GetState() const</div><divclass="ttdef"><b>Definition:</b><ahref="revised__simplex_8cc_source.html#l00467">revised_simplex.cc:467</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_revised_simplex_html_afa85e3bd0c3e1bd18b4faf1dd36d550a"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_revised_simplex.html#afa85e3bd0c3e1bd18b4faf1dd36d550a">operations_research::glop::RevisedSimplex::GetUnitRowLeftInverse</a></div><divclass="ttdeci">const ScatteredRow & GetUnitRowLeftInverse(RowIndex row)</div><divclass="ttdef"><b>Definition:</b><ahref="revised__simplex_8h_source.html#l00223">revised_simplex.h:223</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_update_row_html_a2355c817cae2bbd316f28aea2e842761"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_update_row.html#a2355c817cae2bbd316f28aea2e842761">operations_research::glop::UpdateRow::ComputeAndGetUnitRowLeftInverse</a></div><divclass="ttdeci">const ScatteredRow & ComputeAndGetUnitRowLeftInverse(RowIndex leaving_row)</div><divclass="ttdef"><b>Definition:</b><ahref="update__row_8cc_source.html#l00056">update_row.cc:56</a></div></div>
<divclass="ttc"id="anamespaceoperations__research_html"><divclass="ttname"><ahref="namespaceoperations__research.html">operations_research</a></div><divclass="ttdoc">The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...</div><divclass="ttdef"><b>Definition:</b><ahref="dense__doubly__linked__list_8h_source.html#l00021">dense_doubly_linked_list.h:21</a></div></div>