<ahref="lp__data_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="l00015"name="l00015"></a><spanclass="lineno"> 15</span><spanclass="comment">// Storage classes for Linear Programs.</span></div>
<divclass="line"><aid="l00017"name="l00017"></a><spanclass="lineno"> 17</span><spanclass="comment">// LinearProgram stores the complete data for a Linear Program:</span></div>
<divclass="line"><aid="l00018"name="l00018"></a><spanclass="lineno"> 18</span><spanclass="comment">// - objective coefficients and offset,</span></div>
<divclass="line"><aid="l00027"name="l00027"></a><spanclass="lineno"> 27</span><spanclass="preprocessor">#include <algorithm></span><spanclass="comment">// for max</span></div>
<divclass="line"><aid="l00030"name="l00030"></a><spanclass="lineno"> 30</span><spanclass="preprocessor">#include <string></span><spanclass="comment">// for string</span></div>
<divclass="line"><aid="l00031"name="l00031"></a><spanclass="lineno"> 31</span><spanclass="preprocessor">#include <vector></span><spanclass="comment">// for vector</span></div>
<divclass="line"><aid="l00036"name="l00036"></a><spanclass="lineno"> 36</span><spanclass="preprocessor">#include "<aclass="code"href="base_2logging_8h.html">ortools/base/logging.h</a>"</span><spanclass="comment">// for CHECK*</span></div>
<divclass="line"><aid="l00037"name="l00037"></a><spanclass="lineno"> 37</span><spanclass="preprocessor">#include "<aclass="code"href="macros_8h.html">ortools/base/macros.h</a>"</span><spanclass="comment">// for DISALLOW_COPY_AND_ASSIGN, NULL</span></div>
<divclass="line"><aid="l00049"name="l00049"></a><spanclass="lineno"> 49</span><spanclass="comment">// The LinearProgram class is used to store a linear problem in a form</span></div>
<divclass="line"><aid="l00050"name="l00050"></a><spanclass="lineno"> 50</span><spanclass="comment">// accepted by LPSolver.</span></div>
<divclass="line"><aid="l00052"name="l00052"></a><spanclass="lineno"> 52</span><spanclass="comment">// In addition to the simple setter functions used to create such problems, the</span></div>
<divclass="line"><aid="l00053"name="l00053"></a><spanclass="lineno"> 53</span><spanclass="comment">// class also contains a few more advanced modification functions used primarily</span></div>
<divclass="line"><aid="l00054"name="l00054"></a><spanclass="lineno"> 54</span><spanclass="comment">// by preprocessors. A client shouldn't need to use them directly.</span></div>
<divclass="line"><aid="l00058"name="l00058"></a><spanclass="lineno"> 58</span><spanclass="comment">// The variable can take any value between and including its lower and upper</span></div>
<divclass="line"><aid="l00061"name="l00061"></a><spanclass="lineno"> 61</span><spanclass="comment">// The variable must only take integer values.</span></div>
<divclass="line"><aid="l00063"name="l00063"></a><spanclass="lineno"> 63</span><spanclass="comment">// The variable is implied integer variable i.e. it was continuous variable</span></div>
<divclass="line"><aid="l00064"name="l00064"></a><spanclass="lineno"> 64</span><spanclass="comment">// in the LP and was detected to take only integer values.</span></div>
<divclass="line"><aid="l00070"name="l00070"></a><spanclass="lineno"> 70</span><spanclass="comment">// Clears, i.e. reset the object to its initial value.</span></div>
<divclass="line"><aid="l00077"name="l00077"></a><spanclass="lineno"> 77</span><spanclass="comment">// Creates a new variable and returns its index.</span></div>
<divclass="line"><aid="l00078"name="l00078"></a><spanclass="lineno"> 78</span><spanclass="comment">// By default, the column bounds will be [0, infinity).</span></div>
<divclass="line"><aid="l00081"name="l00081"></a><spanclass="lineno"> 81</span><spanclass="comment">// Creates a new slack variable and returns its index. Do not use this method</span></div>
<divclass="line"><aid="l00082"name="l00082"></a><spanclass="lineno"> 82</span><spanclass="comment">// to create non-slack variables.</span></div>
<divclass="line"><aid="l00088"name="l00088"></a><spanclass="lineno"> 88</span><spanclass="comment">// Creates a new constraint and returns its index.</span></div>
<divclass="line"><aid="l00089"name="l00089"></a><spanclass="lineno"> 89</span><spanclass="comment">// By default, the constraint bounds will be [0, 0].</span></div>
<divclass="line"><aid="l00092"name="l00092"></a><spanclass="lineno"> 92</span><spanclass="comment">// Same as CreateNewVariable() or CreateNewConstraint() but also assign an</span></div>
<divclass="line"><aid="l00093"name="l00093"></a><spanclass="lineno"> 93</span><spanclass="comment">// immutable id to the variable or constraint so they can be retrieved later.</span></div>
<divclass="line"><aid="l00094"name="l00094"></a><spanclass="lineno"> 94</span><spanclass="comment">// By default, the name is also set to this id, but it can be changed later</span></div>
<divclass="line"><aid="l00095"name="l00095"></a><spanclass="lineno"> 95</span><spanclass="comment">// without changing the id.</span></div>
<divclass="line"><aid="l00097"name="l00097"></a><spanclass="lineno"> 97</span><spanclass="comment">// Note that these ids are NOT copied over by the Populate*() functions.</span></div>
<divclass="line"><aid="l00099"name="l00099"></a><spanclass="lineno"> 99</span><spanclass="comment">// TODO(user): Move these and the two corresponding hash_table into a new</span></div>
<divclass="line"><aid="l00100"name="l00100"></a><spanclass="lineno"> 100</span><spanclass="comment">// LinearProgramBuilder class to simplify the code of some functions like</span></div>
<divclass="line"><aid="l00101"name="l00101"></a><spanclass="lineno"> 101</span><spanclass="comment">// DeleteColumns() here and make the behavior on copy clear? or simply remove</span></div>
<divclass="line"><aid="l00102"name="l00102"></a><spanclass="lineno"> 102</span><spanclass="comment">// them as it is almost as easy to maintain a hash_table on the client side.</span></div>
<divclass="line"><aid="l00106"name="l00106"></a><spanclass="lineno"> 106</span><spanclass="comment">// Functions to set the name of a variable or constraint. Note that you</span></div>
<divclass="line"><aid="l00107"name="l00107"></a><spanclass="lineno"> 107</span><spanclass="comment">// won't be able to find those named variables/constraints with</span></div>
<divclass="line"><aid="l00109"name="l00109"></a><spanclass="lineno"> 109</span><spanclass="comment">// TODO(user): Add PopulateIdsFromNames() so names added via</span></div>
<divclass="line"><aid="l00110"name="l00110"></a><spanclass="lineno"> 110</span><spanclass="comment">// Set{Variable|Constraint}Name() can be found.</span></div>
<divclass="line"><aid="l00117"name="l00117"></a><spanclass="lineno"> 117</span><spanclass="comment">// Returns whether the variable at column col is constrained to be integer.</span></div>
<divclass="line"><aid="l00120"name="l00120"></a><spanclass="lineno"> 120</span><spanclass="comment">// Returns whether the variable at column col must take binary values or not.</span></div>
<divclass="line"><aid="l00123"name="l00123"></a><spanclass="lineno"> 123</span><spanclass="comment">// Defines lower and upper bounds for the variable at col. Note that the</span></div>
<divclass="line"><aid="l00124"name="l00124"></a><spanclass="lineno"> 124</span><spanclass="comment">// bounds may be set to +/- infinity. The variable must have been created</span></div>
<divclass="line"><aid="l00125"name="l00125"></a><spanclass="lineno"> 125</span><spanclass="comment">// before or this will crash in non-debug mode.</span></div>
<divclass="line"><aid="l00129"name="l00129"></a><spanclass="lineno"> 129</span><spanclass="comment">// Defines lower and upper bounds for the constraint at row. Note that the</span></div>
<divclass="line"><aid="l00130"name="l00130"></a><spanclass="lineno"> 130</span><spanclass="comment">// bounds may be set to +/- infinity. If the constraint wasn't created before,</span></div>
<divclass="line"><aid="l00131"name="l00131"></a><spanclass="lineno"> 131</span><spanclass="comment">// all the rows from the current GetNumberOfRows() to the given row will be</span></div>
<divclass="line"><aid="l00132"name="l00132"></a><spanclass="lineno"> 132</span><spanclass="comment">// created with a range [0,0].</span></div>
<divclass="line"><aid="l00136"name="l00136"></a><spanclass="lineno"> 136</span><spanclass="comment">// Defines the coefficient for col / row.</span></div>
<divclass="line"><aid="l00139"name="l00139"></a><spanclass="lineno"> 139</span><spanclass="comment">// Defines the objective coefficient of column col.</span></div>
<divclass="line"><aid="l00140"name="l00140"></a><spanclass="lineno"> 140</span><spanclass="comment">// It is set to 0.0 by default.</span></div>
<divclass="line"><aid="l00143"name="l00143"></a><spanclass="lineno"> 143</span><spanclass="comment">// Define the objective offset (0.0 by default) and scaling factor (positive</span></div>
<divclass="line"><aid="l00144"name="l00144"></a><spanclass="lineno"> 144</span><spanclass="comment">// and equal to 1.0 by default). This is mainly used for displaying purpose</span></div>
<divclass="line"><aid="l00145"name="l00145"></a><spanclass="lineno"> 145</span><spanclass="comment">// and the real objective is factor * (objective + offset).</span></div>
<divclass="line"><aid="l00149"name="l00149"></a><spanclass="lineno"> 149</span><spanclass="comment">// Defines the optimization direction. When maximize is true (resp. false),</span></div>
<divclass="line"><aid="l00150"name="l00150"></a><spanclass="lineno"> 150</span><spanclass="comment">// the objective is maximized (resp. minimized). The default is false.</span></div>
<divclass="line"><aid="l00153"name="l00153"></a><spanclass="lineno"> 153</span><spanclass="comment">// Calls CleanUp() on each columns.</span></div>
<divclass="line"><aid="l00154"name="l00154"></a><spanclass="lineno"> 154</span><spanclass="comment">// That is, removes duplicates, zeros, and orders the coefficients by row.</span></div>
<divclass="line"><aid="l00157"name="l00157"></a><spanclass="lineno"> 157</span><spanclass="comment">// Returns true if all the columns are ordered by rows and contain no</span></div>
<divclass="line"><aid="l00158"name="l00158"></a><spanclass="lineno"> 158</span><spanclass="comment">// duplicates or zero entries (i.e. if IsCleanedUp() is true for all columns).</span></div>
<divclass="line"><aid="l00161"name="l00161"></a><spanclass="lineno"> 161</span><spanclass="comment">// Functions that return the name of a variable or constraint. If the name is</span></div>
<divclass="line"><aid="l00162"name="l00162"></a><spanclass="lineno"> 162</span><spanclass="comment">// empty, they return a special name that depends on the index.</span></div>
<divclass="line"><aid="l00169"name="l00169"></a><spanclass="lineno"> 169</span><spanclass="comment">// Returns true (resp. false) when the problem is a maximization</span></div>
<divclass="line"><aid="l00173"name="l00173"></a><spanclass="lineno"> 173</span><spanclass="comment">// Returns the underlying SparseMatrix or its transpose (which may need to be</span></div>
<divclass="line"><aid="l00178"name="l00178"></a><spanclass="lineno"> 178</span><spanclass="comment">// Some transformations are better done on the transpose representation. These</span></div>
<divclass="line"><aid="l00179"name="l00179"></a><spanclass="lineno"> 179</span><spanclass="comment">// two functions are here for that. Note that calling the first function and</span></div>
<divclass="line"><aid="l00180"name="l00180"></a><spanclass="lineno"> 180</span><spanclass="comment">// modifying the matrix does not change the result of any function in this</span></div>
<divclass="line"><aid="l00181"name="l00181"></a><spanclass="lineno"> 181</span><spanclass="comment">// class until UseTransposeMatrixAsReference() is called. This is because the</span></div>
<divclass="line"><aid="l00182"name="l00182"></a><spanclass="lineno"> 182</span><spanclass="comment">// transpose matrix is only used by GetTransposeSparseMatrix() and this</span></div>
<divclass="line"><aid="l00183"name="l00183"></a><spanclass="lineno"> 183</span><spanclass="comment">// function will recompute the whole transpose from the matrix. In particular,</span></div>
<divclass="line"><aid="l00184"name="l00184"></a><spanclass="lineno"> 184</span><spanclass="comment">// do not call GetTransposeSparseMatrix() while you modify the matrix returned</span></div>
<divclass="line"><aid="l00185"name="l00185"></a><spanclass="lineno"> 185</span><spanclass="comment">// by GetMutableTransposeSparseMatrix() otherwise all your changes will be</span></div>
<divclass="line"><aid="l00188"name="l00188"></a><spanclass="lineno"> 188</span><spanclass="comment">// IMPORTANT: The matrix dimension cannot change. Otherwise this will cause</span></div>
<divclass="line"><aid="l00189"name="l00189"></a><spanclass="lineno"> 189</span><spanclass="comment">// problems. This is checked in debug mode when calling</span></div>
<divclass="line"><aid="l00194"name="l00194"></a><spanclass="lineno"> 194</span><spanclass="comment">// Release the memory used by the transpose matrix.</span></div>
<divclass="line"><aid="l00197"name="l00197"></a><spanclass="lineno"> 197</span><spanclass="comment">// Gets the underlying SparseColumn with the given index.</span></div>
<divclass="line"><aid="l00198"name="l00198"></a><spanclass="lineno"> 198</span><spanclass="comment">// This is the same as GetSparseMatrix().column(col);</span></div>
<divclass="line"><aid="l00201"name="l00201"></a><spanclass="lineno"> 201</span><spanclass="comment">// Gets a pointer to the underlying SparseColumn with the given index.</span></div>
<divclass="line"><aid="l00210"name="l00210"></a><spanclass="lineno"> 210</span><spanclass="comment">// Returns the number of entries in the linear program matrix.</span></div>
<divclass="line"><aid="l00213"name="l00213"></a><spanclass="lineno"> 213</span><spanclass="comment">// Return the lower bounds (resp. upper bounds) of constraints as a column</span></div>
<divclass="line"><aid="l00214"name="l00214"></a><spanclass="lineno"> 214</span><spanclass="comment">// vector. Note that the bound values may be +/- infinity.</span></div>
<divclass="line"><aid="l00222"name="l00222"></a><spanclass="lineno"> 222</span><spanclass="comment">// Returns the objective coefficients (or cost) of variables as a row vector.</span></div>
<divclass="line"><aid="l00227"name="l00227"></a><spanclass="lineno"> 227</span><spanclass="comment">// Return the lower bounds (resp. upper bounds) of variables as a row vector.</span></div>
<divclass="line"><aid="l00228"name="l00228"></a><spanclass="lineno"> 228</span><spanclass="comment">// Note that the bound values may be +/- infinity.</span></div>
<divclass="line"><aid="l00236"name="l00236"></a><spanclass="lineno"> 236</span><spanclass="comment">// Returns a row vector of VariableType representing types of variables.</span></div>
<divclass="line"><aid="l00241"name="l00241"></a><spanclass="lineno"> 241</span><spanclass="comment">// Returns a list (technically a vector) of the ColIndices of the integer</span></div>
<divclass="line"><aid="l00242"name="l00242"></a><spanclass="lineno"> 242</span><spanclass="comment">// variables. This vector is lazily computed.</span></div>
<divclass="line"><aid="l00245"name="l00245"></a><spanclass="lineno"> 245</span><spanclass="comment">// Returns a list (technically a vector) of the ColIndices of the binary</span></div>
<divclass="line"><aid="l00246"name="l00246"></a><spanclass="lineno"> 246</span><spanclass="comment">// integer variables. This vector is lazily computed.</span></div>
<divclass="line"><aid="l00249"name="l00249"></a><spanclass="lineno"> 249</span><spanclass="comment">// Returns a list (technically a vector) of the ColIndices of the non-binary</span></div>
<divclass="line"><aid="l00250"name="l00250"></a><spanclass="lineno"> 250</span><spanclass="comment">// integer variables. This vector is lazily computed.</span></div>
<divclass="line"><aid="l00253"name="l00253"></a><spanclass="lineno"> 253</span><spanclass="comment">// Returns the objective coefficient (or cost) of the given variable for the</span></div>
<divclass="line"><aid="l00254"name="l00254"></a><spanclass="lineno"> 254</span><spanclass="comment">// minimization version of the problem. That is, this is the same as</span></div>
<divclass="line"><aid="l00255"name="l00255"></a><spanclass="lineno"> 255</span><spanclass="comment">// GetObjectiveCoefficient() for a minimization problem and the opposite for a</span></div>
<divclass="line"><aid="l00259"name="l00259"></a><spanclass="lineno"> 259</span><spanclass="comment">// Returns the objective offset and scaling factor.</span></div>
<divclass="line"><aid="l00265"name="l00265"></a><spanclass="lineno"> 265</span><spanclass="comment">// Checks if each variable respects its bounds, nothing else.</span></div>
<divclass="line"><aid="l00269"name="l00269"></a><spanclass="lineno"> 269</span><spanclass="comment">// Tests if the solution is LP-feasible within the given tolerance,</span></div>
<divclass="line"><aid="l00270"name="l00270"></a><spanclass="lineno"> 270</span><spanclass="comment">// i.e., satisfies all linear constraints within the absolute tolerance level.</span></div>
<divclass="line"><aid="l00271"name="l00271"></a><spanclass="lineno"> 271</span><spanclass="comment">// The solution does not need to satisfy the integer constraints.</span></div>
<divclass="line"><aid="l00275"name="l00275"></a><spanclass="lineno"> 275</span><spanclass="comment">// Tests if the solution is integer within the given tolerance, i.e., all</span></div>
<divclass="line"><aid="l00276"name="l00276"></a><spanclass="lineno"> 276</span><spanclass="comment">// integer variables have integer values within the absolute tolerance level.</span></div>
<divclass="line"><aid="l00277"name="l00277"></a><spanclass="lineno"> 277</span><spanclass="comment">// The solution does not need to satisfy the linear constraints.</span></div>
<divclass="line"><aid="l00281"name="l00281"></a><spanclass="lineno"> 281</span><spanclass="comment">// Tests if the solution is both LP-feasible and integer within the tolerance.</span></div>
<divclass="line"><aid="l00285"name="l00285"></a><spanclass="lineno"> 285</span><spanclass="comment">// Fills the value of the slack from the other variable values.</span></div>
<divclass="line"><aid="l00286"name="l00286"></a><spanclass="lineno"> 286</span><spanclass="comment">// This requires that the slack have been added.</span></div>
<divclass="line"><aid="l00289"name="l00289"></a><spanclass="lineno"> 289</span><spanclass="comment">// Functions to translate the sum(solution * objective_coefficients()) to</span></div>
<divclass="line"><aid="l00290"name="l00290"></a><spanclass="lineno"> 290</span><spanclass="comment">// the real objective of the problem and back. Note that these can also</span></div>
<divclass="line"><aid="l00291"name="l00291"></a><spanclass="lineno"> 291</span><spanclass="comment">// be used to translate bounds of the objective in the same way.</span></div>
<divclass="line"><aid="l00295"name="l00295"></a><spanclass="lineno"> 295</span><spanclass="comment">// A short string with the problem dimension.</span></div>
<divclass="line"><aid="l00298"name="l00298"></a><spanclass="lineno"> 298</span><spanclass="comment">// A short line with some stats on the problem coefficients.</span></div>
<divclass="line"><aid="l00302"name="l00302"></a><spanclass="lineno"> 302</span><spanclass="comment">// Returns a stringified LinearProgram. We use the LP file format used by</span></div>
<divclass="line"><aid="l00303"name="l00303"></a><spanclass="lineno"> 303</span><spanclass="comment">// lp_solve (see http://lpsolve.sourceforge.net/5.1/index.htm).</span></div>
<divclass="line"><aid="l00306"name="l00306"></a><spanclass="lineno"> 306</span><spanclass="comment">// Returns a string that contains the provided solution of the LP in the</span></div>
<divclass="line"><aid="l00307"name="l00307"></a><spanclass="lineno"> 307</span><spanclass="comment">// format var1 = X, var2 = Y, var3 = Z, ...</span></div>
<divclass="line"><aid="l00310"name="l00310"></a><spanclass="lineno"> 310</span><spanclass="comment">// Returns a comma-separated string of integers containing (in that order)</span></div>
<divclass="line"><aid="l00316"name="l00316"></a><spanclass="lineno"> 316</span><spanclass="comment">// Very useful for reporting in the way used in journal articles.</span></div>
<divclass="line"><aid="l00319"name="l00319"></a><spanclass="lineno"> 319</span><spanclass="comment">// Returns a string containing the same information as with GetProblemStats(),</span></div>
<divclass="line"><aid="l00320"name="l00320"></a><spanclass="lineno"> 320</span><spanclass="comment">// but in a much more human-readable form, for example:</span></div>
<divclass="line"><aid="l00321"name="l00321"></a><spanclass="lineno"> 321</span><spanclass="comment">// Number of rows : 27</span></div>
<divclass="line"><aid="l00322"name="l00322"></a><spanclass="lineno"> 322</span><spanclass="comment">// Number of variables in file : 32</span></div>
<divclass="line"><aid="l00323"name="l00323"></a><spanclass="lineno"> 323</span><spanclass="comment">// Number of entries (non-zeros) : 83</span></div>
<divclass="line"><aid="l00324"name="l00324"></a><spanclass="lineno"> 324</span><spanclass="comment">// Number of entries in the objective : 5</span></div>
<divclass="line"><aid="l00325"name="l00325"></a><spanclass="lineno"> 325</span><spanclass="comment">// Number of entries in the right-hand side : 7</span></div>
<divclass="line"><aid="l00326"name="l00326"></a><spanclass="lineno"> 326</span><spanclass="comment">// Number of <= constraints : 19</span></div>
<divclass="line"><aid="l00327"name="l00327"></a><spanclass="lineno"> 327</span><spanclass="comment">// Number of >= constraints : 0</span></div>
<divclass="line"><aid="l00328"name="l00328"></a><spanclass="lineno"> 328</span><spanclass="comment">// Number of = constraints : 8</span></div>
<divclass="line"><aid="l00329"name="l00329"></a><spanclass="lineno"> 329</span><spanclass="comment">// Number of range constraints : 0</span></div>
<divclass="line"><aid="l00330"name="l00330"></a><spanclass="lineno"> 330</span><spanclass="comment">// Number of non-negative variables : 32</span></div>
<divclass="line"><aid="l00331"name="l00331"></a><spanclass="lineno"> 331</span><spanclass="comment">// Number of boxed variables : 0</span></div>
<divclass="line"><aid="l00332"name="l00332"></a><spanclass="lineno"> 332</span><spanclass="comment">// Number of free variables : 0</span></div>
<divclass="line"><aid="l00333"name="l00333"></a><spanclass="lineno"> 333</span><spanclass="comment">// Number of fixed variables : 0</span></div>
<divclass="line"><aid="l00334"name="l00334"></a><spanclass="lineno"> 334</span><spanclass="comment">// Number of other variables : 0</span></div>
<divclass="line"><aid="l00337"name="l00337"></a><spanclass="lineno"> 337</span><spanclass="comment">// Returns a comma-separated string of numbers containing (in that order)</span></div>
<divclass="line"><aid="l00338"name="l00338"></a><spanclass="lineno"> 338</span><spanclass="comment">// fill rate, max number of entries (length) in a row, average row length,</span></div>
<divclass="line"><aid="l00339"name="l00339"></a><spanclass="lineno"> 339</span><spanclass="comment">// standard deviation of row length, max column length, average column length,</span></div>
<divclass="line"><aid="l00340"name="l00340"></a><spanclass="lineno"> 340</span><spanclass="comment">// standard deviation of column length</span></div>
<divclass="line"><aid="l00341"name="l00341"></a><spanclass="lineno"> 341</span><spanclass="comment">// Useful for profiling algorithms.</span></div>
<divclass="line"><aid="l00343"name="l00343"></a><spanclass="lineno"> 343</span><spanclass="comment">// TODO(user): Theses are statistics about the underlying matrix and should be</span></div>
<divclass="line"><aid="l00344"name="l00344"></a><spanclass="lineno"> 344</span><spanclass="comment">// moved to SparseMatrix.</span></div>
<divclass="line"><aid="l00347"name="l00347"></a><spanclass="lineno"> 347</span><spanclass="comment">// Returns a string containing the same information as with GetNonZeroStats(),</span></div>
<divclass="line"><aid="l00348"name="l00348"></a><spanclass="lineno"> 348</span><spanclass="comment">// but in a much more human-readable form, for example:</span></div>
<divclass="line"><aid="l00349"name="l00349"></a><spanclass="lineno"> 349</span><spanclass="comment">// Fill rate : 9.61%</span></div>
<divclass="line"><aid="l00350"name="l00350"></a><spanclass="lineno"> 350</span><spanclass="comment">// Entries in row (Max / average / std, dev.) : 9 / 3.07 / 1.94</span></div>
<divclass="line"><aid="l00351"name="l00351"></a><spanclass="lineno"> 351</span><spanclass="comment">// Entries in column (Max / average / std, dev.): 4 / 2.59 / 0.96</span></div>
<divclass="line"><aid="l00354"name="l00354"></a><spanclass="lineno"> 354</span><spanclass="comment">// Adds slack variables to the problem for all rows which don't have slack</span></div>
<divclass="line"><aid="l00355"name="l00355"></a><spanclass="lineno"> 355</span><spanclass="comment">// variables. The new slack variables have bounds set to opposite of the</span></div>
<divclass="line"><aid="l00356"name="l00356"></a><spanclass="lineno"> 356</span><spanclass="comment">// bounds of the corresponding constraint, and changes all constraints to</span></div>
<divclass="line"><aid="l00357"name="l00357"></a><spanclass="lineno"> 357</span><spanclass="comment">// equality constraints with both bounds set to 0.0. If a constraint uses only</span></div>
<divclass="line"><aid="l00358"name="l00358"></a><spanclass="lineno"> 358</span><spanclass="comment">// integer variables and all their coefficients are integer, it will mark the</span></div>
<divclass="line"><aid="l00359"name="l00359"></a><spanclass="lineno"> 359</span><spanclass="comment">// slack variable as integer too.</span></div>
<divclass="line"><aid="l00361"name="l00361"></a><spanclass="lineno"> 361</span><spanclass="comment">// It is an error to call CreateNewVariable() or CreateNewConstraint() on a</span></div>
<divclass="line"><aid="l00362"name="l00362"></a><spanclass="lineno"> 362</span><spanclass="comment">// linear program on which this method was called.</span></div>
<divclass="line"><aid="l00364"name="l00364"></a><spanclass="lineno"> 364</span><spanclass="comment">// Note that many of the slack variables may not be useful at all, but in</span></div>
<divclass="line"><aid="l00365"name="l00365"></a><spanclass="lineno"> 365</span><spanclass="comment">// order not to recompute the matrix from one Solve() to the next, we always</span></div>
<divclass="line"><aid="l00366"name="l00366"></a><spanclass="lineno"> 366</span><spanclass="comment">// include all of them for a given lp matrix.</span></div>
<divclass="line"><aid="l00368"name="l00368"></a><spanclass="lineno"> 368</span><spanclass="comment">// TODO(user): investigate the impact on the running time. It seems low</span></div>
<divclass="line"><aid="l00369"name="l00369"></a><spanclass="lineno"> 369</span><spanclass="comment">// because we almost never iterate on fixed variables.</span></div>
<divclass="line"><aid="l00372"name="l00372"></a><spanclass="lineno"> 372</span><spanclass="comment">// Returns the index of the first slack variable in the linear program.</span></div>
<divclass="line"><aid="l00373"name="l00373"></a><spanclass="lineno"> 373</span><spanclass="comment">// Returns kInvalidCol if slack variables were not injected into the problem</span></div>
<divclass="line"><aid="l00377"name="l00377"></a><spanclass="lineno"> 377</span><spanclass="comment">// Returns the index of the slack variable corresponding to the given</span></div>
<divclass="line"><aid="l00378"name="l00378"></a><spanclass="lineno"> 378</span><spanclass="comment">// constraint. Returns kInvalidCol if slack variables were not injected into</span></div>
<divclass="line"><aid="l00379"name="l00379"></a><spanclass="lineno"> 379</span><spanclass="comment">// the problem yet.</span></div>
<divclass="line"><aid="l00382"name="l00382"></a><spanclass="lineno"> 382</span><spanclass="comment">// Populates the calling object with the dual of the LinearProgram passed as</span></div>
<divclass="line"><aid="l00384"name="l00384"></a><spanclass="lineno"> 384</span><spanclass="comment">// For the general form that we solve,</span></div>
<divclass="line"><aid="l00385"name="l00385"></a><spanclass="lineno"> 385</span><spanclass="comment">// min c.x</span></div>
<divclass="line"><aid="l00386"name="l00386"></a><spanclass="lineno"> 386</span><spanclass="comment">// s.t. A_1 x = b_1</span></div>
<divclass="line"><aid="l00387"name="l00387"></a><spanclass="lineno"> 387</span><spanclass="comment">// A_2 x <= b_2</span></div>
<divclass="line"><aid="l00388"name="l00388"></a><spanclass="lineno"> 388</span><spanclass="comment">// A_3 x >= b_3</span></div>
<divclass="line"><aid="l00389"name="l00389"></a><spanclass="lineno"> 389</span><spanclass="comment">// l <= x <= u</span></div>
<divclass="line"><aid="l00390"name="l00390"></a><spanclass="lineno"> 390</span><spanclass="comment">// With x: n-column of unknowns</span></div>
<divclass="line"><aid="l00391"name="l00391"></a><spanclass="lineno"> 391</span><spanclass="comment">// l,u: n-columns of bound coefficients</span></div>
<divclass="line"><aid="l00392"name="l00392"></a><spanclass="lineno"> 392</span><spanclass="comment">// c: n-row of cost coefficients</span></div>
<divclass="line"><aid="l00393"name="l00393"></a><spanclass="lineno"> 393</span><spanclass="comment">// A_i: m_i×n-matrix of coefficients</span></div>
<divclass="line"><aid="l00394"name="l00394"></a><spanclass="lineno"> 394</span><spanclass="comment">// b_i: m_i-column of right-hand side coefficients</span></div>
<divclass="line"><aid="l00405"name="l00405"></a><spanclass="lineno"> 405</span><spanclass="comment">// If range constraints are present, each of the corresponding row is</span></div>
<divclass="line"><aid="l00406"name="l00406"></a><spanclass="lineno"> 406</span><spanclass="comment">// duplicated (with one becoming lower bounded and the other upper bounded).</span></div>
<divclass="line"><aid="l00407"name="l00407"></a><spanclass="lineno"> 407</span><spanclass="comment">// For such ranged row in the primal, duplicated_rows[row] is set to the</span></div>
<divclass="line"><aid="l00408"name="l00408"></a><spanclass="lineno"> 408</span><spanclass="comment">// column index in the dual of the corresponding column duplicate. For</span></div>
<divclass="line"><aid="l00409"name="l00409"></a><spanclass="lineno"> 409</span><spanclass="comment">// non-ranged row, duplicated_rows[row] is set to kInvalidCol.</span></div>
<divclass="line"><aid="l00411"name="l00411"></a><spanclass="lineno"> 411</span><spanclass="comment">// IMPORTANT: The linear_program argument must not have any free constraints.</span></div>
<divclass="line"><aid="l00413"name="l00413"></a><spanclass="lineno"> 413</span><spanclass="comment">// IMPORTANT: This function always interprets the argument in its minimization</span></div>
<divclass="line"><aid="l00414"name="l00414"></a><spanclass="lineno"> 414</span><spanclass="comment">// form. So the dual solution of the dual needs to be negated if we want to</span></div>
<divclass="line"><aid="l00415"name="l00415"></a><spanclass="lineno"> 415</span><spanclass="comment">// compute the solution of a maximization problem given as an argument.</span></div>
<divclass="line"><aid="l00417"name="l00417"></a><spanclass="lineno"> 417</span><spanclass="comment">// TODO(user): Do not interpret as a minimization problem?</span></div>
<divclass="line"><aid="l00421"name="l00421"></a><spanclass="lineno"> 421</span><spanclass="comment">// Populates the calling object with the given LinearProgram.</span></div>
<divclass="line"><aid="l00424"name="l00424"></a><spanclass="lineno"> 424</span><spanclass="comment">// Populates the calling object with the given LinearProgram while permuting</span></div>
<divclass="line"><aid="l00425"name="l00425"></a><spanclass="lineno"> 425</span><spanclass="comment">// variables and constraints. This is useful mainly for testing to generate</span></div>
<divclass="line"><aid="l00426"name="l00426"></a><spanclass="lineno"> 426</span><spanclass="comment">// a model with the same optimal objective value.</span></div>
<divclass="line"><aid="l00431"name="l00431"></a><spanclass="lineno"> 431</span><spanclass="comment">// Populates the calling object with the variables of the given LinearProgram.</span></div>
<divclass="line"><aid="l00432"name="l00432"></a><spanclass="lineno"> 432</span><spanclass="comment">// The function preserves the bounds, the integrality, the names of the</span></div>
<divclass="line"><aid="l00433"name="l00433"></a><spanclass="lineno"> 433</span><spanclass="comment">// variables and their objective coefficients. No constraints are copied (the</span></div>
<divclass="line"><aid="l00434"name="l00434"></a><spanclass="lineno"> 434</span><spanclass="comment">// matrix in the destination has 0 rows).</span></div>
<divclass="line"><aid="l00437"name="l00437"></a><spanclass="lineno"> 437</span><spanclass="comment">// Adds constraints to the linear program. The constraints are specified using</span></div>
<divclass="line"><aid="l00438"name="l00438"></a><spanclass="lineno"> 438</span><spanclass="comment">// a sparse matrix of the coefficients, and vectors that represent the</span></div>
<divclass="line"><aid="l00439"name="l00439"></a><spanclass="lineno"> 439</span><spanclass="comment">// left-hand side and the right-hand side of the constraints, i.e.</span></div>
<divclass="line"><aid="l00441"name="l00441"></a><spanclass="lineno"> 441</span><spanclass="comment">// The sizes of the columns and the names must be the same as the number of</span></div>
<divclass="line"><aid="l00442"name="l00442"></a><spanclass="lineno"> 442</span><spanclass="comment">// rows of the sparse matrix; the number of columns of the matrix must be</span></div>
<divclass="line"><aid="l00443"name="l00443"></a><spanclass="lineno"> 443</span><spanclass="comment">// equal to the number of variables of the linear program.</span></div>
<divclass="line"><aid="l00449"name="l00449"></a><spanclass="lineno"> 449</span><spanclass="comment">// Calls the AddConstraints method. After adding the constraints it adds slack</span></div>
<divclass="line"><aid="l00450"name="l00450"></a><spanclass="lineno"> 450</span><spanclass="comment">// variables to the constraints.</span></div>
<divclass="line"><aid="l00457"name="l00457"></a><spanclass="lineno"> 457</span><spanclass="comment">// Swaps the content of this LinearProgram with the one passed as argument.</span></div>
<divclass="line"><aid="l00458"name="l00458"></a><spanclass="lineno"> 458</span><spanclass="comment">// Works in O(1).</span></div>
<divclass="line"><aid="l00461"name="l00461"></a><spanclass="lineno"> 461</span><spanclass="comment">// Removes the given column indices from the LinearProgram.</span></div>
<divclass="line"><aid="l00462"name="l00462"></a><spanclass="lineno"> 462</span><spanclass="comment">// This needs to allocate O(num_variables) memory to update variable_table_.</span></div>
<divclass="line"><aid="l00465"name="l00465"></a><spanclass="lineno"> 465</span><spanclass="comment">// Removes slack variables from the linear program. The method restores the</span></div>
<divclass="line"><aid="l00466"name="l00466"></a><spanclass="lineno"> 466</span><spanclass="comment">// bounds on constraints from the bounds of the slack variables, resets the</span></div>
<divclass="line"><aid="l00467"name="l00467"></a><spanclass="lineno"> 467</span><spanclass="comment">// index of the first slack variable, and removes the relevant columns from</span></div>
<divclass="line"><aid="l00468"name="l00468"></a><spanclass="lineno"> 468</span><spanclass="comment">// the matrix.</span></div>
<divclass="line"><aid="l00471"name="l00471"></a><spanclass="lineno"> 471</span><spanclass="comment">// Scales the problem using the given scaler.</span></div>
<divclass="line"><aid="l00474"name="l00474"></a><spanclass="lineno"> 474</span><spanclass="comment">// While Scale() makes sure the coefficients inside the linear program matrix</span></div>
<divclass="line"><aid="l00475"name="l00475"></a><spanclass="lineno"> 475</span><spanclass="comment">// are in [-1, 1], the objective coefficients, variable bounds and constraint</span></div>
<divclass="line"><aid="l00476"name="l00476"></a><spanclass="lineno"> 476</span><spanclass="comment">// bounds can still take large values (originally or due to the matrix</span></div>
<divclass="line"><aid="l00479"name="l00479"></a><spanclass="lineno"> 479</span><spanclass="comment">// It makes a lot of sense to also scale them given that internally we use</span></div>
<divclass="line"><aid="l00480"name="l00480"></a><spanclass="lineno"> 480</span><spanclass="comment">// absolute tolerances, and that it is nice to have the same behavior if users</span></div>
<divclass="line"><aid="l00481"name="l00481"></a><spanclass="lineno"> 481</span><spanclass="comment">// scale their problems. For instance one could change the unit of ALL the</span></div>
<divclass="line"><aid="l00482"name="l00482"></a><spanclass="lineno"> 482</span><spanclass="comment">// variables from Bytes to MBytes if they denote memory quantities. Or express</span></div>
<divclass="line"><aid="l00483"name="l00483"></a><spanclass="lineno"> 483</span><spanclass="comment">// a cost in dollars instead of thousands of dollars.</span></div>
<divclass="line"><aid="l00485"name="l00485"></a><spanclass="lineno"> 485</span><spanclass="comment">// Here, we are quite prudent and just make sure that the range of the</span></div>
<divclass="line"><aid="l00486"name="l00486"></a><spanclass="lineno"> 486</span><spanclass="comment">// non-zeros magnitudes contains one. So for instance if all non-zeros costs</span></div>
<divclass="line"><aid="l00487"name="l00487"></a><spanclass="lineno"> 487</span><spanclass="comment">// are in [1e4, 1e6], we will divide them by 1e4 so that the new range is</span></div>
<divclass="line"><aid="l00490"name="l00490"></a><spanclass="lineno"> 490</span><spanclass="comment">// TODO(user): Another more aggressive idea is to set the median/mean/geomean</span></div>
<divclass="line"><aid="l00491"name="l00491"></a><spanclass="lineno"> 491</span><spanclass="comment">// of the magnitudes to one. Investigate if this leads to better results. It</span></div>
<divclass="line"><aid="l00492"name="l00492"></a><spanclass="lineno"> 492</span><spanclass="comment">// does look more robust.</span></div>
<divclass="line"><aid="l00494"name="l00494"></a><spanclass="lineno"> 494</span><spanclass="comment">// Both functions update objective_scaling_factor()/objective_offset() and</span></div>
<divclass="line"><aid="l00495"name="l00495"></a><spanclass="lineno"> 495</span><spanclass="comment">// return the scaling coefficient so that:</span></div>
<divclass="line"><aid="l00496"name="l00496"></a><spanclass="lineno"> 496</span><spanclass="comment">// - For ScaleObjective(), the old coefficients can be retrieved by</span></div>
<divclass="line"><aid="l00497"name="l00497"></a><spanclass="lineno"> 497</span><spanclass="comment">// multiplying the new ones by the returned factor.</span></div>
<divclass="line"><aid="l00498"name="l00498"></a><spanclass="lineno"> 498</span><spanclass="comment">// - For ScaleBounds(), the old variable and constraint bounds can be</span></div>
<divclass="line"><aid="l00499"name="l00499"></a><spanclass="lineno"> 499</span><spanclass="comment">// retrieved by multiplying the new ones by the returned factor.</span></div>
<divclass="line"><aid="l00503"name="l00503"></a><spanclass="lineno"> 503</span><spanclass="comment">// Removes the given row indices from the LinearProgram.</span></div>
<divclass="line"><aid="l00504"name="l00504"></a><spanclass="lineno"> 504</span><spanclass="comment">// This needs to allocate O(num_variables) memory.</span></div>
<divclass="line"><aid="l00507"name="l00507"></a><spanclass="lineno"> 507</span><spanclass="comment">// Does basic checking on the linear program:</span></div>
<divclass="line"><aid="l00508"name="l00508"></a><spanclass="lineno"> 508</span><spanclass="comment">// - returns false if some coefficient are NaNs.</span></div>
<divclass="line"><aid="l00509"name="l00509"></a><spanclass="lineno"> 509</span><spanclass="comment">// - returns false if some coefficient other than the bounds are +/- infinity.</span></div>
<divclass="line"><aid="l00510"name="l00510"></a><spanclass="lineno"> 510</span><spanclass="comment">// Note that these conditions are also guarded by DCHECK on each of the</span></div>
<divclass="line"><aid="l00511"name="l00511"></a><spanclass="lineno"> 511</span><spanclass="comment">// SetXXX() function above.</span></div>
<divclass="line"><aid="l00513"name="l00513"></a><spanclass="lineno"> 513</span><spanclass="comment">// This also returns false if any finite value has a magnitude larger than</span></div>
<divclass="line"><aid="l00514"name="l00514"></a><spanclass="lineno"> 514</span><spanclass="comment">// the given threshold.</span></div>
<divclass="line"><aid="l00517"name="l00517"></a><spanclass="lineno"> 517</span><spanclass="comment">// Updates the bounds of the variables to the intersection of their original</span></div>
<divclass="line"><aid="l00518"name="l00518"></a><spanclass="lineno"> 518</span><spanclass="comment">// bounds and the bounds specified by variable_lower_bounds and</span></div>
<divclass="line"><aid="l00519"name="l00519"></a><spanclass="lineno"> 519</span><spanclass="comment">// variable_upper_bounds. If the new bounds of all variables are non-empty,</span></div>
<divclass="line"><aid="l00525"name="l00525"></a><spanclass="lineno"> 525</span><spanclass="comment">// Returns true if the linear program is in equation form Ax = 0 and all slack</span></div>
<divclass="line"><aid="l00526"name="l00526"></a><spanclass="lineno"> 526</span><spanclass="comment">// variables have been added. This is also called "computational form" in some</span></div>
<divclass="line"><aid="l00527"name="l00527"></a><spanclass="lineno"> 527</span><spanclass="comment">// of the literature.</span></div>
<divclass="line"><aid="l00530"name="l00530"></a><spanclass="lineno"> 530</span><spanclass="comment">// Returns true if all integer variables in the linear program have strictly</span></div>
<divclass="line"><aid="l00534"name="l00534"></a><spanclass="lineno"> 534</span><spanclass="comment">// Returns true if all integer constraints in the linear program have strictly</span></div>
<divclass="line"><aid="l00538"name="l00538"></a><spanclass="lineno"> 538</span><spanclass="comment">// Advanced usage. Bypass the costly call to CleanUp() when we known that the</span></div>
<divclass="line"><aid="l00539"name="l00539"></a><spanclass="lineno"> 539</span><spanclass="comment">// change we made kept the matrix columns "clean" (see the comment of</span></div>
<divclass="line"><aid="l00540"name="l00540"></a><spanclass="lineno"> 540</span><spanclass="comment">// CleanUp()). This is unsafe but can save a big chunk of the running time</span></div>
<divclass="line"><aid="l00541"name="l00541"></a><spanclass="lineno"> 541</span><spanclass="comment">// when one does a small amount of incremental changes to the problem (like</span></div>
<divclass="line"><aid="l00542"name="l00542"></a><spanclass="lineno"> 542</span><spanclass="comment">// adding a new row with no duplicates or zero entries).</span></div>
<divclass="line"><aid="l00548"name="l00548"></a><spanclass="lineno"> 548</span><spanclass="comment">// If true, checks bound validity in debug mode.</span></div>
<divclass="line"><aid="l00551"name="l00551"></a><spanclass="lineno"> 551</span><spanclass="comment">// In our presolve, the calls and the extra test inside SetConstraintBounds()</span></div>
<divclass="line"><aid="l00552"name="l00552"></a><spanclass="lineno"> 552</span><spanclass="comment">// can be visible when a lot of substitutions are performed.</span></div>
<divclass="line"><aid="l00561"name="l00561"></a><spanclass="lineno"> 561</span><spanclass="comment">// A helper function that updates the vectors integer_variables_list_,</span></div>
<divclass="line"><aid="l00562"name="l00562"></a><spanclass="lineno"> 562</span><spanclass="comment">// binary_variables_list_, and non_binary_variables_list_.</span></div>
<divclass="line"><aid="l00565"name="l00565"></a><spanclass="lineno"> 565</span><spanclass="comment">// A helper function to format problem statistics. Used by GetProblemStats()</span></div>
<divclass="line"><aid="l00566"name="l00566"></a><spanclass="lineno"> 566</span><spanclass="comment">// and GetPrettyProblemStats().</span></div>
<divclass="line"><aid="l00569"name="l00569"></a><spanclass="lineno"> 569</span><spanclass="comment">// A helper function to format non-zero statistics. Used by GetNonZeroStats()</span></div>
<divclass="line"><aid="l00570"name="l00570"></a><spanclass="lineno"> 570</span><spanclass="comment">// and GetPrettyNonZeroStats().</span></div>
<divclass="line"><aid="l00573"name="l00573"></a><spanclass="lineno"> 573</span><spanclass="comment">// Resizes all row vectors to include index 'row'.</span></div>
<divclass="line"><aid="l00576"name="l00576"></a><spanclass="lineno"> 576</span><spanclass="comment">// Populates the definitions of variables, name and objective in the calling</span></div>
<divclass="line"><aid="l00577"name="l00577"></a><spanclass="lineno"> 577</span><spanclass="comment">// linear program with the data from the given linear program. The method does</span></div>
<divclass="line"><aid="l00578"name="l00578"></a><spanclass="lineno"> 578</span><spanclass="comment">// not touch the data structures for storing constraints.</span></div>
<divclass="line"><aid="l00582"name="l00582"></a><spanclass="lineno"> 582</span><spanclass="comment">// Stores the linear program coefficients.</span></div>
<divclass="line"><aid="l00585"name="l00585"></a><spanclass="lineno"> 585</span><spanclass="comment">// The transpose of matrix_. This will be lazily recomputed by</span></div>
<divclass="line"><aid="l00586"name="l00586"></a><spanclass="lineno"> 586</span><spanclass="comment">// GetTransposeSparseMatrix() if transpose_matrix_is_consistent_ is false.</span></div>
<divclass="line"><aid="l00601"name="l00601"></a><spanclass="lineno"> 601</span><spanclass="comment">// The vector of the indices of variables constrained to be integer.</span></div>
<divclass="line"><aid="l00602"name="l00602"></a><spanclass="lineno"> 602</span><spanclass="comment">// Note(user): the set of indices in integer_variables_list_ is the union</span></div>
<divclass="line"><aid="l00603"name="l00603"></a><spanclass="lineno"> 603</span><spanclass="comment">// of the set of indices in binary_variables_list_ and of the set of indices</span></div>
<divclass="line"><aid="l00604"name="l00604"></a><spanclass="lineno"> 604</span><spanclass="comment">// in non_binary_variables_list_ below.</span></div>
<divclass="line"><aid="l00607"name="l00607"></a><spanclass="lineno"> 607</span><spanclass="comment">// The vector of the indices of variables constrained to be binary.</span></div>
<divclass="line"><aid="l00610"name="l00610"></a><spanclass="lineno"> 610</span><spanclass="comment">// The vector of the indices of variables constrained to be integer, but not</span></div>
<divclass="line"><aid="l00614"name="l00614"></a><spanclass="lineno"> 614</span><spanclass="comment">// Map used to find the index of a variable based on its id.</span></div>
<divclass="line"><aid="l00617"name="l00617"></a><spanclass="lineno"> 617</span><spanclass="comment">// Map used to find the index of a constraint based on its id.</span></div>
<divclass="line"><aid="l00620"name="l00620"></a><spanclass="lineno"> 620</span><spanclass="comment">// Offset of the objective, i.e. value of the objective when all variables</span></div>
<divclass="line"><aid="l00621"name="l00621"></a><spanclass="lineno"> 621</span><spanclass="comment">// are set to zero.</span></div>
<divclass="line"><aid="l00625"name="l00625"></a><spanclass="lineno"> 625</span><spanclass="comment">// Boolean true (resp. false) when the problem is a maximization</span></div>
<divclass="line"><aid="l00629"name="l00629"></a><spanclass="lineno"> 629</span><spanclass="comment">// Boolean to speed-up multiple calls to IsCleanedUp() or</span></div>
<divclass="line"><aid="l00630"name="l00630"></a><spanclass="lineno"> 630</span><spanclass="comment">// CleanUp(). Mutable so IsCleanedUp() can be const.</span></div>
<divclass="line"><aid="l00633"name="l00633"></a><spanclass="lineno"> 633</span><spanclass="comment">// Whether transpose_matrix_ is guaranteed to be the transpose of matrix_.</span></div>
<divclass="line"><aid="l00636"name="l00636"></a><spanclass="lineno"> 636</span><spanclass="comment">// Whether integer_variables_list_ is consistent with the current</span></div>
<divclass="line"><aid="l00643"name="l00643"></a><spanclass="lineno"> 643</span><spanclass="comment">// The index of the first slack variable added to the linear program by</span></div>
<divclass="line"><aid="l00647"name="l00647"></a><spanclass="lineno"> 647</span><spanclass="comment">// If true, checks bounds in debug mode.</span></div>
<divclass="line"><aid="l00659"name="l00659"></a><spanclass="lineno"> 659</span><spanclass="comment">// Contains the solution of a LinearProgram as returned by a preprocessor.</span></div>
<divclass="line"><aid="l00670"name="l00670"></a><spanclass="lineno"> 670</span><spanclass="comment">// The actual primal/dual solution values. This is what most clients will</span></div>
<divclass="line"><aid="l00671"name="l00671"></a><spanclass="lineno"> 671</span><spanclass="comment">// need, and this is enough for LPSolver to easily check the optimality.</span></div>
<divclass="line"><aid="l00675"name="l00675"></a><spanclass="lineno"> 675</span><spanclass="comment">// The status of the variables and constraints which is difficult to</span></div>
<divclass="line"><aid="l00676"name="l00676"></a><spanclass="lineno"> 676</span><spanclass="comment">// reconstruct from the solution values alone. Some remarks:</span></div>
<divclass="line"><aid="l00677"name="l00677"></a><spanclass="lineno"> 677</span><spanclass="comment">// - From this information alone, by factorizing the basis, it is easy to</span></div>
<divclass="line"><aid="l00678"name="l00678"></a><spanclass="lineno"> 678</span><spanclass="comment">// reconstruct the primal and dual values.</span></div>
<divclass="line"><aid="l00679"name="l00679"></a><spanclass="lineno"> 679</span><spanclass="comment">// - The main difficulty to construct this from the solution values is to</span></div>
<divclass="line"><aid="l00680"name="l00680"></a><spanclass="lineno"> 680</span><spanclass="comment">// reconstruct the optimal basis if some basic variables are exactly at</span></div>
<divclass="line"><aid="l00681"name="l00681"></a><spanclass="lineno"> 681</span><spanclass="comment">// one of their bounds (and their reduced costs are close to zero).</span></div>
<divclass="line"><aid="l00682"name="l00682"></a><spanclass="lineno"> 682</span><spanclass="comment">// - The non-basic information (VariableStatus::FIXED_VALUE,</span></div>
<divclass="line"><aid="l00684"name="l00684"></a><spanclass="lineno"> 684</span><spanclass="comment">// VariableStatus::FREE) is easy to construct for variables (because</span></div>
<divclass="line"><aid="l00685"name="l00685"></a><spanclass="lineno"> 685</span><spanclass="comment">// they are at their exact bounds). They can be guessed for constraints</span></div>
<divclass="line"><aid="l00686"name="l00686"></a><spanclass="lineno"> 686</span><spanclass="comment">// (here a small precision error is unavoidable). However, it is useful to</span></div>
<divclass="line"><aid="l00687"name="l00687"></a><spanclass="lineno"> 687</span><spanclass="comment">// carry this exact information during post-solve.</span></div>
<divclass="line"><aid="l00694"name="l00694"></a><spanclass="lineno"> 694</span><spanclass="comment">// Helper function to check the bounds of the SetVariableBounds() and</span></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_linear_program_html_a2175025047722705a3af86e54229f9cd"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_linear_program.html#a2175025047722705a3af86e54229f9cd">operations_research::glop::LinearProgram::GetTransposeSparseMatrix</a></div><divclass="ttdeci">const SparseMatrix & GetTransposeSparseMatrix() const</div><divclass="ttdef"><b>Definition:</b><ahref="lp__data_8cc_source.html#l00376">lp_data.cc:376</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_linear_program_html_a24dcbf29c0d6cd766009a182a6484e3b"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_linear_program.html#a24dcbf29c0d6cd766009a182a6484e3b">operations_research::glop::LinearProgram::name</a></div><divclass="ttdeci">const std::string & name() const</div><divclass="ttdef"><b>Definition:</b><ahref="lp__data_8h_source.html#l00075">lp_data.h:75</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_linear_program_html_a5bb553b6a1b88f16c42b70697ac65473"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_linear_program.html#a5bb553b6a1b88f16c42b70697ac65473">operations_research::glop::LinearProgram::constraint_lower_bounds</a></div><divclass="ttdeci">const DenseColumn & constraint_lower_bounds() const</div><divclass="ttdef"><b>Definition:</b><ahref="lp__data_8h_source.html#l00215">lp_data.h:215</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_linear_program_html_a74f1c824468608a9bb5fee6f10eca698"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_linear_program.html#a74f1c824468608a9bb5fee6f10eca698">operations_research::glop::LinearProgram::variable_upper_bounds</a></div><divclass="ttdeci">const DenseRow & variable_upper_bounds() const</div><divclass="ttdef"><b>Definition:</b><ahref="lp__data_8h_source.html#l00232">lp_data.h:232</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_linear_program_html_a9245b35ee316a27a561d5b041e588be5"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_linear_program.html#a9245b35ee316a27a561d5b041e588be5">operations_research::glop::LinearProgram::constraint_upper_bounds</a></div><divclass="ttdeci">const DenseColumn & constraint_upper_bounds() const</div><divclass="ttdef"><b>Definition:</b><ahref="lp__data_8h_source.html#l00218">lp_data.h:218</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_linear_program_html_a977f52b2e6fa6e9d6db8d8ac9cbf33c4"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_linear_program.html#a977f52b2e6fa6e9d6db8d8ac9cbf33c4">operations_research::glop::LinearProgram::objective_coefficients</a></div><divclass="ttdeci">const DenseRow & objective_coefficients() const</div><divclass="ttdef"><b>Definition:</b><ahref="lp__data_8h_source.html#l00223">lp_data.h:223</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_linear_program_html_ad97d7cdf5aa8b8704f95084d54a2beb1"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_linear_program.html#ad97d7cdf5aa8b8704f95084d54a2beb1">operations_research::glop::LinearProgram::GetSparseMatrix</a></div><divclass="ttdeci">const SparseMatrix & GetSparseMatrix() const</div><divclass="ttdef"><b>Definition:</b><ahref="lp__data_8h_source.html#l00175">lp_data.h:175</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_linear_program_html_adb3b261831be8afb947baceaba1c220b"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_linear_program.html#adb3b261831be8afb947baceaba1c220b">operations_research::glop::LinearProgram::variable_lower_bounds</a></div><divclass="ttdeci">const DenseRow & variable_lower_bounds() const</div><divclass="ttdef"><b>Definition:</b><ahref="lp__data_8h_source.html#l00229">lp_data.h:229</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>