<ahref="primal__edge__norms_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="l00031"name="l00031"></a><spanclass="lineno"> 31</span><spanclass="comment">// This class maintains the primal edge squared norms (and other variants) to be</span></div>
<divclass="line"><aid="l00032"name="l00032"></a><spanclass="lineno"> 32</span><spanclass="comment">// used in the primal pricing step. Instead of computing the needed values from</span></div>
<divclass="line"><aid="l00033"name="l00033"></a><spanclass="lineno"> 33</span><spanclass="comment">// scractch at each iteration, it is more efficient to update them incrementally</span></div>
<divclass="line"><aid="l00034"name="l00034"></a><spanclass="lineno"> 34</span><spanclass="comment">// for each basis pivot applied to the simplex basis matrix B.</span></div>
<divclass="line"><aid="l00037"name="l00037"></a><spanclass="lineno"> 37</span><spanclass="comment">// - To each non-basic column 'a' of a matrix A, we can associate an "edge" in</span></div>
<divclass="line"><aid="l00038"name="l00038"></a><spanclass="lineno"> 38</span><spanclass="comment">// the kernel of A equal to 1.0 on the index of 'a' and '-B^{-1}.a' on the</span></div>
<divclass="line"><aid="l00040"name="l00040"></a><spanclass="lineno"> 40</span><spanclass="comment">// - 'B^{-1}.a' is called the "right inverse" of 'a'.</span></div>
<divclass="line"><aid="l00041"name="l00041"></a><spanclass="lineno"> 41</span><spanclass="comment">// - The entering edge is the edge we are following during a simplex step,</span></div>
<divclass="line"><aid="l00042"name="l00042"></a><spanclass="lineno"> 42</span><spanclass="comment">// and we call "direction" the reverse of this edge restricted to the</span></div>
<divclass="line"><aid="l00043"name="l00043"></a><spanclass="lineno"> 43</span><spanclass="comment">// basic variables, i.e. the right inverse of the entering column.</span></div>
<divclass="line"><aid="l00052"name="l00052"></a><spanclass="lineno"> 52</span><spanclass="comment">// - Ping-Qi Pan "A fast simplex algorithm for linear programming".</span></div>
<divclass="line"><aid="l00058"name="l00058"></a><spanclass="lineno"> 58</span><spanclass="comment">// Takes references to the linear program data we need. Note that we assume</span></div>
<divclass="line"><aid="l00059"name="l00059"></a><spanclass="lineno"> 59</span><spanclass="comment">// that the matrix will never change in our back, but the other references are</span></div>
<divclass="line"><aid="l00060"name="l00060"></a><spanclass="lineno"> 60</span><spanclass="comment">// supposed to reflect the correct state.</span></div>
<divclass="line"><aid="l00065"name="l00065"></a><spanclass="lineno"> 65</span><spanclass="comment">// Clears, i.e. resets the object to its initial value. This will trigger</span></div>
<divclass="line"><aid="l00066"name="l00066"></a><spanclass="lineno"> 66</span><spanclass="comment">// a recomputation for the next Get*() method call.</span></div>
<divclass="line"><aid="l00069"name="l00069"></a><spanclass="lineno"> 69</span><spanclass="comment">// If this is true, then the caller must re-factorize the basis before the</span></div>
<divclass="line"><aid="l00070"name="l00070"></a><spanclass="lineno"> 70</span><spanclass="comment">// next call to GetEdgeSquaredNorms(). This is because the latter will</span></div>
<divclass="line"><aid="l00071"name="l00071"></a><spanclass="lineno"> 71</span><spanclass="comment">// recompute the norms from scratch and therefore needs a hightened precision</span></div>
<divclass="line"><aid="l00072"name="l00072"></a><spanclass="lineno"> 72</span><spanclass="comment">// and speed.</span></div>
<divclass="line"><aid="l00075"name="l00075"></a><spanclass="lineno"> 75</span><spanclass="comment">// Depending on the SetPricingRule(), this returns one of the "norms" vector</span></div>
<divclass="line"><aid="l00076"name="l00076"></a><spanclass="lineno"> 76</span><spanclass="comment">// below. Note that all norms are squared.</span></div>
<divclass="line"><aid="l00079"name="l00079"></a><spanclass="lineno"> 79</span><spanclass="comment">// Returns the primal edge squared norms. This is only valid if the caller</span></div>
<divclass="line"><aid="l00080"name="l00080"></a><spanclass="lineno"> 80</span><spanclass="comment">// properly called UpdateBeforeBasisPivot() before each basis pivot, or if</span></div>
<divclass="line"><aid="l00081"name="l00081"></a><spanclass="lineno"> 81</span><spanclass="comment">// this is the first call to this function after a Clear(). Note that only the</span></div>
<divclass="line"><aid="l00082"name="l00082"></a><spanclass="lineno"> 82</span><spanclass="comment">// relevant columns are filled.</span></div>
<divclass="line"><aid="l00085"name="l00085"></a><spanclass="lineno"> 85</span><spanclass="comment">// Returns an approximation of the edges norms "devex".</span></div>
<divclass="line"><aid="l00086"name="l00086"></a><spanclass="lineno"> 86</span><spanclass="comment">// This is only valid if the caller properly called UpdateBeforeBasisPivot()</span></div>
<divclass="line"><aid="l00087"name="l00087"></a><spanclass="lineno"> 87</span><spanclass="comment">// before each basis pivot, or if this is the first call to this function</span></div>
<divclass="line"><aid="l00088"name="l00088"></a><spanclass="lineno"> 88</span><spanclass="comment">// after a Clear().</span></div>
<divclass="line"><aid="l00091"name="l00091"></a><spanclass="lineno"> 91</span><spanclass="comment">// Returns the L2 norms of all the columns of A.</span></div>
<divclass="line"><aid="l00092"name="l00092"></a><spanclass="lineno"> 92</span><spanclass="comment">// Note that this is currently not cleared by Clear().</span></div>
<divclass="line"><aid="l00095"name="l00095"></a><spanclass="lineno"> 95</span><spanclass="comment">// Compares the current entering edge norm with its precise version (using the</span></div>
<divclass="line"><aid="l00096"name="l00096"></a><spanclass="lineno"> 96</span><spanclass="comment">// direction that wasn't avaible before) and triggers a full recomputation if</span></div>
<divclass="line"><aid="l00097"name="l00097"></a><spanclass="lineno"> 97</span><spanclass="comment">// the precision is not good enough (see recompute_edges_norm_threshold in</span></div>
<divclass="line"><aid="l00098"name="l00098"></a><spanclass="lineno"> 98</span><spanclass="comment">// GlopParameters). As a side effect, this replace the entering_col edge</span></div>
<divclass="line"><aid="l00099"name="l00099"></a><spanclass="lineno"> 99</span><spanclass="comment">// norm with its precise version.</span></div>
<divclass="line"><aid="l00103"name="l00103"></a><spanclass="lineno"> 103</span><spanclass="comment">// Updates any internal data BEFORE the given simplex pivot is applied to B.</span></div>
<divclass="line"><aid="l00104"name="l00104"></a><spanclass="lineno"> 104</span><spanclass="comment">// Note that no updates are needed in case of a bound flip.</span></div>
<divclass="line"><aid="l00105"name="l00105"></a><spanclass="lineno"> 105</span><spanclass="comment">// The arguments are in order:</span></div>
<divclass="line"><aid="l00106"name="l00106"></a><spanclass="lineno"> 106</span><spanclass="comment">// - The index of the entering non-basic column of A.</span></div>
<divclass="line"><aid="l00107"name="l00107"></a><spanclass="lineno"> 107</span><spanclass="comment">// - The index in B of the leaving basic variable.</span></div>
<divclass="line"><aid="l00108"name="l00108"></a><spanclass="lineno"> 108</span><spanclass="comment">// - The 'direction', i.e. the right inverse of the entering column.</span></div>
<divclass="line"><aid="l00109"name="l00109"></a><spanclass="lineno"> 109</span><spanclass="comment">// - The update row (see UpdateRow), which will only be computed if needed.</span></div>
<divclass="line"><aid="l00120"name="l00120"></a><spanclass="lineno"> 120</span><spanclass="comment">// This changes what GetSquaredNorms() returns.</span></div>
<divclass="line"><aid="l00125"name="l00125"></a><spanclass="lineno"> 125</span><spanclass="comment">// Registers a boolean that will be set to true each time the norms are or</span></div>
<divclass="line"><aid="l00126"name="l00126"></a><spanclass="lineno"> 126</span><spanclass="comment">// will be recomputed. This allows anyone that depends on this to know that it</span></div>
<divclass="line"><aid="l00127"name="l00127"></a><spanclass="lineno"> 127</span><spanclass="comment">// cannot just assume an incremental changes and needs to updates its data.</span></div>
<divclass="line"><aid="l00128"name="l00128"></a><spanclass="lineno"> 128</span><spanclass="comment">// Important: UpdateBeforeBasisPivot() will not trigger this.</span></div>
<divclass="line"><aid="l00131"name="l00131"></a><spanclass="lineno"> 131</span><spanclass="comment">// Returns a string with statistics about this class.</span></div>
<divclass="line"><aid="l00134"name="l00134"></a><spanclass="lineno"> 134</span><spanclass="comment">// Deterministic time used by the scalar product computation of this class.</span></div>
<divclass="line"><aid="l00156"name="l00156"></a><spanclass="lineno"> 156</span><spanclass="comment">// Recompute the matrix column L2 norms from scratch.</span></div>
<divclass="line"><aid="l00159"name="l00159"></a><spanclass="lineno"> 159</span><spanclass="comment">// Recompute the edge squared L2 norms from scratch.</span></div>
<divclass="line"><aid="l00162"name="l00162"></a><spanclass="lineno"> 162</span><spanclass="comment">// Compute the left inverse of the direction.</span></div>
<divclass="line"><aid="l00163"name="l00163"></a><spanclass="lineno"> 163</span><spanclass="comment">// The first argument is there for checking precision.</span></div>
<divclass="line"><aid="l00167"name="l00167"></a><spanclass="lineno"> 167</span><spanclass="comment">// Updates edges_squared_norm_ according to the given pivot.</span></div>
<divclass="line"><aid="l00176"name="l00176"></a><spanclass="lineno"> 176</span><spanclass="comment">// Updates devex_weights_ according to the given pivot.</span></div>
<divclass="line"><aid="l00181"name="l00181"></a><spanclass="lineno"> 181</span><spanclass="comment">// Problem data that should be updated from outside.</span></div>
<divclass="line"><aid="l00191"name="l00191"></a><spanclass="lineno"> 191</span><spanclass="comment">// Booleans to control what happens on the next ChooseEnteringColumn() call.</span></div>
<divclass="line"><aid="l00196"name="l00196"></a><spanclass="lineno"> 196</span><spanclass="comment">// Norm^2 of the edges of the relevant columns of A.</span></div>
<divclass="line"><aid="l00202"name="l00202"></a><spanclass="lineno"> 202</span><spanclass="comment">// Approximation of edges norms "devex".</span></div>
<divclass="line"><aid="l00203"name="l00203"></a><spanclass="lineno"> 203</span><spanclass="comment">// Denoted by vector 'w' in Pin Qi Pan (1810.pdf section 1.1.4)</span></div>
<divclass="line"><aid="l00204"name="l00204"></a><spanclass="lineno"> 204</span><spanclass="comment">// At any time, devex_weights_ >= 1.0.</span></div>
<divclass="line"><aid="l00207"name="l00207"></a><spanclass="lineno"> 207</span><spanclass="comment">// Tracks number of updates of the devex weights since we have to reset</span></div>
<divclass="line"><aid="l00208"name="l00208"></a><spanclass="lineno"> 208</span><spanclass="comment">// them to 1.0 every now and then.</span></div>
<divclass="line"><aid="l00211"name="l00211"></a><spanclass="lineno"> 211</span><spanclass="comment">// Left inverse by B of the 'direction'. This is the transpose of 'v' in the</span></div>
<divclass="line"><aid="l00212"name="l00212"></a><spanclass="lineno"> 212</span><spanclass="comment">// steepest edge paper. Its scalar product with a column 'a' of A gives the</span></div>
<divclass="line"><aid="l00213"name="l00213"></a><spanclass="lineno"> 213</span><spanclass="comment">// value of the scalar product of the 'direction' with the right inverse of</span></div>
<divclass="line"><aid="l00220"name="l00220"></a><spanclass="lineno"> 220</span><spanclass="comment">// Boolean(s) to set to false when the norms are changed outside of the</span></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_primal_edge_norms_html_a11b5738482346b103919cf0e6481c977"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_primal_edge_norms.html#a11b5738482346b103919cf0e6481c977">operations_research::glop::PrimalEdgeNorms::GetSquaredNorms</a></div><divclass="ttdeci">const DenseRow & GetSquaredNorms()</div><divclass="ttdef"><b>Definition:</b><ahref="primal__edge__norms_8cc_source.html#l00049">primal_edge_norms.cc:49</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_primal_edge_norms_html_a551ee6b517f861e2ad7557e092a9860d"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_primal_edge_norms.html#a551ee6b517f861e2ad7557e092a9860d">operations_research::glop::PrimalEdgeNorms::GetMatrixColumnNorms</a></div><divclass="ttdeci">const DenseRow & GetMatrixColumnNorms()</div><divclass="ttdef"><b>Definition:</b><ahref="primal__edge__norms_8cc_source.html#l00070">primal_edge_norms.cc:70</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_primal_edge_norms_html_a67a5105630385abc274872ab7a28e70f"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_primal_edge_norms.html#a67a5105630385abc274872ab7a28e70f">operations_research::glop::PrimalEdgeNorms::GetEdgeSquaredNorms</a></div><divclass="ttdeci">const DenseRow & GetEdgeSquaredNorms()</div><divclass="ttdef"><b>Definition:</b><ahref="primal__edge__norms_8cc_source.html#l00060">primal_edge_norms.cc:60</a></div></div>
<divclass="ttc"id="aclassoperations__research_1_1glop_1_1_primal_edge_norms_html_a6f599ec9c50fc8a7421f98203a06a428"><divclass="ttname"><ahref="classoperations__research_1_1glop_1_1_primal_edge_norms.html#a6f599ec9c50fc8a7421f98203a06a428">operations_research::glop::PrimalEdgeNorms::GetDevexWeights</a></div><divclass="ttdeci">const DenseRow & GetDevexWeights()</div><divclass="ttdef"><b>Definition:</b><ahref="primal__edge__norms_8cc_source.html#l00065">primal_edge_norms.cc:65</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>