163 lines
145 KiB
HTML
163 lines
145 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<title>OR-Tools</title>
|
|
<meta http-equiv="Content-Type" content="text/html;"/>
|
|
<meta charset="utf-8"/>
|
|
<!--<link rel='stylesheet' type='text/css' href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>-->
|
|
<link rel="stylesheet" type="text/css" href="ortools.css" title="default" media="screen,print" />
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="banner-container">
|
|
<div id="banner">
|
|
<span id="sfml">OR-Tools 7.2</span>
|
|
</div>
|
|
</div>
|
|
<link rel="icon" href="https://developers.google.com/optimization/images/orLogo.png">
|
|
<div id="content">
|
|
<!-- Generated by Doxygen 1.8.15 -->
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="navrow2" class="tabs2">
|
|
<ul class="tablist">
|
|
<li><a href="files.html"><span>File List</span></a></li>
|
|
</ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(document).ready(function(){initNavTree('knapsack__solver_8h_source.html','');});
|
|
/* @license-end */
|
|
</script>
|
|
<div id="doc-content">
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">knapsack_solver.h</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<a href="knapsack__solver_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">// Copyright 2010-2018 Google LLC</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment">// you may not use this file except in compliance with the License.</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment">// You may obtain a copy of the License at</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment">//</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment">//</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment">// Unless required by applicable law or agreed to in writing, software</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment">// See the License for the specific language governing permissions and</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment">// limitations under the License.</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> </div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="preprocessor">#ifndef OR_TOOLS_ALGORITHMS_KNAPSACK_SOLVER_H_</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="preprocessor">#define OR_TOOLS_ALGORITHMS_KNAPSACK_SOLVER_H_</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> </div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="preprocessor">#include <math.h></span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> </div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="preprocessor">#include <memory></span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#include <string></span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="preprocessor">#include <vector></span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> </div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="preprocessor">#include "absl/memory/memory.h"</span></div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="preprocessor">#include "ortools/base/basictypes.h"</span></div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="preprocessor">#include "ortools/base/integral_types.h"</span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="preprocessor">#include "ortools/base/logging.h"</span></div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="preprocessor">#include "ortools/base/macros.h"</span></div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="preprocessor">#include "ortools/util/time_limit.h"</span></div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span> </div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="keyword">namespace </span><a class="code" href="namespaceoperations__research.html">operations_research</a> {</div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> </div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span> <span class="keyword">class </span>BaseKnapsackSolver;</div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span> </div><div class="line"><a name="l00120"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSolver.html"> 120</a></span> <span class="keyword">class </span><a class="code" href="classoperations__research_1_1KnapsackSolver.html">KnapsackSolver</a> {</div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00127"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893"> 127</a></span>  <span class="keyword">enum</span> <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893">SolverType</a> {</div><div class="line"><a name="l00134"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893a4d72c45990d1a81e3f5bcdaf6de72096"> 134</a></span>  <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893a4d72c45990d1a81e3f5bcdaf6de72096">KNAPSACK_BRUTE_FORCE_SOLVER</a> = 0,</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span> </div><div class="line"><a name="l00142"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893aa6c3b9157b2506f5a53b0c73165c8f9b"> 142</a></span>  <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893aa6c3b9157b2506f5a53b0c73165c8f9b">KNAPSACK_64ITEMS_SOLVER</a> = 1,</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span> </div><div class="line"><a name="l00150"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893a9c02fa29c925bc1d37cba92490998132"> 150</a></span>  <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893a9c02fa29c925bc1d37cba92490998132">KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER</a> = 2,</div><div class="line"><a name="l00151"></a><span class="lineno"> 151</span> </div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span> <span class="preprocessor">#if defined(USE_CBC)</span></div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span> </div><div class="line"><a name="l00158"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893ae1b7e0ea856a376a9c04130e0abdf812"> 158</a></span>  <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893ae1b7e0ea856a376a9c04130e0abdf812">KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER</a> = 3,</div><div class="line"><a name="l00159"></a><span class="lineno"> 159</span> <span class="preprocessor">#endif // USE_CBC</span></div><div class="line"><a name="l00160"></a><span class="lineno"> 160</span> </div><div class="line"><a name="l00166"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893ae8c15c25eaf606f5f853821aaabba164"> 166</a></span>  <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893ae8c15c25eaf606f5f853821aaabba164">KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER</a> = 5,</div><div class="line"><a name="l00167"></a><span class="lineno"> 167</span> </div><div class="line"><a name="l00168"></a><span class="lineno"> 168</span> <span class="preprocessor">#if defined(USE_SCIP)</span></div><div class="line"><a name="l00169"></a><span class="lineno"> 169</span> </div><div class="line"><a name="l00174"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893aa6d83fc5b8d17db1f82c1b414a4e8b20"> 174</a></span>  <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893aa6d83fc5b8d17db1f82c1b414a4e8b20">KNAPSACK_MULTIDIMENSION_SCIP_MIP_SOLVER</a> = 6,</div><div class="line"><a name="l00175"></a><span class="lineno"> 175</span> <span class="preprocessor">#endif // USE_SCIP</span></div><div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  };</div><div class="line"><a name="l00177"></a><span class="lineno"> 177</span> </div><div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  <span class="keyword">explicit</span> <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a7638cb76df7cb79d956dda62d179a554">KnapsackSolver</a>(<span class="keyword">const</span> std::string &solver_name);</div><div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a7638cb76df7cb79d956dda62d179a554">KnapsackSolver</a>(<a class="code" href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893">SolverType</a> solver_type, <span class="keyword">const</span> std::string &solver_name);</div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span>  <span class="keyword">virtual</span> <a class="code" href="classoperations__research_1_1KnapsackSolver.html#ac6d1a38c9a1c607e80d05720372ace4d">~KnapsackSolver</a>();</div><div class="line"><a name="l00181"></a><span class="lineno"> 181</span> </div><div class="line"><a name="l00185"></a><span class="lineno"> 185</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackSolver.html#aca019151f60942f2e7245874bb89cd62">Init</a>(<span class="keyword">const</span> std::vector<int64> &profits,</div><div class="line"><a name="l00186"></a><span class="lineno"> 186</span>  <span class="keyword">const</span> std::vector<std::vector<int64>> &weights,</div><div class="line"><a name="l00187"></a><span class="lineno"> 187</span>  <span class="keyword">const</span> std::vector<int64> &capacities);</div><div class="line"><a name="l00188"></a><span class="lineno"> 188</span> </div><div class="line"><a name="l00192"></a><span class="lineno"> 192</span>  int64 <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a7c3b5825c8effd86de03a610d1a38ed7">Solve</a>();</div><div class="line"><a name="l00193"></a><span class="lineno"> 193</span> </div><div class="line"><a name="l00197"></a><span class="lineno"> 197</span>  <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a170ccb08012026c5a438fcf16feb6faa">BestSolutionContains</a>(<span class="keywordtype">int</span> item_id) <span class="keyword">const</span>;</div><div class="line"><a name="l00201"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSolver.html#a96f960b29496f637af7a3eeb10e606ab"> 201</a></span>  <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a96f960b29496f637af7a3eeb10e606ab">IsSolutionOptimal</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> is_solution_optimal_; }</div><div class="line"><a name="l00202"></a><span class="lineno"> 202</span>  std::string <a class="code" href="classoperations__research_1_1KnapsackSolver.html#ad2950d2690930dd8562b40d29bb7002e">GetName</a>() <span class="keyword">const</span>;</div><div class="line"><a name="l00203"></a><span class="lineno"> 203</span> </div><div class="line"><a name="l00204"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSolver.html#a0408f46c96d0dbf4eb463fa385778593"> 204</a></span>  <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a0408f46c96d0dbf4eb463fa385778593">use_reduction</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> use_reduction_; }</div><div class="line"><a name="l00205"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSolver.html#abb429376ba12d5541f22a905a728b0e1"> 205</a></span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackSolver.html#abb429376ba12d5541f22a905a728b0e1">set_use_reduction</a>(<span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a0408f46c96d0dbf4eb463fa385778593">use_reduction</a>) {</div><div class="line"><a name="l00206"></a><span class="lineno"> 206</span>  use_reduction_ = <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a0408f46c96d0dbf4eb463fa385778593">use_reduction</a>;</div><div class="line"><a name="l00207"></a><span class="lineno"> 207</span>  }</div><div class="line"><a name="l00208"></a><span class="lineno"> 208</span> </div><div class="line"><a name="l00214"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSolver.html#a0f6ca3ef8483871052325ea2d04ca72d"> 214</a></span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackSolver.html#a0f6ca3ef8483871052325ea2d04ca72d">set_time_limit</a>(<span class="keywordtype">double</span> time_limit_seconds) {</div><div class="line"><a name="l00215"></a><span class="lineno"> 215</span>  time_limit_seconds_ = time_limit_seconds;</div><div class="line"><a name="l00216"></a><span class="lineno"> 216</span>  time_limit_ = absl::make_unique<TimeLimit>(time_limit_seconds_);</div><div class="line"><a name="l00217"></a><span class="lineno"> 217</span>  }</div><div class="line"><a name="l00218"></a><span class="lineno"> 218</span> </div><div class="line"><a name="l00219"></a><span class="lineno"> 219</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00220"></a><span class="lineno"> 220</span>  <span class="comment">// Trivial reduction of capacity constraints when the capacity is higher than</span></div><div class="line"><a name="l00221"></a><span class="lineno"> 221</span>  <span class="comment">// the sum of the weights of the items. Returns the number of reduced items.</span></div><div class="line"><a name="l00222"></a><span class="lineno"> 222</span>  <span class="keywordtype">int</span> ReduceCapacities(<span class="keywordtype">int</span> num_items,</div><div class="line"><a name="l00223"></a><span class="lineno"> 223</span>  <span class="keyword">const</span> std::vector<std::vector<int64> >& weights,</div><div class="line"><a name="l00224"></a><span class="lineno"> 224</span>  <span class="keyword">const</span> std::vector<int64>& capacities,</div><div class="line"><a name="l00225"></a><span class="lineno"> 225</span>  std::vector<std::vector<int64> >* reduced_weights,</div><div class="line"><a name="l00226"></a><span class="lineno"> 226</span>  std::vector<int64>* reduced_capacities);</div><div class="line"><a name="l00227"></a><span class="lineno"> 227</span>  <span class="keywordtype">int</span> ReduceProblem(<span class="keywordtype">int</span> num_items);</div><div class="line"><a name="l00228"></a><span class="lineno"> 228</span>  <span class="keywordtype">void</span> ComputeAdditionalProfit(<span class="keyword">const</span> std::vector<int64>& profits);</div><div class="line"><a name="l00229"></a><span class="lineno"> 229</span>  <span class="keywordtype">void</span> InitReducedProblem(<span class="keyword">const</span> std::vector<int64>& profits,</div><div class="line"><a name="l00230"></a><span class="lineno"> 230</span>  <span class="keyword">const</span> std::vector<std::vector<int64> >& weights,</div><div class="line"><a name="l00231"></a><span class="lineno"> 231</span>  <span class="keyword">const</span> std::vector<int64>& capacities);</div><div class="line"><a name="l00232"></a><span class="lineno"> 232</span> </div><div class="line"><a name="l00233"></a><span class="lineno"> 233</span>  std::unique_ptr<BaseKnapsackSolver> solver_;</div><div class="line"><a name="l00234"></a><span class="lineno"> 234</span>  std::vector<bool> known_value_;</div><div class="line"><a name="l00235"></a><span class="lineno"> 235</span>  std::vector<bool> best_solution_;</div><div class="line"><a name="l00236"></a><span class="lineno"> 236</span>  <span class="keywordtype">bool</span> is_solution_optimal_ = <span class="keyword">false</span>;</div><div class="line"><a name="l00237"></a><span class="lineno"> 237</span>  std::vector<int> mapping_reduced_item_id_;</div><div class="line"><a name="l00238"></a><span class="lineno"> 238</span>  <span class="keywordtype">bool</span> is_problem_solved_;</div><div class="line"><a name="l00239"></a><span class="lineno"> 239</span>  int64 additional_profit_;</div><div class="line"><a name="l00240"></a><span class="lineno"> 240</span>  <span class="keywordtype">bool</span> use_reduction_;</div><div class="line"><a name="l00241"></a><span class="lineno"> 241</span>  <span class="keywordtype">double</span> time_limit_seconds_;</div><div class="line"><a name="l00242"></a><span class="lineno"> 242</span>  std::unique_ptr<TimeLimit> time_limit_;</div><div class="line"><a name="l00243"></a><span class="lineno"> 243</span> </div><div class="line"><a name="l00244"></a><span class="lineno"> 244</span>  DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1KnapsackSolver.html">KnapsackSolver</a>);</div><div class="line"><a name="l00245"></a><span class="lineno"> 245</span> };</div><div class="line"><a name="l00246"></a><span class="lineno"> 246</span> </div><div class="line"><a name="l00247"></a><span class="lineno"> 247</span> <span class="preprocessor">#if !defined(SWIG)</span></div><div class="line"><a name="l00248"></a><span class="lineno"> 248</span> <span class="comment">// The following code defines needed classes for the KnapsackGenericSolver</span></div><div class="line"><a name="l00249"></a><span class="lineno"> 249</span> <span class="comment">// class which is the entry point to extend knapsack with new constraints such</span></div><div class="line"><a name="l00250"></a><span class="lineno"> 250</span> <span class="comment">// as conflicts between items.</span></div><div class="line"><a name="l00251"></a><span class="lineno"> 251</span> <span class="comment">//</span></div><div class="line"><a name="l00252"></a><span class="lineno"> 252</span> <span class="comment">// Constraints are enforced using KnapsackPropagator objects, in the current</span></div><div class="line"><a name="l00253"></a><span class="lineno"> 253</span> <span class="comment">// code there is one propagator per dimension (KnapsackCapacityPropagator).</span></div><div class="line"><a name="l00254"></a><span class="lineno"> 254</span> <span class="comment">// One of those propagators, named master propagator, is used to guide the</span></div><div class="line"><a name="l00255"></a><span class="lineno"> 255</span> <span class="comment">// search, i.e. decides which item should be assigned next.</span></div><div class="line"><a name="l00256"></a><span class="lineno"> 256</span> <span class="comment">// Roughly speaking the search algorithm is:</span></div><div class="line"><a name="l00257"></a><span class="lineno"> 257</span> <span class="comment">// - While not optimal</span></div><div class="line"><a name="l00258"></a><span class="lineno"> 258</span> <span class="comment">// - Select next search node to expand</span></div><div class="line"><a name="l00259"></a><span class="lineno"> 259</span> <span class="comment">// - Select next item_i to assign (using master propagator)</span></div><div class="line"><a name="l00260"></a><span class="lineno"> 260</span> <span class="comment">// - Generate a new search node where item_i is in the knapsack</span></div><div class="line"><a name="l00261"></a><span class="lineno"> 261</span> <span class="comment">// - Check validity of this new partial solution (using propagators)</span></div><div class="line"><a name="l00262"></a><span class="lineno"> 262</span> <span class="comment">// - If valid, add this new search node to the search</span></div><div class="line"><a name="l00263"></a><span class="lineno"> 263</span> <span class="comment">// - Generate a new search node where item_i is not in the knapsack</span></div><div class="line"><a name="l00264"></a><span class="lineno"> 264</span> <span class="comment">// - Check validity of this new partial solution (using propagators)</span></div><div class="line"><a name="l00265"></a><span class="lineno"> 265</span> <span class="comment">// - If valid, add this new search node to the search</span></div><div class="line"><a name="l00266"></a><span class="lineno"> 266</span> <span class="comment">//</span></div><div class="line"><a name="l00267"></a><span class="lineno"> 267</span> <span class="comment">// TODO(user): Add a new propagator class for conflict constraint.</span></div><div class="line"><a name="l00268"></a><span class="lineno"> 268</span> <span class="comment">// TODO(user): Add a new propagator class used as a guide when the problem has</span></div><div class="line"><a name="l00269"></a><span class="lineno"> 269</span> <span class="comment">// several dimensions.</span></div><div class="line"><a name="l00270"></a><span class="lineno"> 270</span> </div><div class="line"><a name="l00271"></a><span class="lineno"> 271</span> <span class="comment">// ----- KnapsackAssignement -----</span></div><div class="line"><a name="l00272"></a><span class="lineno"> 272</span> <span class="comment">// KnapsackAssignement is a small struct used to pair an item with its</span></div><div class="line"><a name="l00273"></a><span class="lineno"> 273</span> <span class="comment">// assignment. It is mainly used for search nodes and updates.</span></div><div class="line"><a name="l00274"></a><span class="lineno"><a class="line" href="structoperations__research_1_1KnapsackAssignment.html"> 274</a></span> <span class="keyword">struct </span><a class="code" href="structoperations__research_1_1KnapsackAssignment.html">KnapsackAssignment</a> {</div><div class="line"><a name="l00275"></a><span class="lineno"><a class="line" href="structoperations__research_1_1KnapsackAssignment.html#aab038e186549b78c472c9fbe16f6f315"> 275</a></span>  <a class="code" href="structoperations__research_1_1KnapsackAssignment.html#aab038e186549b78c472c9fbe16f6f315">KnapsackAssignment</a>(<span class="keywordtype">int</span> _item_id, <span class="keywordtype">bool</span> _is_in)</div><div class="line"><a name="l00276"></a><span class="lineno"> 276</span>  : <a class="code" href="structoperations__research_1_1KnapsackAssignment.html#a91340b6da590fae44e79199666ccf468">item_id</a>(_item_id), <a class="code" href="structoperations__research_1_1KnapsackAssignment.html#ab4ba3de70cb7aa3ad9aaee3dd2c60b7b">is_in</a>(_is_in) {}</div><div class="line"><a name="l00277"></a><span class="lineno"><a class="line" href="structoperations__research_1_1KnapsackAssignment.html#a91340b6da590fae44e79199666ccf468"> 277</a></span>  <span class="keywordtype">int</span> <a class="code" href="structoperations__research_1_1KnapsackAssignment.html#a91340b6da590fae44e79199666ccf468">item_id</a>;</div><div class="line"><a name="l00278"></a><span class="lineno"><a class="line" href="structoperations__research_1_1KnapsackAssignment.html#ab4ba3de70cb7aa3ad9aaee3dd2c60b7b"> 278</a></span>  <span class="keywordtype">bool</span> <a class="code" href="structoperations__research_1_1KnapsackAssignment.html#ab4ba3de70cb7aa3ad9aaee3dd2c60b7b">is_in</a>;</div><div class="line"><a name="l00279"></a><span class="lineno"> 279</span> };</div><div class="line"><a name="l00280"></a><span class="lineno"> 280</span> </div><div class="line"><a name="l00281"></a><span class="lineno"> 281</span> <span class="comment">// ----- KnapsackItem -----</span></div><div class="line"><a name="l00282"></a><span class="lineno"> 282</span> <span class="comment">// KnapsackItem is a small struct to pair an item weight with its</span></div><div class="line"><a name="l00283"></a><span class="lineno"> 283</span> <span class="comment">// corresponding profit.</span></div><div class="line"><a name="l00284"></a><span class="lineno"> 284</span> <span class="comment">// The aim of the knapsack problem is to pack as many valuable items as</span></div><div class="line"><a name="l00285"></a><span class="lineno"> 285</span> <span class="comment">// possible. A straight forward heuristic is to take those with the greatest</span></div><div class="line"><a name="l00286"></a><span class="lineno"> 286</span> <span class="comment">// profit-per-unit-weight. This ratio is called efficiency in this</span></div><div class="line"><a name="l00287"></a><span class="lineno"> 287</span> <span class="comment">// implementation. So items will be grouped in vectors, and sorted by</span></div><div class="line"><a name="l00288"></a><span class="lineno"> 288</span> <span class="comment">// decreasing efficiency.</span></div><div class="line"><a name="l00289"></a><span class="lineno"> 289</span> <span class="comment">// Note that profits are duplicated for each dimension. This is done to</span></div><div class="line"><a name="l00290"></a><span class="lineno"> 290</span> <span class="comment">// simplify the code, especially the GetEfficiency method and vector sorting.</span></div><div class="line"><a name="l00291"></a><span class="lineno"> 291</span> <span class="comment">// As there usually are only few dimensions, the overhead should not be an</span></div><div class="line"><a name="l00292"></a><span class="lineno"> 292</span> <span class="comment">// issue.</span></div><div class="line"><a name="l00293"></a><span class="lineno"><a class="line" href="structoperations__research_1_1KnapsackItem.html"> 293</a></span> <span class="keyword">struct </span><a class="code" href="structoperations__research_1_1KnapsackItem.html">KnapsackItem</a> {</div><div class="line"><a name="l00294"></a><span class="lineno"><a class="line" href="structoperations__research_1_1KnapsackItem.html#a5ae427adb88e21ec0f883b8bbcc4b1d4"> 294</a></span>  <a class="code" href="structoperations__research_1_1KnapsackItem.html#a5ae427adb88e21ec0f883b8bbcc4b1d4">KnapsackItem</a>(<span class="keywordtype">int</span> _id, int64 _weight, int64 _profit)</div><div class="line"><a name="l00295"></a><span class="lineno"> 295</span>  : <a class="code" href="structoperations__research_1_1KnapsackItem.html#a69aae0cb6039a8a356744648c8dfb9c1">id</a>(_id), <a class="code" href="structoperations__research_1_1KnapsackItem.html#ab974e9e70c585c50c96851ecb454d882">weight</a>(_weight), <a class="code" href="structoperations__research_1_1KnapsackItem.html#a057015810b94bfb1b5efac74e9d8d487">profit</a>(_profit) {}</div><div class="line"><a name="l00296"></a><span class="lineno"><a class="line" href="structoperations__research_1_1KnapsackItem.html#a99b55b42e78cab5b85c8f411d13f32e9"> 296</a></span>  <span class="keywordtype">double</span> <a class="code" href="structoperations__research_1_1KnapsackItem.html#a99b55b42e78cab5b85c8f411d13f32e9">GetEfficiency</a>(int64 profit_max)<span class="keyword"> const </span>{</div><div class="line"><a name="l00297"></a><span class="lineno"> 297</span>  <span class="keywordflow">return</span> (<a class="code" href="structoperations__research_1_1KnapsackItem.html#ab974e9e70c585c50c96851ecb454d882">weight</a> > 0)</div><div class="line"><a name="l00298"></a><span class="lineno"> 298</span>  ? static_cast<double>(<a class="code" href="structoperations__research_1_1KnapsackItem.html#a057015810b94bfb1b5efac74e9d8d487">profit</a>) / static_cast<double>(<a class="code" href="structoperations__research_1_1KnapsackItem.html#ab974e9e70c585c50c96851ecb454d882">weight</a>)</div><div class="line"><a name="l00299"></a><span class="lineno"> 299</span>  : static_cast<double>(profit_max);</div><div class="line"><a name="l00300"></a><span class="lineno"> 300</span>  }</div><div class="line"><a name="l00301"></a><span class="lineno"> 301</span> </div><div class="line"><a name="l00302"></a><span class="lineno"> 302</span>  <span class="comment">// The 'id' field is used to retrieve the initial item in order to</span></div><div class="line"><a name="l00303"></a><span class="lineno"> 303</span>  <span class="comment">// communicate with other propagators and state.</span></div><div class="line"><a name="l00304"></a><span class="lineno"><a class="line" href="structoperations__research_1_1KnapsackItem.html#a69aae0cb6039a8a356744648c8dfb9c1"> 304</a></span>  <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="structoperations__research_1_1KnapsackItem.html#a69aae0cb6039a8a356744648c8dfb9c1">id</a>;</div><div class="line"><a name="l00305"></a><span class="lineno"><a class="line" href="structoperations__research_1_1KnapsackItem.html#ab974e9e70c585c50c96851ecb454d882"> 305</a></span>  <span class="keyword">const</span> int64 <a class="code" href="structoperations__research_1_1KnapsackItem.html#ab974e9e70c585c50c96851ecb454d882">weight</a>;</div><div class="line"><a name="l00306"></a><span class="lineno"><a class="line" href="structoperations__research_1_1KnapsackItem.html#a057015810b94bfb1b5efac74e9d8d487"> 306</a></span>  <span class="keyword">const</span> int64 <a class="code" href="structoperations__research_1_1KnapsackItem.html#a057015810b94bfb1b5efac74e9d8d487">profit</a>;</div><div class="line"><a name="l00307"></a><span class="lineno"> 307</span> };</div><div class="line"><a name="l00308"></a><span class="lineno"><a class="line" href="namespaceoperations__research.html#ab6f3adbb119982fdfb9a85d87310f255"> 308</a></span> <span class="keyword">typedef</span> <a class="code" href="structoperations__research_1_1KnapsackItem.html">KnapsackItem</a>* <a class="code" href="namespaceoperations__research.html#ab6f3adbb119982fdfb9a85d87310f255">KnapsackItemPtr</a>;</div><div class="line"><a name="l00309"></a><span class="lineno"> 309</span> </div><div class="line"><a name="l00310"></a><span class="lineno"> 310</span> <span class="comment">// ----- KnapsackSearchNode -----</span></div><div class="line"><a name="l00311"></a><span class="lineno"> 311</span> <span class="comment">// KnapsackSearchNode is a class used to describe a decision in the decision</span></div><div class="line"><a name="l00312"></a><span class="lineno"> 312</span> <span class="comment">// search tree.</span></div><div class="line"><a name="l00313"></a><span class="lineno"> 313</span> <span class="comment">// The node is defined by a pointer to the parent search node and an</span></div><div class="line"><a name="l00314"></a><span class="lineno"> 314</span> <span class="comment">// assignment (see KnapsackAssignement).</span></div><div class="line"><a name="l00315"></a><span class="lineno"> 315</span> <span class="comment">// As the current state is not explicitly stored in a search node, one should</span></div><div class="line"><a name="l00316"></a><span class="lineno"> 316</span> <span class="comment">// go through the search tree to incrementally build a partial solution from</span></div><div class="line"><a name="l00317"></a><span class="lineno"> 317</span> <span class="comment">// a previous search node.</span></div><div class="line"><a name="l00318"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchNode.html"> 318</a></span> <span class="keyword">class </span><a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a> {</div><div class="line"><a name="l00319"></a><span class="lineno"> 319</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00320"></a><span class="lineno"> 320</span>  <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html#ae4b93f14ee40150e79e0551006a93705">KnapsackSearchNode</a>(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>* <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html#aefa89c44b243d58591f919ec6e455989">parent</a>,</div><div class="line"><a name="l00321"></a><span class="lineno"> 321</span>  <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1KnapsackAssignment.html">KnapsackAssignment</a>& <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html#a4a1f5f83b8b2ec165e4e6b8cd35dd60d">assignment</a>);</div><div class="line"><a name="l00322"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchNode.html#a16d77e11bc5eac6ddd95e129a8904753"> 322</a></span>  <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html#a16d77e11bc5eac6ddd95e129a8904753">depth</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> depth_; }</div><div class="line"><a name="l00323"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchNode.html#aefa89c44b243d58591f919ec6e455989"> 323</a></span>  <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>* <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html#aefa89c44b243d58591f919ec6e455989">parent</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> parent_; }</div><div class="line"><a name="l00324"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchNode.html#a4a1f5f83b8b2ec165e4e6b8cd35dd60d"> 324</a></span>  <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1KnapsackAssignment.html">KnapsackAssignment</a>& <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html#a4a1f5f83b8b2ec165e4e6b8cd35dd60d">assignment</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> assignment_; }</div><div class="line"><a name="l00325"></a><span class="lineno"> 325</span> </div><div class="line"><a name="l00326"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchNode.html#ac7cf8a7ec95046908db026fc079d3a88"> 326</a></span>  int64 <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html#ac7cf8a7ec95046908db026fc079d3a88">current_profit</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> current_profit_; }</div><div class="line"><a name="l00327"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchNode.html#a2be03bd371b69f335778de84dc7ae5a8"> 327</a></span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html#a2be03bd371b69f335778de84dc7ae5a8">set_current_profit</a>(int64 profit) { current_profit_ = profit; }</div><div class="line"><a name="l00328"></a><span class="lineno"> 328</span> </div><div class="line"><a name="l00329"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchNode.html#a3691617cae29584af4d54edf27b1f045"> 329</a></span>  int64 <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html#a3691617cae29584af4d54edf27b1f045">profit_upper_bound</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> profit_upper_bound_; }</div><div class="line"><a name="l00330"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchNode.html#a5af222fdaf626cb0e33d2191d90b806c"> 330</a></span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html#a5af222fdaf626cb0e33d2191d90b806c">set_profit_upper_bound</a>(int64 profit) { profit_upper_bound_ = profit; }</div><div class="line"><a name="l00331"></a><span class="lineno"> 331</span> </div><div class="line"><a name="l00332"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchNode.html#a28a03df4a481f501c503fc9500eb8f47"> 332</a></span>  <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html#a28a03df4a481f501c503fc9500eb8f47">next_item_id</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> next_item_id_; }</div><div class="line"><a name="l00333"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchNode.html#aa09bf719c32bf8f662d3c609f3e72f19"> 333</a></span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html#aa09bf719c32bf8f662d3c609f3e72f19">set_next_item_id</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>) { next_item_id_ = id; }</div><div class="line"><a name="l00334"></a><span class="lineno"> 334</span> </div><div class="line"><a name="l00335"></a><span class="lineno"> 335</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00336"></a><span class="lineno"> 336</span>  <span class="comment">// 'depth' field is used to navigate efficiently through the search tree</span></div><div class="line"><a name="l00337"></a><span class="lineno"> 337</span>  <span class="comment">// (see KnapsackSearchPath).</span></div><div class="line"><a name="l00338"></a><span class="lineno"> 338</span>  <span class="keywordtype">int</span> depth_;</div><div class="line"><a name="l00339"></a><span class="lineno"> 339</span>  <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>* <span class="keyword">const</span> parent_;</div><div class="line"><a name="l00340"></a><span class="lineno"> 340</span>  <a class="code" href="structoperations__research_1_1KnapsackAssignment.html">KnapsackAssignment</a> assignment_;</div><div class="line"><a name="l00341"></a><span class="lineno"> 341</span> </div><div class="line"><a name="l00342"></a><span class="lineno"> 342</span>  <span class="comment">// 'current_profit' and 'profit_upper_bound' fields are used to sort search</span></div><div class="line"><a name="l00343"></a><span class="lineno"> 343</span>  <span class="comment">// nodes using a priority queue. That allows to pop the node with the best</span></div><div class="line"><a name="l00344"></a><span class="lineno"> 344</span>  <span class="comment">// upper bound, and more importantly to stop the search when optimality is</span></div><div class="line"><a name="l00345"></a><span class="lineno"> 345</span>  <span class="comment">// proved.</span></div><div class="line"><a name="l00346"></a><span class="lineno"> 346</span>  int64 current_profit_;</div><div class="line"><a name="l00347"></a><span class="lineno"> 347</span>  int64 profit_upper_bound_;</div><div class="line"><a name="l00348"></a><span class="lineno"> 348</span> </div><div class="line"><a name="l00349"></a><span class="lineno"> 349</span>  <span class="comment">// 'next_item_id' field allows to avoid an O(number_of_items) scan to find</span></div><div class="line"><a name="l00350"></a><span class="lineno"> 350</span>  <span class="comment">// next item to select. This is done for free by the upper bound computation.</span></div><div class="line"><a name="l00351"></a><span class="lineno"> 351</span>  <span class="keywordtype">int</span> next_item_id_;</div><div class="line"><a name="l00352"></a><span class="lineno"> 352</span> </div><div class="line"><a name="l00353"></a><span class="lineno"> 353</span>  DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>);</div><div class="line"><a name="l00354"></a><span class="lineno"> 354</span> };</div><div class="line"><a name="l00355"></a><span class="lineno"> 355</span> </div><div class="line"><a name="l00356"></a><span class="lineno"> 356</span> <span class="comment">// ----- KnapsackSearchPath -----</span></div><div class="line"><a name="l00357"></a><span class="lineno"> 357</span> <span class="comment">// KnapsackSearchPath is a small class used to represent the path between a</span></div><div class="line"><a name="l00358"></a><span class="lineno"> 358</span> <span class="comment">// node to another node in the search tree.</span></div><div class="line"><a name="l00359"></a><span class="lineno"> 359</span> <span class="comment">// As the solution state is not stored for each search node, the state should</span></div><div class="line"><a name="l00360"></a><span class="lineno"> 360</span> <span class="comment">// be rebuilt at each node. One simple solution is to apply all decisions</span></div><div class="line"><a name="l00361"></a><span class="lineno"> 361</span> <span class="comment">// between the node 'to' and the root. This can be computed in</span></div><div class="line"><a name="l00362"></a><span class="lineno"> 362</span> <span class="comment">// O(number_of_items).</span></div><div class="line"><a name="l00363"></a><span class="lineno"> 363</span> <span class="comment">//</span></div><div class="line"><a name="l00364"></a><span class="lineno"> 364</span> <span class="comment">// However, it is possible to achieve better average complexity. Two</span></div><div class="line"><a name="l00365"></a><span class="lineno"> 365</span> <span class="comment">// consecutively explored nodes are usually close enough (i.e., much less than</span></div><div class="line"><a name="l00366"></a><span class="lineno"> 366</span> <span class="comment">// number_of_items) to benefit from an incremental update from the node</span></div><div class="line"><a name="l00367"></a><span class="lineno"> 367</span> <span class="comment">// 'from' to the node 'to'.</span></div><div class="line"><a name="l00368"></a><span class="lineno"> 368</span> <span class="comment">//</span></div><div class="line"><a name="l00369"></a><span class="lineno"> 369</span> <span class="comment">// The 'via' field is the common parent of 'from' field and 'to' field.</span></div><div class="line"><a name="l00370"></a><span class="lineno"> 370</span> <span class="comment">// So the state can be built by reverting all decisions from 'from' to 'via'</span></div><div class="line"><a name="l00371"></a><span class="lineno"> 371</span> <span class="comment">// and then applying all decisions from 'via' to 'to'.</span></div><div class="line"><a name="l00372"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchPath.html"> 372</a></span> <span class="keyword">class </span><a class="code" href="classoperations__research_1_1KnapsackSearchPath.html">KnapsackSearchPath</a> {</div><div class="line"><a name="l00373"></a><span class="lineno"> 373</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00374"></a><span class="lineno"> 374</span>  <a class="code" href="classoperations__research_1_1KnapsackSearchPath.html#a459653bd55ab09a55714f660419367b1">KnapsackSearchPath</a>(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>& <a class="code" href="classoperations__research_1_1KnapsackSearchPath.html#abfbc25d180ab655ca72aa1dda80b5e1b">from</a>,</div><div class="line"><a name="l00375"></a><span class="lineno"> 375</span>  <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>& <a class="code" href="classoperations__research_1_1KnapsackSearchPath.html#a070dcd6139b7a475886f061cefb7fd78">to</a>);</div><div class="line"><a name="l00376"></a><span class="lineno"> 376</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackSearchPath.html#a91d3f4f27442d3ee1f748811d5d0d964">Init</a>();</div><div class="line"><a name="l00377"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchPath.html#abfbc25d180ab655ca72aa1dda80b5e1b"> 377</a></span>  <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>& <a class="code" href="classoperations__research_1_1KnapsackSearchPath.html#abfbc25d180ab655ca72aa1dda80b5e1b">from</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> from_; }</div><div class="line"><a name="l00378"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchPath.html#afede2909f269364002ffe722f4bed1b2"> 378</a></span>  <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>& <a class="code" href="classoperations__research_1_1KnapsackSearchPath.html#afede2909f269364002ffe722f4bed1b2">via</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> *via_; }</div><div class="line"><a name="l00379"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackSearchPath.html#a070dcd6139b7a475886f061cefb7fd78"> 379</a></span>  <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>& <a class="code" href="classoperations__research_1_1KnapsackSearchPath.html#a070dcd6139b7a475886f061cefb7fd78">to</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> to_; }</div><div class="line"><a name="l00380"></a><span class="lineno"> 380</span>  <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>* <a class="code" href="classoperations__research_1_1KnapsackSearchPath.html#a3c129707bd16aea17d0eb3ad6c4e10e5">MoveUpToDepth</a>(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>& node,</div><div class="line"><a name="l00381"></a><span class="lineno"> 381</span>  <span class="keywordtype">int</span> depth) <span class="keyword">const</span>;</div><div class="line"><a name="l00382"></a><span class="lineno"> 382</span> </div><div class="line"><a name="l00383"></a><span class="lineno"> 383</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00384"></a><span class="lineno"> 384</span>  <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>& from_;</div><div class="line"><a name="l00385"></a><span class="lineno"> 385</span>  <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>* via_; <span class="comment">// Computed in 'Init'.</span></div><div class="line"><a name="l00386"></a><span class="lineno"> 386</span>  <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>& to_;</div><div class="line"><a name="l00387"></a><span class="lineno"> 387</span> </div><div class="line"><a name="l00388"></a><span class="lineno"> 388</span>  DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1KnapsackSearchPath.html">KnapsackSearchPath</a>);</div><div class="line"><a name="l00389"></a><span class="lineno"> 389</span> };</div><div class="line"><a name="l00390"></a><span class="lineno"> 390</span> </div><div class="line"><a name="l00391"></a><span class="lineno"> 391</span> <span class="comment">// ----- KnapsackState -----</span></div><div class="line"><a name="l00392"></a><span class="lineno"> 392</span> <span class="comment">// KnapsackState represents a partial solution to the knapsack problem.</span></div><div class="line"><a name="l00393"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackState.html"> 393</a></span> <span class="keyword">class </span><a class="code" href="classoperations__research_1_1KnapsackState.html">KnapsackState</a> {</div><div class="line"><a name="l00394"></a><span class="lineno"> 394</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00395"></a><span class="lineno"> 395</span>  <a class="code" href="classoperations__research_1_1KnapsackState.html#adb083eb4c9bb7413cff7262e58c5abe0">KnapsackState</a>();</div><div class="line"><a name="l00396"></a><span class="lineno"> 396</span> </div><div class="line"><a name="l00397"></a><span class="lineno"> 397</span>  <span class="comment">// Initializes vectors with number_of_items set to false (i.e. not bound yet).</span></div><div class="line"><a name="l00398"></a><span class="lineno"> 398</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackState.html#a6b5c2748ef2668630c5bfdfa56093e95">Init</a>(<span class="keywordtype">int</span> number_of_items);</div><div class="line"><a name="l00399"></a><span class="lineno"> 399</span>  <span class="comment">// Updates the state by applying or reverting a decision.</span></div><div class="line"><a name="l00400"></a><span class="lineno"> 400</span>  <span class="comment">// Returns false if fails, i.e. trying to apply an inconsistent decision</span></div><div class="line"><a name="l00401"></a><span class="lineno"> 401</span>  <span class="comment">// to an already assigned item.</span></div><div class="line"><a name="l00402"></a><span class="lineno"> 402</span>  <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1KnapsackState.html#a3fa5da9a819f219f4c51e410fe12c1a3">UpdateState</a>(<span class="keywordtype">bool</span> revert, <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1KnapsackAssignment.html">KnapsackAssignment</a>& assignment);</div><div class="line"><a name="l00403"></a><span class="lineno"> 403</span> </div><div class="line"><a name="l00404"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackState.html#aa819237f8d1a2dddad038ac0c8efa495"> 404</a></span>  <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1KnapsackState.html#aa819237f8d1a2dddad038ac0c8efa495">GetNumberOfItems</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> is_bound_.size(); }</div><div class="line"><a name="l00405"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackState.html#ad5b6fe4a0bbfa609c73c8802379d50e5"> 405</a></span>  <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1KnapsackState.html#ad5b6fe4a0bbfa609c73c8802379d50e5">is_bound</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> is_bound_.at(<span class="keywordtype">id</span>); }</div><div class="line"><a name="l00406"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackState.html#a9365eaaee4e8e05325f0f12a50a94297"> 406</a></span>  <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1KnapsackState.html#a9365eaaee4e8e05325f0f12a50a94297">is_in</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> is_in_.at(<span class="keywordtype">id</span>); }</div><div class="line"><a name="l00407"></a><span class="lineno"> 407</span> </div><div class="line"><a name="l00408"></a><span class="lineno"> 408</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00409"></a><span class="lineno"> 409</span>  <span class="comment">// Vectors 'is_bound_' and 'is_in_' contain a boolean value for each item.</span></div><div class="line"><a name="l00410"></a><span class="lineno"> 410</span>  <span class="comment">// 'is_bound_(item_i)' is false when there is no decision for item_i yet.</span></div><div class="line"><a name="l00411"></a><span class="lineno"> 411</span>  <span class="comment">// When item_i is bound, 'is_in_(item_i)' represents the presence (true) or</span></div><div class="line"><a name="l00412"></a><span class="lineno"> 412</span>  <span class="comment">// the absence (false) of item_i in the current solution.</span></div><div class="line"><a name="l00413"></a><span class="lineno"> 413</span>  std::vector<bool> is_bound_;</div><div class="line"><a name="l00414"></a><span class="lineno"> 414</span>  std::vector<bool> is_in_;</div><div class="line"><a name="l00415"></a><span class="lineno"> 415</span> </div><div class="line"><a name="l00416"></a><span class="lineno"> 416</span>  DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1KnapsackState.html">KnapsackState</a>);</div><div class="line"><a name="l00417"></a><span class="lineno"> 417</span> };</div><div class="line"><a name="l00418"></a><span class="lineno"> 418</span> </div><div class="line"><a name="l00419"></a><span class="lineno"> 419</span> <span class="comment">// ----- KnapsackPropagator -----</span></div><div class="line"><a name="l00420"></a><span class="lineno"> 420</span> <span class="comment">// KnapsackPropagator is the base class for modeling and propagating a</span></div><div class="line"><a name="l00421"></a><span class="lineno"> 421</span> <span class="comment">// constraint given an assignment.</span></div><div class="line"><a name="l00422"></a><span class="lineno"> 422</span> <span class="comment">//</span></div><div class="line"><a name="l00423"></a><span class="lineno"> 423</span> <span class="comment">// When some work has to be done both by the base and the derived class,</span></div><div class="line"><a name="l00424"></a><span class="lineno"> 424</span> <span class="comment">// a protected pure virtual method ending by 'Propagator' is defined.</span></div><div class="line"><a name="l00425"></a><span class="lineno"> 425</span> <span class="comment">// For instance, 'Init' creates a vector of items, and then calls</span></div><div class="line"><a name="l00426"></a><span class="lineno"> 426</span> <span class="comment">// 'InitPropagator' to let the derived class perform its own initialization.</span></div><div class="line"><a name="l00427"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackPropagator.html"> 427</a></span> <span class="keyword">class </span><a class="code" href="classoperations__research_1_1KnapsackPropagator.html">KnapsackPropagator</a> {</div><div class="line"><a name="l00428"></a><span class="lineno"> 428</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00429"></a><span class="lineno"> 429</span>  <span class="keyword">explicit</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#a8d55d0c6ac3f05b72100f1635cfd2250">KnapsackPropagator</a>(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackState.html">KnapsackState</a>& <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#af652548ebe8eeb5b0abfb900cf7f2927">state</a>);</div><div class="line"><a name="l00430"></a><span class="lineno"> 430</span>  <span class="keyword">virtual</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#a510e0ee59d597e16200ee04ab2e417ac">~KnapsackPropagator</a>();</div><div class="line"><a name="l00431"></a><span class="lineno"> 431</span> </div><div class="line"><a name="l00432"></a><span class="lineno"> 432</span>  <span class="comment">// Initializes data structure and then calls InitPropagator.</span></div><div class="line"><a name="l00433"></a><span class="lineno"> 433</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#aeb74436e19f4e74afdeb17f623bb0335">Init</a>(<span class="keyword">const</span> std::vector<int64>& profits,</div><div class="line"><a name="l00434"></a><span class="lineno"> 434</span>  <span class="keyword">const</span> std::vector<int64>& weights);</div><div class="line"><a name="l00435"></a><span class="lineno"> 435</span> </div><div class="line"><a name="l00436"></a><span class="lineno"> 436</span>  <span class="comment">// Updates data structure and then calls UpdatePropagator.</span></div><div class="line"><a name="l00437"></a><span class="lineno"> 437</span>  <span class="comment">// Returns false when failure.</span></div><div class="line"><a name="l00438"></a><span class="lineno"> 438</span>  <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#a5843f83c839a81d039724b6d49ba325a">Update</a>(<span class="keywordtype">bool</span> revert, <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1KnapsackAssignment.html">KnapsackAssignment</a>& assignment);</div><div class="line"><a name="l00439"></a><span class="lineno"> 439</span>  <span class="comment">// ComputeProfitBounds should set 'profit_lower_bound_' and</span></div><div class="line"><a name="l00440"></a><span class="lineno"> 440</span>  <span class="comment">// 'profit_upper_bound_' which are constraint specific.</span></div><div class="line"><a name="l00441"></a><span class="lineno"> 441</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#a8133fbb05961e760ed907e1f599966d8">ComputeProfitBounds</a>() = 0;</div><div class="line"><a name="l00442"></a><span class="lineno"> 442</span>  <span class="comment">// Returns the id of next item to assign.</span></div><div class="line"><a name="l00443"></a><span class="lineno"> 443</span>  <span class="comment">// Returns kNoSelection when all items are bound.</span></div><div class="line"><a name="l00444"></a><span class="lineno"> 444</span>  <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#a44b8bedd2218a210512ab3f8f3172312">GetNextItemId</a>() <span class="keyword">const</span> = 0;</div><div class="line"><a name="l00445"></a><span class="lineno"> 445</span> </div><div class="line"><a name="l00446"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackPropagator.html#a49bb0497f50479663fc4b37bb4a08268"> 446</a></span>  int64 <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#a49bb0497f50479663fc4b37bb4a08268">current_profit</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> current_profit_; }</div><div class="line"><a name="l00447"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackPropagator.html#a11ea8cfd2264c8f033d59e2848f9a871"> 447</a></span>  int64 <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#a11ea8cfd2264c8f033d59e2848f9a871">profit_lower_bound</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> profit_lower_bound_; }</div><div class="line"><a name="l00448"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackPropagator.html#aaa95c66b22228756739735f4574cb4a1"> 448</a></span>  int64 <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#aaa95c66b22228756739735f4574cb4a1">profit_upper_bound</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> profit_upper_bound_; }</div><div class="line"><a name="l00449"></a><span class="lineno"> 449</span> </div><div class="line"><a name="l00450"></a><span class="lineno"> 450</span>  <span class="comment">// Copies the current state into 'solution'.</span></div><div class="line"><a name="l00451"></a><span class="lineno"> 451</span>  <span class="comment">// All unbound items are set to false (i.e. not in the knapsack).</span></div><div class="line"><a name="l00452"></a><span class="lineno"> 452</span>  <span class="comment">// When 'has_one_propagator' is true, CopyCurrentSolutionPropagator is called</span></div><div class="line"><a name="l00453"></a><span class="lineno"> 453</span>  <span class="comment">// to have a better solution. When there is only one propagator</span></div><div class="line"><a name="l00454"></a><span class="lineno"> 454</span>  <span class="comment">// there is no need to check the solution with other propagators, so the</span></div><div class="line"><a name="l00455"></a><span class="lineno"> 455</span>  <span class="comment">// partial solution can be smartly completed.</span></div><div class="line"><a name="l00456"></a><span class="lineno"> 456</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#a4a8ef9517e0c8bf1eb1e450b72aa4e05">CopyCurrentStateToSolution</a>(<span class="keywordtype">bool</span> has_one_propagator,</div><div class="line"><a name="l00457"></a><span class="lineno"> 457</span>  std::vector<bool>* solution) <span class="keyword">const</span>;</div><div class="line"><a name="l00458"></a><span class="lineno"> 458</span> </div><div class="line"><a name="l00459"></a><span class="lineno"> 459</span>  <span class="keyword">protected</span>:</div><div class="line"><a name="l00460"></a><span class="lineno"> 460</span>  <span class="comment">// Initializes data structure. This method is called after initialization</span></div><div class="line"><a name="l00461"></a><span class="lineno"> 461</span>  <span class="comment">// of KnapsackPropagator data structure.</span></div><div class="line"><a name="l00462"></a><span class="lineno"> 462</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#aeb99e95f19c68257f0b450cfff8fc3d0">InitPropagator</a>() = 0;</div><div class="line"><a name="l00463"></a><span class="lineno"> 463</span> </div><div class="line"><a name="l00464"></a><span class="lineno"> 464</span>  <span class="comment">// Updates internal data structure incrementally. This method is called</span></div><div class="line"><a name="l00465"></a><span class="lineno"> 465</span>  <span class="comment">// after update of KnapsackPropagator data structure.</span></div><div class="line"><a name="l00466"></a><span class="lineno"> 466</span>  <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#abaf6d9225cde1b0d83d1a54299705ccb">UpdatePropagator</a>(<span class="keywordtype">bool</span> revert,</div><div class="line"><a name="l00467"></a><span class="lineno"> 467</span>  <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1KnapsackAssignment.html">KnapsackAssignment</a>& assignment) = 0;</div><div class="line"><a name="l00468"></a><span class="lineno"> 468</span> </div><div class="line"><a name="l00469"></a><span class="lineno"> 469</span>  <span class="comment">// Copies the current state into 'solution'.</span></div><div class="line"><a name="l00470"></a><span class="lineno"> 470</span>  <span class="comment">// Only unbound items have to be copied as CopyCurrentSolution was already</span></div><div class="line"><a name="l00471"></a><span class="lineno"> 471</span>  <span class="comment">// called with current state.</span></div><div class="line"><a name="l00472"></a><span class="lineno"> 472</span>  <span class="comment">// This method is useful when a propagator is able to find a better solution</span></div><div class="line"><a name="l00473"></a><span class="lineno"> 473</span>  <span class="comment">// than the blind instantiation to false of unbound items.</span></div><div class="line"><a name="l00474"></a><span class="lineno"> 474</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#a95551ecb408465b2fcf57aaaac393336">CopyCurrentStateToSolutionPropagator</a>(</div><div class="line"><a name="l00475"></a><span class="lineno"> 475</span>  std::vector<bool>* solution) <span class="keyword">const</span> = 0;</div><div class="line"><a name="l00476"></a><span class="lineno"> 476</span> </div><div class="line"><a name="l00477"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackPropagator.html#af652548ebe8eeb5b0abfb900cf7f2927"> 477</a></span>  <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackState.html">KnapsackState</a>& <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#af652548ebe8eeb5b0abfb900cf7f2927">state</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> state_; }</div><div class="line"><a name="l00478"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackPropagator.html#ac6a4643a2599c05708695addf803e52d"> 478</a></span>  <span class="keyword">const</span> std::vector<KnapsackItemPtr>& <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#ac6a4643a2599c05708695addf803e52d">items</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> items_; }</div><div class="line"><a name="l00479"></a><span class="lineno"> 479</span> </div><div class="line"><a name="l00480"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackPropagator.html#a697a86fbe4ab12732c8e6972ebdd5947"> 480</a></span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#a697a86fbe4ab12732c8e6972ebdd5947">set_profit_lower_bound</a>(int64 profit) { profit_lower_bound_ = profit; }</div><div class="line"><a name="l00481"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackPropagator.html#a7bbc1ccc57318641a01cd253299f5861"> 481</a></span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#a7bbc1ccc57318641a01cd253299f5861">set_profit_upper_bound</a>(int64 profit) { profit_upper_bound_ = profit; }</div><div class="line"><a name="l00482"></a><span class="lineno"> 482</span> </div><div class="line"><a name="l00483"></a><span class="lineno"> 483</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00484"></a><span class="lineno"> 484</span>  std::vector<KnapsackItemPtr> items_;</div><div class="line"><a name="l00485"></a><span class="lineno"> 485</span>  int64 current_profit_;</div><div class="line"><a name="l00486"></a><span class="lineno"> 486</span>  int64 profit_lower_bound_;</div><div class="line"><a name="l00487"></a><span class="lineno"> 487</span>  int64 profit_upper_bound_;</div><div class="line"><a name="l00488"></a><span class="lineno"> 488</span>  <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackState.html">KnapsackState</a>& state_;</div><div class="line"><a name="l00489"></a><span class="lineno"> 489</span> </div><div class="line"><a name="l00490"></a><span class="lineno"> 490</span>  DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1KnapsackPropagator.html">KnapsackPropagator</a>);</div><div class="line"><a name="l00491"></a><span class="lineno"> 491</span> };</div><div class="line"><a name="l00492"></a><span class="lineno"> 492</span> </div><div class="line"><a name="l00493"></a><span class="lineno"> 493</span> <span class="comment">// ----- KnapsackCapacityPropagator -----</span></div><div class="line"><a name="l00494"></a><span class="lineno"> 494</span> <span class="comment">// KnapsackCapacityPropagator is a KnapsackPropagator used to enforce</span></div><div class="line"><a name="l00495"></a><span class="lineno"> 495</span> <span class="comment">// a capacity constraint.</span></div><div class="line"><a name="l00496"></a><span class="lineno"> 496</span> <span class="comment">// As a KnapsackPropagator is supposed to compute profit lower and upper</span></div><div class="line"><a name="l00497"></a><span class="lineno"> 497</span> <span class="comment">// bounds, and get the next item to select, it can be seen as a 0-1 Knapsack</span></div><div class="line"><a name="l00498"></a><span class="lineno"> 498</span> <span class="comment">// solver. The most efficient way to compute the upper bound is to iterate on</span></div><div class="line"><a name="l00499"></a><span class="lineno"> 499</span> <span class="comment">// items in profit-per-unit-weight decreasing order. The break item is</span></div><div class="line"><a name="l00500"></a><span class="lineno"> 500</span> <span class="comment">// commonly defined as the first item for which there is not enough remaining</span></div><div class="line"><a name="l00501"></a><span class="lineno"> 501</span> <span class="comment">// capacity. Selecting this break item as the next-item-to-assign usually</span></div><div class="line"><a name="l00502"></a><span class="lineno"> 502</span> <span class="comment">// gives the best results (see Greenberg & Hegerich).</span></div><div class="line"><a name="l00503"></a><span class="lineno"> 503</span> <span class="comment">//</span></div><div class="line"><a name="l00504"></a><span class="lineno"> 504</span> <span class="comment">// This is exactly what is implemented in this class.</span></div><div class="line"><a name="l00505"></a><span class="lineno"> 505</span> <span class="comment">//</span></div><div class="line"><a name="l00506"></a><span class="lineno"> 506</span> <span class="comment">// When there is only one propagator, it is possible to compute a better</span></div><div class="line"><a name="l00507"></a><span class="lineno"> 507</span> <span class="comment">// profit lower bound almost for free. During the scan to find the</span></div><div class="line"><a name="l00508"></a><span class="lineno"> 508</span> <span class="comment">// break element all unbound items are added just as if they were part of</span></div><div class="line"><a name="l00509"></a><span class="lineno"> 509</span> <span class="comment">// the current solution. This is used in both ComputeProfitBounds and</span></div><div class="line"><a name="l00510"></a><span class="lineno"> 510</span> <span class="comment">// CopyCurrentSolutionPropagator.</span></div><div class="line"><a name="l00511"></a><span class="lineno"> 511</span> <span class="comment">// For incrementality reasons, the ith item should be accessible in O(1). That's</span></div><div class="line"><a name="l00512"></a><span class="lineno"> 512</span> <span class="comment">// the reason why the item vector has to be duplicated 'sorted_items_'.</span></div><div class="line"><a name="l00513"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackCapacityPropagator.html"> 513</a></span> <span class="keyword">class </span><a class="code" href="classoperations__research_1_1KnapsackCapacityPropagator.html">KnapsackCapacityPropagator</a> : <span class="keyword">public</span> <a class="code" href="classoperations__research_1_1KnapsackPropagator.html">KnapsackPropagator</a> {</div><div class="line"><a name="l00514"></a><span class="lineno"> 514</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00515"></a><span class="lineno"> 515</span>  <a class="code" href="classoperations__research_1_1KnapsackCapacityPropagator.html#a9dd517fbac9988f24173eaf86238976e">KnapsackCapacityPropagator</a>(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackState.html">KnapsackState</a>& <a class="code" href="classoperations__research_1_1KnapsackPropagator.html#af652548ebe8eeb5b0abfb900cf7f2927">state</a>, int64 capacity);</div><div class="line"><a name="l00516"></a><span class="lineno"> 516</span>  <a class="code" href="classoperations__research_1_1KnapsackCapacityPropagator.html#a33d39340cd8d61263b20361c8b774832">~KnapsackCapacityPropagator</a>() <span class="keyword">override</span>;</div><div class="line"><a name="l00517"></a><span class="lineno"> 517</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackCapacityPropagator.html#af1d7d1e175e652c64962af490ab42247">ComputeProfitBounds</a>() <span class="keyword">override</span>;</div><div class="line"><a name="l00518"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackCapacityPropagator.html#aeea8be32ceca77b5eaf9139df5e4ea4a"> 518</a></span>  <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1KnapsackCapacityPropagator.html#aeea8be32ceca77b5eaf9139df5e4ea4a">GetNextItemId</a>()<span class="keyword"> const override </span>{ <span class="keywordflow">return</span> break_item_id_; }</div><div class="line"><a name="l00519"></a><span class="lineno"> 519</span> </div><div class="line"><a name="l00520"></a><span class="lineno"> 520</span>  <span class="keyword">protected</span>:</div><div class="line"><a name="l00521"></a><span class="lineno"> 521</span>  <span class="comment">// Initializes KnapsackCapacityPropagator (e.g., sort items in decreasing</span></div><div class="line"><a name="l00522"></a><span class="lineno"> 522</span>  <span class="comment">// order).</span></div><div class="line"><a name="l00523"></a><span class="lineno"> 523</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackCapacityPropagator.html#a59eff70af400b44d87d57b90047ada6e">InitPropagator</a>() <span class="keyword">override</span>;</div><div class="line"><a name="l00524"></a><span class="lineno"> 524</span>  <span class="comment">// Updates internal data structure incrementally (i.e., 'consumed_capacity_')</span></div><div class="line"><a name="l00525"></a><span class="lineno"> 525</span>  <span class="comment">// to avoid a O(number_of_items) scan.</span></div><div class="line"><a name="l00526"></a><span class="lineno"> 526</span>  <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1KnapsackCapacityPropagator.html#a944c99875dbcc49d557c129f4077799b">UpdatePropagator</a>(<span class="keywordtype">bool</span> revert,</div><div class="line"><a name="l00527"></a><span class="lineno"> 527</span>  <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1KnapsackAssignment.html">KnapsackAssignment</a>& assignment) <span class="keyword">override</span>;</div><div class="line"><a name="l00528"></a><span class="lineno"> 528</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackCapacityPropagator.html#a03745304f7f106699428e4ed6efdef9d">CopyCurrentStateToSolutionPropagator</a>(</div><div class="line"><a name="l00529"></a><span class="lineno"> 529</span>  std::vector<bool>* solution) <span class="keyword">const override</span>;</div><div class="line"><a name="l00530"></a><span class="lineno"> 530</span> </div><div class="line"><a name="l00531"></a><span class="lineno"> 531</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00532"></a><span class="lineno"> 532</span>  <span class="comment">// An obvious additional profit upper bound corresponds to the linear</span></div><div class="line"><a name="l00533"></a><span class="lineno"> 533</span>  <span class="comment">// relaxation: remaining_capacity * efficiency of the break item.</span></div><div class="line"><a name="l00534"></a><span class="lineno"> 534</span>  <span class="comment">// It is possible to do better in O(1), using Martello-Toth bound U2.</span></div><div class="line"><a name="l00535"></a><span class="lineno"> 535</span>  <span class="comment">// The main idea is to enforce integrality constraint on the break item,</span></div><div class="line"><a name="l00536"></a><span class="lineno"> 536</span>  <span class="comment">// ie. either the break item is part of the solution, either it is not.</span></div><div class="line"><a name="l00537"></a><span class="lineno"> 537</span>  <span class="comment">// So basically the linear relaxation is done on the item before the break</span></div><div class="line"><a name="l00538"></a><span class="lineno"> 538</span>  <span class="comment">// item, or the one after the break item.</span></div><div class="line"><a name="l00539"></a><span class="lineno"> 539</span>  <span class="comment">// This is what GetAdditionalProfit method implements.</span></div><div class="line"><a name="l00540"></a><span class="lineno"> 540</span>  int64 GetAdditionalProfit(int64 remaining_capacity, <span class="keywordtype">int</span> break_item_id) <span class="keyword">const</span>;</div><div class="line"><a name="l00541"></a><span class="lineno"> 541</span> </div><div class="line"><a name="l00542"></a><span class="lineno"> 542</span>  <span class="keyword">const</span> int64 capacity_;</div><div class="line"><a name="l00543"></a><span class="lineno"> 543</span>  int64 consumed_capacity_;</div><div class="line"><a name="l00544"></a><span class="lineno"> 544</span>  <span class="keywordtype">int</span> break_item_id_;</div><div class="line"><a name="l00545"></a><span class="lineno"> 545</span>  std::vector<KnapsackItemPtr> sorted_items_;</div><div class="line"><a name="l00546"></a><span class="lineno"> 546</span>  int64 profit_max_;</div><div class="line"><a name="l00547"></a><span class="lineno"> 547</span> </div><div class="line"><a name="l00548"></a><span class="lineno"> 548</span>  DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1KnapsackCapacityPropagator.html">KnapsackCapacityPropagator</a>);</div><div class="line"><a name="l00549"></a><span class="lineno"> 549</span> };</div><div class="line"><a name="l00550"></a><span class="lineno"> 550</span> </div><div class="line"><a name="l00551"></a><span class="lineno"> 551</span> <span class="comment">// ----- BaseKnapsackSolver -----</span></div><div class="line"><a name="l00552"></a><span class="lineno"> 552</span> <span class="comment">// This is the base class for knapsack solvers.</span></div><div class="line"><a name="l00553"></a><span class="lineno"><a class="line" href="classoperations__research_1_1BaseKnapsackSolver.html"> 553</a></span> <span class="keyword">class </span><a class="code" href="classoperations__research_1_1BaseKnapsackSolver.html">BaseKnapsackSolver</a> {</div><div class="line"><a name="l00554"></a><span class="lineno"> 554</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00555"></a><span class="lineno"><a class="line" href="classoperations__research_1_1BaseKnapsackSolver.html#a507afd9932799f0be34f34605cd5ffee"> 555</a></span>  <span class="keyword">explicit</span> <a class="code" href="classoperations__research_1_1BaseKnapsackSolver.html#a507afd9932799f0be34f34605cd5ffee">BaseKnapsackSolver</a>(<span class="keyword">const</span> std::string& solver_name)</div><div class="line"><a name="l00556"></a><span class="lineno"> 556</span>  : solver_name_(solver_name) {}</div><div class="line"><a name="l00557"></a><span class="lineno"><a class="line" href="classoperations__research_1_1BaseKnapsackSolver.html#a5f685ec61d9de86d57bdc53124c08b12"> 557</a></span>  <span class="keyword">virtual</span> <a class="code" href="classoperations__research_1_1BaseKnapsackSolver.html#a5f685ec61d9de86d57bdc53124c08b12">~BaseKnapsackSolver</a>() {}</div><div class="line"><a name="l00558"></a><span class="lineno"> 558</span> </div><div class="line"><a name="l00559"></a><span class="lineno"> 559</span>  <span class="comment">// Initializes the solver and enters the problem to be solved.</span></div><div class="line"><a name="l00560"></a><span class="lineno"> 560</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1BaseKnapsackSolver.html#a3e8f72facec15537065c1625e647d58b">Init</a>(<span class="keyword">const</span> std::vector<int64>& profits,</div><div class="line"><a name="l00561"></a><span class="lineno"> 561</span>  <span class="keyword">const</span> std::vector<std::vector<int64> >& weights,</div><div class="line"><a name="l00562"></a><span class="lineno"> 562</span>  <span class="keyword">const</span> std::vector<int64>& capacities) = 0;</div><div class="line"><a name="l00563"></a><span class="lineno"> 563</span> </div><div class="line"><a name="l00564"></a><span class="lineno"> 564</span>  <span class="comment">// Gets the lower and upper bound when the item is in or out of the knapsack.</span></div><div class="line"><a name="l00565"></a><span class="lineno"> 565</span>  <span class="comment">// To ensure objects are correctly initialized, this method should not be</span></div><div class="line"><a name="l00566"></a><span class="lineno"> 566</span>  <span class="comment">// called before ::Init.</span></div><div class="line"><a name="l00567"></a><span class="lineno"> 567</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1BaseKnapsackSolver.html#a381cc9d7b544a8ec4727f9618f0b4f8f">GetLowerAndUpperBoundWhenItem</a>(<span class="keywordtype">int</span> item_id, <span class="keywordtype">bool</span> is_item_in,</div><div class="line"><a name="l00568"></a><span class="lineno"> 568</span>  int64* lower_bound,</div><div class="line"><a name="l00569"></a><span class="lineno"> 569</span>  int64* upper_bound);</div><div class="line"><a name="l00570"></a><span class="lineno"> 570</span> </div><div class="line"><a name="l00571"></a><span class="lineno"> 571</span>  <span class="comment">// Solves the problem and returns the profit of the optimal solution.</span></div><div class="line"><a name="l00572"></a><span class="lineno"> 572</span>  <span class="keyword">virtual</span> int64 <a class="code" href="classoperations__research_1_1BaseKnapsackSolver.html#a952deb24e032890d2781e52fedb70efa">Solve</a>(TimeLimit* time_limit, <span class="keywordtype">bool</span>* is_solution_optimal) = 0;</div><div class="line"><a name="l00573"></a><span class="lineno"> 573</span> </div><div class="line"><a name="l00574"></a><span class="lineno"> 574</span>  <span class="comment">// Returns true if the item 'item_id' is packed in the optimal knapsack.</span></div><div class="line"><a name="l00575"></a><span class="lineno"> 575</span>  <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1BaseKnapsackSolver.html#a08bf62b91f6cf3fca10a504f7dd278a6">best_solution</a>(<span class="keywordtype">int</span> item_id) <span class="keyword">const</span> = 0;</div><div class="line"><a name="l00576"></a><span class="lineno"> 576</span> </div><div class="line"><a name="l00577"></a><span class="lineno"><a class="line" href="classoperations__research_1_1BaseKnapsackSolver.html#ae19aff92b4b38e712ead1cfcafd81f03"> 577</a></span>  <span class="keyword">virtual</span> std::string <a class="code" href="classoperations__research_1_1BaseKnapsackSolver.html#ae19aff92b4b38e712ead1cfcafd81f03">GetName</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> solver_name_; }</div><div class="line"><a name="l00578"></a><span class="lineno"> 578</span> </div><div class="line"><a name="l00579"></a><span class="lineno"> 579</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00580"></a><span class="lineno"> 580</span>  <span class="keyword">const</span> std::string solver_name_;</div><div class="line"><a name="l00581"></a><span class="lineno"> 581</span> };</div><div class="line"><a name="l00582"></a><span class="lineno"> 582</span> </div><div class="line"><a name="l00583"></a><span class="lineno"> 583</span> <span class="comment">// ----- KnapsackGenericSolver -----</span></div><div class="line"><a name="l00584"></a><span class="lineno"> 584</span> <span class="comment">// KnapsackGenericSolver is the multi-dimensional knapsack solver class.</span></div><div class="line"><a name="l00585"></a><span class="lineno"> 585</span> <span class="comment">// In the current implementation, the next item to assign is given by the</span></div><div class="line"><a name="l00586"></a><span class="lineno"> 586</span> <span class="comment">// master propagator. Using SetMasterPropagator allows changing the default</span></div><div class="line"><a name="l00587"></a><span class="lineno"> 587</span> <span class="comment">// (propagator of the first dimension), and selecting another dimension when</span></div><div class="line"><a name="l00588"></a><span class="lineno"> 588</span> <span class="comment">// more constrained.</span></div><div class="line"><a name="l00589"></a><span class="lineno"> 589</span> <span class="comment">// TODO(user): In the case of a multi-dimensional knapsack problem, implement</span></div><div class="line"><a name="l00590"></a><span class="lineno"> 590</span> <span class="comment">// an aggregated propagator to combine all dimensions and give a better guide</span></div><div class="line"><a name="l00591"></a><span class="lineno"> 591</span> <span class="comment">// to select the next item (see, for instance, Dobson's aggregated efficiency).</span></div><div class="line"><a name="l00592"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackGenericSolver.html"> 592</a></span> <span class="keyword">class </span><a class="code" href="classoperations__research_1_1KnapsackGenericSolver.html">KnapsackGenericSolver</a> : <span class="keyword">public</span> <a class="code" href="classoperations__research_1_1BaseKnapsackSolver.html">BaseKnapsackSolver</a> {</div><div class="line"><a name="l00593"></a><span class="lineno"> 593</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00594"></a><span class="lineno"> 594</span>  <span class="keyword">explicit</span> <a class="code" href="classoperations__research_1_1KnapsackGenericSolver.html#ad92ca41f734bcbc35ef295f8a4bd556c">KnapsackGenericSolver</a>(<span class="keyword">const</span> std::string& solver_name);</div><div class="line"><a name="l00595"></a><span class="lineno"> 595</span>  <a class="code" href="classoperations__research_1_1KnapsackGenericSolver.html#a7635ee76659f4e0117709aab3809460b">~KnapsackGenericSolver</a>() <span class="keyword">override</span>;</div><div class="line"><a name="l00596"></a><span class="lineno"> 596</span> </div><div class="line"><a name="l00597"></a><span class="lineno"> 597</span>  <span class="comment">// Initializes the solver and enters the problem to be solved.</span></div><div class="line"><a name="l00598"></a><span class="lineno"> 598</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackGenericSolver.html#af9635774fd7761f62ee92e64205034b3">Init</a>(<span class="keyword">const</span> std::vector<int64>& profits,</div><div class="line"><a name="l00599"></a><span class="lineno"> 599</span>  <span class="keyword">const</span> std::vector<std::vector<int64> >& weights,</div><div class="line"><a name="l00600"></a><span class="lineno"> 600</span>  <span class="keyword">const</span> std::vector<int64>& capacities) <span class="keyword">override</span>;</div><div class="line"><a name="l00601"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackGenericSolver.html#aa809ec4aa24281647003e8a473784051"> 601</a></span>  <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1KnapsackGenericSolver.html#aa809ec4aa24281647003e8a473784051">GetNumberOfItems</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> state_.<a class="code" href="classoperations__research_1_1KnapsackState.html#aa819237f8d1a2dddad038ac0c8efa495">GetNumberOfItems</a>(); }</div><div class="line"><a name="l00602"></a><span class="lineno"> 602</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackGenericSolver.html#aa49dbbb2b6eae494f521992c964bad53">GetLowerAndUpperBoundWhenItem</a>(<span class="keywordtype">int</span> item_id, <span class="keywordtype">bool</span> is_item_in,</div><div class="line"><a name="l00603"></a><span class="lineno"> 603</span>  int64* lower_bound,</div><div class="line"><a name="l00604"></a><span class="lineno"> 604</span>  int64* upper_bound) <span class="keyword">override</span>;</div><div class="line"><a name="l00605"></a><span class="lineno"> 605</span> </div><div class="line"><a name="l00606"></a><span class="lineno"> 606</span>  <span class="comment">// Sets which propagator should be used to guide the search.</span></div><div class="line"><a name="l00607"></a><span class="lineno"> 607</span>  <span class="comment">// 'master_propagator_id' should be in 0..p-1 with p the number of</span></div><div class="line"><a name="l00608"></a><span class="lineno"> 608</span>  <span class="comment">// propagators.</span></div><div class="line"><a name="l00609"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackGenericSolver.html#ae320eaa08affeb2643270191b8f9700b"> 609</a></span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1KnapsackGenericSolver.html#ae320eaa08affeb2643270191b8f9700b">set_master_propagator_id</a>(<span class="keywordtype">int</span> master_propagator_id) {</div><div class="line"><a name="l00610"></a><span class="lineno"> 610</span>  master_propagator_id_ = master_propagator_id;</div><div class="line"><a name="l00611"></a><span class="lineno"> 611</span>  }</div><div class="line"><a name="l00612"></a><span class="lineno"> 612</span> </div><div class="line"><a name="l00613"></a><span class="lineno"> 613</span>  <span class="comment">// Solves the problem and returns the profit of the optimal solution.</span></div><div class="line"><a name="l00614"></a><span class="lineno"> 614</span>  int64 <a class="code" href="classoperations__research_1_1KnapsackGenericSolver.html#a8f57ec05930a3df316b5df101c814984">Solve</a>(TimeLimit* time_limit, <span class="keywordtype">bool</span>* is_solution_optimal) <span class="keyword">override</span>;</div><div class="line"><a name="l00615"></a><span class="lineno"> 615</span>  <span class="comment">// Returns true if the item 'item_id' is packed in the optimal knapsack.</span></div><div class="line"><a name="l00616"></a><span class="lineno"><a class="line" href="classoperations__research_1_1KnapsackGenericSolver.html#a3f48cb5dfceb3c4129779568d2569606"> 616</a></span>  <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1KnapsackGenericSolver.html#a3f48cb5dfceb3c4129779568d2569606">best_solution</a>(<span class="keywordtype">int</span> item_id)<span class="keyword"> const override </span>{</div><div class="line"><a name="l00617"></a><span class="lineno"> 617</span>  <span class="keywordflow">return</span> best_solution_.at(item_id);</div><div class="line"><a name="l00618"></a><span class="lineno"> 618</span>  }</div><div class="line"><a name="l00619"></a><span class="lineno"> 619</span> </div><div class="line"><a name="l00620"></a><span class="lineno"> 620</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00621"></a><span class="lineno"> 621</span>  <span class="comment">// Clears internal data structure.</span></div><div class="line"><a name="l00622"></a><span class="lineno"> 622</span>  <span class="keywordtype">void</span> Clear();</div><div class="line"><a name="l00623"></a><span class="lineno"> 623</span> </div><div class="line"><a name="l00624"></a><span class="lineno"> 624</span>  <span class="comment">// Updates all propagators reverting/applying all decision on the path.</span></div><div class="line"><a name="l00625"></a><span class="lineno"> 625</span>  <span class="comment">// Returns true if fails. Note that, even if fails, all propagators should</span></div><div class="line"><a name="l00626"></a><span class="lineno"> 626</span>  <span class="comment">// be updated to be in a stable state in order to stay incremental.</span></div><div class="line"><a name="l00627"></a><span class="lineno"> 627</span>  <span class="keywordtype">bool</span> UpdatePropagators(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchPath.html">KnapsackSearchPath</a>& path);</div><div class="line"><a name="l00628"></a><span class="lineno"> 628</span>  <span class="comment">// Updates all propagators reverting/applying one decision.</span></div><div class="line"><a name="l00629"></a><span class="lineno"> 629</span>  <span class="comment">// Return true if fails. Note that, even if fails, all propagators should</span></div><div class="line"><a name="l00630"></a><span class="lineno"> 630</span>  <span class="comment">// be updated to be in a stable state in order to stay incremental.</span></div><div class="line"><a name="l00631"></a><span class="lineno"> 631</span>  <span class="keywordtype">bool</span> IncrementalUpdate(<span class="keywordtype">bool</span> revert, <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1KnapsackAssignment.html">KnapsackAssignment</a>& assignment);</div><div class="line"><a name="l00632"></a><span class="lineno"> 632</span>  <span class="comment">// Updates the best solution if the current solution has a better profit.</span></div><div class="line"><a name="l00633"></a><span class="lineno"> 633</span>  <span class="keywordtype">void</span> UpdateBestSolution();</div><div class="line"><a name="l00634"></a><span class="lineno"> 634</span> </div><div class="line"><a name="l00635"></a><span class="lineno"> 635</span>  <span class="comment">// Returns true if new relevant search node was added to the nodes array, that</span></div><div class="line"><a name="l00636"></a><span class="lineno"> 636</span>  <span class="comment">// means this node should be added to the search queue too.</span></div><div class="line"><a name="l00637"></a><span class="lineno"> 637</span>  <span class="keywordtype">bool</span> MakeNewNode(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1KnapsackSearchNode.html">KnapsackSearchNode</a>& node, <span class="keywordtype">bool</span> is_in);</div><div class="line"><a name="l00638"></a><span class="lineno"> 638</span> </div><div class="line"><a name="l00639"></a><span class="lineno"> 639</span>  <span class="comment">// Gets the aggregated (min) profit upper bound among all propagators.</span></div><div class="line"><a name="l00640"></a><span class="lineno"> 640</span>  int64 GetAggregatedProfitUpperBound() <span class="keyword">const</span>;</div><div class="line"><a name="l00641"></a><span class="lineno"> 641</span>  <span class="keywordtype">bool</span> HasOnePropagator()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> propagators_.size() == 1; }</div><div class="line"><a name="l00642"></a><span class="lineno"> 642</span>  int64 GetCurrentProfit()<span class="keyword"> const </span>{</div><div class="line"><a name="l00643"></a><span class="lineno"> 643</span>  <span class="keywordflow">return</span> propagators_.at(master_propagator_id_)->current_profit();</div><div class="line"><a name="l00644"></a><span class="lineno"> 644</span>  }</div><div class="line"><a name="l00645"></a><span class="lineno"> 645</span>  int64 GetNextItemId()<span class="keyword"> const </span>{</div><div class="line"><a name="l00646"></a><span class="lineno"> 646</span>  <span class="keywordflow">return</span> propagators_.at(master_propagator_id_)->GetNextItemId();</div><div class="line"><a name="l00647"></a><span class="lineno"> 647</span>  }</div><div class="line"><a name="l00648"></a><span class="lineno"> 648</span> </div><div class="line"><a name="l00649"></a><span class="lineno"> 649</span>  std::vector<KnapsackPropagator*> propagators_;</div><div class="line"><a name="l00650"></a><span class="lineno"> 650</span>  <span class="keywordtype">int</span> master_propagator_id_;</div><div class="line"><a name="l00651"></a><span class="lineno"> 651</span>  std::vector<KnapsackSearchNode*> search_nodes_;</div><div class="line"><a name="l00652"></a><span class="lineno"> 652</span>  KnapsackState state_;</div><div class="line"><a name="l00653"></a><span class="lineno"> 653</span>  int64 best_solution_profit_;</div><div class="line"><a name="l00654"></a><span class="lineno"> 654</span>  std::vector<bool> best_solution_;</div><div class="line"><a name="l00655"></a><span class="lineno"> 655</span> </div><div class="line"><a name="l00656"></a><span class="lineno"> 656</span>  DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1KnapsackGenericSolver.html#ad92ca41f734bcbc35ef295f8a4bd556c">KnapsackGenericSolver</a>);</div><div class="line"><a name="l00657"></a><span class="lineno"> 657</span> };</div><div class="line"><a name="l00658"></a><span class="lineno"> 658</span> <span class="preprocessor">#endif // SWIG</span></div><div class="line"><a name="l00659"></a><span class="lineno"> 659</span> } <span class="comment">// namespace operations_research</span></div><div class="line"><a name="l00660"></a><span class="lineno"> 660</span> </div><div class="line"><a name="l00661"></a><span class="lineno"> 661</span> <span class="preprocessor">#endif // OR_TOOLS_ALGORITHMS_KNAPSACK_SOLVER_H_</span></div><div class="ttc" id="classoperations__research_1_1KnapsackSearchPath_html_a070dcd6139b7a475886f061cefb7fd78"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchPath.html#a070dcd6139b7a475886f061cefb7fd78">operations_research::KnapsackSearchPath::to</a></div><div class="ttdeci">const KnapsackSearchNode & to() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00379">knapsack_solver.h:379</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1KnapsackAssignment_html_ab4ba3de70cb7aa3ad9aaee3dd2c60b7b"><div class="ttname"><a href="structoperations__research_1_1KnapsackAssignment.html#ab4ba3de70cb7aa3ad9aaee3dd2c60b7b">operations_research::KnapsackAssignment::is_in</a></div><div class="ttdeci">bool is_in</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00278">knapsack_solver.h:278</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchPath_html_afede2909f269364002ffe722f4bed1b2"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchPath.html#afede2909f269364002ffe722f4bed1b2">operations_research::KnapsackSearchPath::via</a></div><div class="ttdeci">const KnapsackSearchNode & via() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00378">knapsack_solver.h:378</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1KnapsackItem_html_a5ae427adb88e21ec0f883b8bbcc4b1d4"><div class="ttname"><a href="structoperations__research_1_1KnapsackItem.html#a5ae427adb88e21ec0f883b8bbcc4b1d4">operations_research::KnapsackItem::KnapsackItem</a></div><div class="ttdeci">KnapsackItem(int _id, int64 _weight, int64 _profit)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00294">knapsack_solver.h:294</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackState_html_aa819237f8d1a2dddad038ac0c8efa495"><div class="ttname"><a href="classoperations__research_1_1KnapsackState.html#aa819237f8d1a2dddad038ac0c8efa495">operations_research::KnapsackState::GetNumberOfItems</a></div><div class="ttdeci">int GetNumberOfItems() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00404">knapsack_solver.h:404</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1KnapsackAssignment_html_aab038e186549b78c472c9fbe16f6f315"><div class="ttname"><a href="structoperations__research_1_1KnapsackAssignment.html#aab038e186549b78c472c9fbe16f6f315">operations_research::KnapsackAssignment::KnapsackAssignment</a></div><div class="ttdeci">KnapsackAssignment(int _item_id, bool _is_in)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00275">knapsack_solver.h:275</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_af652548ebe8eeb5b0abfb900cf7f2927"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#af652548ebe8eeb5b0abfb900cf7f2927">operations_research::KnapsackPropagator::state</a></div><div class="ttdeci">const KnapsackState & state() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00477">knapsack_solver.h:477</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_ac6a4643a2599c05708695addf803e52d"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#ac6a4643a2599c05708695addf803e52d">operations_research::KnapsackPropagator::items</a></div><div class="ttdeci">const std::vector< KnapsackItemPtr > & items() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00478">knapsack_solver.h:478</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackCapacityPropagator_html_aeea8be32ceca77b5eaf9139df5e4ea4a"><div class="ttname"><a href="classoperations__research_1_1KnapsackCapacityPropagator.html#aeea8be32ceca77b5eaf9139df5e4ea4a">operations_research::KnapsackCapacityPropagator::GetNextItemId</a></div><div class="ttdeci">int GetNextItemId() const override</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00518">knapsack_solver.h:518</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackCapacityPropagator_html_a59eff70af400b44d87d57b90047ada6e"><div class="ttname"><a href="classoperations__research_1_1KnapsackCapacityPropagator.html#a59eff70af400b44d87d57b90047ada6e">operations_research::KnapsackCapacityPropagator::InitPropagator</a></div><div class="ttdeci">void InitPropagator() override</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackState_html_a6b5c2748ef2668630c5bfdfa56093e95"><div class="ttname"><a href="classoperations__research_1_1KnapsackState.html#a6b5c2748ef2668630c5bfdfa56093e95">operations_research::KnapsackState::Init</a></div><div class="ttdeci">void Init(int number_of_items)</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_a5843f83c839a81d039724b6d49ba325a"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#a5843f83c839a81d039724b6d49ba325a">operations_research::KnapsackPropagator::Update</a></div><div class="ttdeci">bool Update(bool revert, const KnapsackAssignment &assignment)</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_aeb99e95f19c68257f0b450cfff8fc3d0"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#aeb99e95f19c68257f0b450cfff8fc3d0">operations_research::KnapsackPropagator::InitPropagator</a></div><div class="ttdeci">virtual void InitPropagator()=0</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackCapacityPropagator_html_a03745304f7f106699428e4ed6efdef9d"><div class="ttname"><a href="classoperations__research_1_1KnapsackCapacityPropagator.html#a03745304f7f106699428e4ed6efdef9d">operations_research::KnapsackCapacityPropagator::CopyCurrentStateToSolutionPropagator</a></div><div class="ttdeci">void CopyCurrentStateToSolutionPropagator(std::vector< bool > *solution) const override</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1BaseKnapsackSolver_html_a3e8f72facec15537065c1625e647d58b"><div class="ttname"><a href="classoperations__research_1_1BaseKnapsackSolver.html#a3e8f72facec15537065c1625e647d58b">operations_research::BaseKnapsackSolver::Init</a></div><div class="ttdeci">virtual void Init(const std::vector< int64 > &profits, const std::vector< std::vector< int64 > > &weights, const std::vector< int64 > &capacities)=0</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_aaa95c66b22228756739735f4574cb4a1"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#aaa95c66b22228756739735f4574cb4a1">operations_research::KnapsackPropagator::profit_upper_bound</a></div><div class="ttdeci">int64 profit_upper_bound() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00448">knapsack_solver.h:448</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a170ccb08012026c5a438fcf16feb6faa"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a170ccb08012026c5a438fcf16feb6faa">operations_research::KnapsackSolver::BestSolutionContains</a></div><div class="ttdeci">bool BestSolutionContains(int item_id) const</div><div class="ttdoc">Returns true if the item 'item_id' is packed in the optimal knapsack.</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchPath_html_abfbc25d180ab655ca72aa1dda80b5e1b"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchPath.html#abfbc25d180ab655ca72aa1dda80b5e1b">operations_research::KnapsackSearchPath::from</a></div><div class="ttdeci">const KnapsackSearchNode & from() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00377">knapsack_solver.h:377</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchNode_html_aa09bf719c32bf8f662d3c609f3e72f19"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchNode.html#aa09bf719c32bf8f662d3c609f3e72f19">operations_research::KnapsackSearchNode::set_next_item_id</a></div><div class="ttdeci">void set_next_item_id(int id)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00333">knapsack_solver.h:333</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1KnapsackItem_html_a99b55b42e78cab5b85c8f411d13f32e9"><div class="ttname"><a href="structoperations__research_1_1KnapsackItem.html#a99b55b42e78cab5b85c8f411d13f32e9">operations_research::KnapsackItem::GetEfficiency</a></div><div class="ttdeci">double GetEfficiency(int64 profit_max) const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00296">knapsack_solver.h:296</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchNode_html"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchNode.html">operations_research::KnapsackSearchNode</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00318">knapsack_solver.h:318</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackGenericSolver_html_aa809ec4aa24281647003e8a473784051"><div class="ttname"><a href="classoperations__research_1_1KnapsackGenericSolver.html#aa809ec4aa24281647003e8a473784051">operations_research::KnapsackGenericSolver::GetNumberOfItems</a></div><div class="ttdeci">int GetNumberOfItems() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00601">knapsack_solver.h:601</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a96f960b29496f637af7a3eeb10e606ab"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a96f960b29496f637af7a3eeb10e606ab">operations_research::KnapsackSolver::IsSolutionOptimal</a></div><div class="ttdeci">bool IsSolutionOptimal() const</div><div class="ttdoc">Returns true if the solution was proven optimal.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00201">knapsack_solver.h:201</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1BaseKnapsackSolver_html_a5f685ec61d9de86d57bdc53124c08b12"><div class="ttname"><a href="classoperations__research_1_1BaseKnapsackSolver.html#a5f685ec61d9de86d57bdc53124c08b12">operations_research::BaseKnapsackSolver::~BaseKnapsackSolver</a></div><div class="ttdeci">virtual ~BaseKnapsackSolver()</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00557">knapsack_solver.h:557</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchNode_html_a2be03bd371b69f335778de84dc7ae5a8"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchNode.html#a2be03bd371b69f335778de84dc7ae5a8">operations_research::KnapsackSearchNode::set_current_profit</a></div><div class="ttdeci">void set_current_profit(int64 profit)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00327">knapsack_solver.h:327</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackGenericSolver_html_a3f48cb5dfceb3c4129779568d2569606"><div class="ttname"><a href="classoperations__research_1_1KnapsackGenericSolver.html#a3f48cb5dfceb3c4129779568d2569606">operations_research::KnapsackGenericSolver::best_solution</a></div><div class="ttdeci">bool best_solution(int item_id) const override</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00616">knapsack_solver.h:616</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackGenericSolver_html_a7635ee76659f4e0117709aab3809460b"><div class="ttname"><a href="classoperations__research_1_1KnapsackGenericSolver.html#a7635ee76659f4e0117709aab3809460b">operations_research::KnapsackGenericSolver::~KnapsackGenericSolver</a></div><div class="ttdeci">~KnapsackGenericSolver() override</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackGenericSolver_html_ae320eaa08affeb2643270191b8f9700b"><div class="ttname"><a href="classoperations__research_1_1KnapsackGenericSolver.html#ae320eaa08affeb2643270191b8f9700b">operations_research::KnapsackGenericSolver::set_master_propagator_id</a></div><div class="ttdeci">void set_master_propagator_id(int master_propagator_id)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00609">knapsack_solver.h:609</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_ad2950d2690930dd8562b40d29bb7002e"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#ad2950d2690930dd8562b40d29bb7002e">operations_research::KnapsackSolver::GetName</a></div><div class="ttdeci">std::string GetName() const</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchPath_html"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchPath.html">operations_research::KnapsackSearchPath</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00372">knapsack_solver.h:372</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackGenericSolver_html"><div class="ttname"><a href="classoperations__research_1_1KnapsackGenericSolver.html">operations_research::KnapsackGenericSolver</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00592">knapsack_solver.h:592</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1KnapsackItem_html_a69aae0cb6039a8a356744648c8dfb9c1"><div class="ttname"><a href="structoperations__research_1_1KnapsackItem.html#a69aae0cb6039a8a356744648c8dfb9c1">operations_research::KnapsackItem::id</a></div><div class="ttdeci">const int id</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00304">knapsack_solver.h:304</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchPath_html_a459653bd55ab09a55714f660419367b1"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchPath.html#a459653bd55ab09a55714f660419367b1">operations_research::KnapsackSearchPath::KnapsackSearchPath</a></div><div class="ttdeci">KnapsackSearchPath(const KnapsackSearchNode &from, const KnapsackSearchNode &to)</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_abaf6d9225cde1b0d83d1a54299705ccb"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#abaf6d9225cde1b0d83d1a54299705ccb">operations_research::KnapsackPropagator::UpdatePropagator</a></div><div class="ttdeci">virtual bool UpdatePropagator(bool revert, const KnapsackAssignment &assignment)=0</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchNode_html_ae4b93f14ee40150e79e0551006a93705"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchNode.html#ae4b93f14ee40150e79e0551006a93705">operations_research::KnapsackSearchNode::KnapsackSearchNode</a></div><div class="ttdeci">KnapsackSearchNode(const KnapsackSearchNode *const parent, const KnapsackAssignment &assignment)</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1BaseKnapsackSolver_html_a08bf62b91f6cf3fca10a504f7dd278a6"><div class="ttname"><a href="classoperations__research_1_1BaseKnapsackSolver.html#a08bf62b91f6cf3fca10a504f7dd278a6">operations_research::BaseKnapsackSolver::best_solution</a></div><div class="ttdeci">virtual bool best_solution(int item_id) const =0</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html">operations_research::KnapsackSolver</a></div><div class="ttdoc">This library solves knapsack problems.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00120">knapsack_solver.h:120</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchNode_html_a3691617cae29584af4d54edf27b1f045"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchNode.html#a3691617cae29584af4d54edf27b1f045">operations_research::KnapsackSearchNode::profit_upper_bound</a></div><div class="ttdeci">int64 profit_upper_bound() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00329">knapsack_solver.h:329</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_a7bbc1ccc57318641a01cd253299f5861"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#a7bbc1ccc57318641a01cd253299f5861">operations_research::KnapsackPropagator::set_profit_upper_bound</a></div><div class="ttdeci">void set_profit_upper_bound(int64 profit)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00481">knapsack_solver.h:481</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_a697a86fbe4ab12732c8e6972ebdd5947"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#a697a86fbe4ab12732c8e6972ebdd5947">operations_research::KnapsackPropagator::set_profit_lower_bound</a></div><div class="ttdeci">void set_profit_lower_bound(int64 profit)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00480">knapsack_solver.h:480</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchNode_html_ac7cf8a7ec95046908db026fc079d3a88"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchNode.html#ac7cf8a7ec95046908db026fc079d3a88">operations_research::KnapsackSearchNode::current_profit</a></div><div class="ttdeci">int64 current_profit() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00326">knapsack_solver.h:326</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackGenericSolver_html_af9635774fd7761f62ee92e64205034b3"><div class="ttname"><a href="classoperations__research_1_1KnapsackGenericSolver.html#af9635774fd7761f62ee92e64205034b3">operations_research::KnapsackGenericSolver::Init</a></div><div class="ttdeci">void Init(const std::vector< int64 > &profits, const std::vector< std::vector< int64 > > &weights, const std::vector< int64 > &capacities) override</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893a4d72c45990d1a81e3f5bcdaf6de72096"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893a4d72c45990d1a81e3f5bcdaf6de72096">operations_research::KnapsackSolver::KNAPSACK_BRUTE_FORCE_SOLVER</a></div><div class="ttdoc">Brute force method.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00134">knapsack_solver.h:134</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchNode_html_a4a1f5f83b8b2ec165e4e6b8cd35dd60d"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchNode.html#a4a1f5f83b8b2ec165e4e6b8cd35dd60d">operations_research::KnapsackSearchNode::assignment</a></div><div class="ttdeci">const KnapsackAssignment & assignment() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00324">knapsack_solver.h:324</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893">operations_research::KnapsackSolver::SolverType</a></div><div class="ttdeci">SolverType</div><div class="ttdoc">Enum controlling which underlying algorithm is used.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00127">knapsack_solver.h:127</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackState_html_adb083eb4c9bb7413cff7262e58c5abe0"><div class="ttname"><a href="classoperations__research_1_1KnapsackState.html#adb083eb4c9bb7413cff7262e58c5abe0">operations_research::KnapsackState::KnapsackState</a></div><div class="ttdeci">KnapsackState()</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_abb429376ba12d5541f22a905a728b0e1"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#abb429376ba12d5541f22a905a728b0e1">operations_research::KnapsackSolver::set_use_reduction</a></div><div class="ttdeci">void set_use_reduction(bool use_reduction)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00205">knapsack_solver.h:205</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_a49bb0497f50479663fc4b37bb4a08268"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#a49bb0497f50479663fc4b37bb4a08268">operations_research::KnapsackPropagator::current_profit</a></div><div class="ttdeci">int64 current_profit() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00446">knapsack_solver.h:446</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1BaseKnapsackSolver_html_a381cc9d7b544a8ec4727f9618f0b4f8f"><div class="ttname"><a href="classoperations__research_1_1BaseKnapsackSolver.html#a381cc9d7b544a8ec4727f9618f0b4f8f">operations_research::BaseKnapsackSolver::GetLowerAndUpperBoundWhenItem</a></div><div class="ttdeci">virtual void GetLowerAndUpperBoundWhenItem(int item_id, bool is_item_in, int64 *lower_bound, int64 *upper_bound)</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackState_html_ad5b6fe4a0bbfa609c73c8802379d50e5"><div class="ttname"><a href="classoperations__research_1_1KnapsackState.html#ad5b6fe4a0bbfa609c73c8802379d50e5">operations_research::KnapsackState::is_bound</a></div><div class="ttdeci">bool is_bound(int id) const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00405">knapsack_solver.h:405</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_aeb74436e19f4e74afdeb17f623bb0335"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#aeb74436e19f4e74afdeb17f623bb0335">operations_research::KnapsackPropagator::Init</a></div><div class="ttdeci">void Init(const std::vector< int64 > &profits, const std::vector< int64 > &weights)</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchNode_html_a5af222fdaf626cb0e33d2191d90b806c"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchNode.html#a5af222fdaf626cb0e33d2191d90b806c">operations_research::KnapsackSearchNode::set_profit_upper_bound</a></div><div class="ttdeci">void set_profit_upper_bound(int64 profit)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00330">knapsack_solver.h:330</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchNode_html_aefa89c44b243d58591f919ec6e455989"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchNode.html#aefa89c44b243d58591f919ec6e455989">operations_research::KnapsackSearchNode::parent</a></div><div class="ttdeci">const KnapsackSearchNode *const parent() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00323">knapsack_solver.h:323</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a7638cb76df7cb79d956dda62d179a554"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a7638cb76df7cb79d956dda62d179a554">operations_research::KnapsackSolver::KnapsackSolver</a></div><div class="ttdeci">KnapsackSolver(const std::string &solver_name)</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893ae1b7e0ea856a376a9c04130e0abdf812"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893ae1b7e0ea856a376a9c04130e0abdf812">operations_research::KnapsackSolver::KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER</a></div><div class="ttdoc">CBC Based Solver.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00158">knapsack_solver.h:158</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1BaseKnapsackSolver_html_a507afd9932799f0be34f34605cd5ffee"><div class="ttname"><a href="classoperations__research_1_1BaseKnapsackSolver.html#a507afd9932799f0be34f34605cd5ffee">operations_research::BaseKnapsackSolver::BaseKnapsackSolver</a></div><div class="ttdeci">BaseKnapsackSolver(const std::string &solver_name)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00555">knapsack_solver.h:555</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackCapacityPropagator_html_a9dd517fbac9988f24173eaf86238976e"><div class="ttname"><a href="classoperations__research_1_1KnapsackCapacityPropagator.html#a9dd517fbac9988f24173eaf86238976e">operations_research::KnapsackCapacityPropagator::KnapsackCapacityPropagator</a></div><div class="ttdeci">KnapsackCapacityPropagator(const KnapsackState &state, int64 capacity)</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackGenericSolver_html_a8f57ec05930a3df316b5df101c814984"><div class="ttname"><a href="classoperations__research_1_1KnapsackGenericSolver.html#a8f57ec05930a3df316b5df101c814984">operations_research::KnapsackGenericSolver::Solve</a></div><div class="ttdeci">int64 Solve(TimeLimit *time_limit, bool *is_solution_optimal) override</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackCapacityPropagator_html_a33d39340cd8d61263b20361c8b774832"><div class="ttname"><a href="classoperations__research_1_1KnapsackCapacityPropagator.html#a33d39340cd8d61263b20361c8b774832">operations_research::KnapsackCapacityPropagator::~KnapsackCapacityPropagator</a></div><div class="ttdeci">~KnapsackCapacityPropagator() override</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackCapacityPropagator_html_a944c99875dbcc49d557c129f4077799b"><div class="ttname"><a href="classoperations__research_1_1KnapsackCapacityPropagator.html#a944c99875dbcc49d557c129f4077799b">operations_research::KnapsackCapacityPropagator::UpdatePropagator</a></div><div class="ttdeci">bool UpdatePropagator(bool revert, const KnapsackAssignment &assignment) override</div></div>
|
|
<div class="ttc" id="structoperations__research_1_1KnapsackItem_html_ab974e9e70c585c50c96851ecb454d882"><div class="ttname"><a href="structoperations__research_1_1KnapsackItem.html#ab974e9e70c585c50c96851ecb454d882">operations_research::KnapsackItem::weight</a></div><div class="ttdeci">const int64 weight</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00305">knapsack_solver.h:305</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_a510e0ee59d597e16200ee04ab2e417ac"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#a510e0ee59d597e16200ee04ab2e417ac">operations_research::KnapsackPropagator::~KnapsackPropagator</a></div><div class="ttdeci">virtual ~KnapsackPropagator()</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackCapacityPropagator_html"><div class="ttname"><a href="classoperations__research_1_1KnapsackCapacityPropagator.html">operations_research::KnapsackCapacityPropagator</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00513">knapsack_solver.h:513</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html">operations_research::KnapsackPropagator</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00427">knapsack_solver.h:427</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893a9c02fa29c925bc1d37cba92490998132"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893a9c02fa29c925bc1d37cba92490998132">operations_research::KnapsackSolver::KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER</a></div><div class="ttdoc">Dynamic Programming approach for single dimension problems.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00150">knapsack_solver.h:150</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893aa6d83fc5b8d17db1f82c1b414a4e8b20"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893aa6d83fc5b8d17db1f82c1b414a4e8b20">operations_research::KnapsackSolver::KNAPSACK_MULTIDIMENSION_SCIP_MIP_SOLVER</a></div><div class="ttdoc">SCIP based solver.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00174">knapsack_solver.h:174</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1BaseKnapsackSolver_html_a952deb24e032890d2781e52fedb70efa"><div class="ttname"><a href="classoperations__research_1_1BaseKnapsackSolver.html#a952deb24e032890d2781e52fedb70efa">operations_research::BaseKnapsackSolver::Solve</a></div><div class="ttdeci">virtual int64 Solve(TimeLimit *time_limit, bool *is_solution_optimal)=0</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchNode_html_a28a03df4a481f501c503fc9500eb8f47"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchNode.html#a28a03df4a481f501c503fc9500eb8f47">operations_research::KnapsackSearchNode::next_item_id</a></div><div class="ttdeci">int next_item_id() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00332">knapsack_solver.h:332</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_aca019151f60942f2e7245874bb89cd62"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#aca019151f60942f2e7245874bb89cd62">operations_research::KnapsackSolver::Init</a></div><div class="ttdeci">void Init(const std::vector< int64 > &profits, const std::vector< std::vector< int64 >> &weights, const std::vector< int64 > &capacities)</div><div class="ttdoc">Initializes the solver and enters the problem to be solved.</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_a95551ecb408465b2fcf57aaaac393336"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#a95551ecb408465b2fcf57aaaac393336">operations_research::KnapsackPropagator::CopyCurrentStateToSolutionPropagator</a></div><div class="ttdeci">virtual void CopyCurrentStateToSolutionPropagator(std::vector< bool > *solution) const =0</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchPath_html_a91d3f4f27442d3ee1f748811d5d0d964"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchPath.html#a91d3f4f27442d3ee1f748811d5d0d964">operations_research::KnapsackSearchPath::Init</a></div><div class="ttdeci">void Init()</div></div>
|
|
<div class="ttc" id="structoperations__research_1_1KnapsackItem_html_a057015810b94bfb1b5efac74e9d8d487"><div class="ttname"><a href="structoperations__research_1_1KnapsackItem.html#a057015810b94bfb1b5efac74e9d8d487">operations_research::KnapsackItem::profit</a></div><div class="ttdeci">const int64 profit</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00306">knapsack_solver.h:306</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchNode_html_a16d77e11bc5eac6ddd95e129a8904753"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchNode.html#a16d77e11bc5eac6ddd95e129a8904753">operations_research::KnapsackSearchNode::depth</a></div><div class="ttdeci">int depth() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00322">knapsack_solver.h:322</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSearchPath_html_a3c129707bd16aea17d0eb3ad6c4e10e5"><div class="ttname"><a href="classoperations__research_1_1KnapsackSearchPath.html#a3c129707bd16aea17d0eb3ad6c4e10e5">operations_research::KnapsackSearchPath::MoveUpToDepth</a></div><div class="ttdeci">const KnapsackSearchNode * MoveUpToDepth(const KnapsackSearchNode &node, int depth) const</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a0408f46c96d0dbf4eb463fa385778593"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a0408f46c96d0dbf4eb463fa385778593">operations_research::KnapsackSolver::use_reduction</a></div><div class="ttdeci">bool use_reduction() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00204">knapsack_solver.h:204</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a0f6ca3ef8483871052325ea2d04ca72d"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a0f6ca3ef8483871052325ea2d04ca72d">operations_research::KnapsackSolver::set_time_limit</a></div><div class="ttdeci">void set_time_limit(double time_limit_seconds)</div><div class="ttdoc">Time limit in seconds.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00214">knapsack_solver.h:214</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1KnapsackAssignment_html_a91340b6da590fae44e79199666ccf468"><div class="ttname"><a href="structoperations__research_1_1KnapsackAssignment.html#a91340b6da590fae44e79199666ccf468">operations_research::KnapsackAssignment::item_id</a></div><div class="ttdeci">int item_id</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00277">knapsack_solver.h:277</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackGenericSolver_html_ad92ca41f734bcbc35ef295f8a4bd556c"><div class="ttname"><a href="classoperations__research_1_1KnapsackGenericSolver.html#ad92ca41f734bcbc35ef295f8a4bd556c">operations_research::KnapsackGenericSolver::KnapsackGenericSolver</a></div><div class="ttdeci">KnapsackGenericSolver(const std::string &solver_name)</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893ae8c15c25eaf606f5f853821aaabba164"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893ae8c15c25eaf606f5f853821aaabba164">operations_research::KnapsackSolver::KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER</a></div><div class="ttdoc">Generic Solver.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00166">knapsack_solver.h:166</a></div></div>
|
|
<div class="ttc" id="namespaceoperations__research_html"><div class="ttname"><a href="namespaceoperations__research.html">operations_research</a></div><div class="ttdef"><b>Definition:</b> <a href="dense__doubly__linked__list_8h_source.html#l00021">dense_doubly_linked_list.h:21</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1KnapsackAssignment_html"><div class="ttname"><a href="structoperations__research_1_1KnapsackAssignment.html">operations_research::KnapsackAssignment</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00274">knapsack_solver.h:274</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackState_html_a3fa5da9a819f219f4c51e410fe12c1a3"><div class="ttname"><a href="classoperations__research_1_1KnapsackState.html#a3fa5da9a819f219f4c51e410fe12c1a3">operations_research::KnapsackState::UpdateState</a></div><div class="ttdeci">bool UpdateState(bool revert, const KnapsackAssignment &assignment)</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_a4a8ef9517e0c8bf1eb1e450b72aa4e05"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#a4a8ef9517e0c8bf1eb1e450b72aa4e05">operations_research::KnapsackPropagator::CopyCurrentStateToSolution</a></div><div class="ttdeci">void CopyCurrentStateToSolution(bool has_one_propagator, std::vector< bool > *solution) const</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_a8133fbb05961e760ed907e1f599966d8"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#a8133fbb05961e760ed907e1f599966d8">operations_research::KnapsackPropagator::ComputeProfitBounds</a></div><div class="ttdeci">virtual void ComputeProfitBounds()=0</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackCapacityPropagator_html_af1d7d1e175e652c64962af490ab42247"><div class="ttname"><a href="classoperations__research_1_1KnapsackCapacityPropagator.html#af1d7d1e175e652c64962af490ab42247">operations_research::KnapsackCapacityPropagator::ComputeProfitBounds</a></div><div class="ttdeci">void ComputeProfitBounds() override</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_a44b8bedd2218a210512ab3f8f3172312"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#a44b8bedd2218a210512ab3f8f3172312">operations_research::KnapsackPropagator::GetNextItemId</a></div><div class="ttdeci">virtual int GetNextItemId() const =0</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackGenericSolver_html_aa49dbbb2b6eae494f521992c964bad53"><div class="ttname"><a href="classoperations__research_1_1KnapsackGenericSolver.html#aa49dbbb2b6eae494f521992c964bad53">operations_research::KnapsackGenericSolver::GetLowerAndUpperBoundWhenItem</a></div><div class="ttdeci">void GetLowerAndUpperBoundWhenItem(int item_id, bool is_item_in, int64 *lower_bound, int64 *upper_bound) override</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1BaseKnapsackSolver_html"><div class="ttname"><a href="classoperations__research_1_1BaseKnapsackSolver.html">operations_research::BaseKnapsackSolver</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00553">knapsack_solver.h:553</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_ac6d1a38c9a1c607e80d05720372ace4d"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#ac6d1a38c9a1c607e80d05720372ace4d">operations_research::KnapsackSolver::~KnapsackSolver</a></div><div class="ttdeci">virtual ~KnapsackSolver()</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_a8d55d0c6ac3f05b72100f1635cfd2250"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#a8d55d0c6ac3f05b72100f1635cfd2250">operations_research::KnapsackPropagator::KnapsackPropagator</a></div><div class="ttdeci">KnapsackPropagator(const KnapsackState &state)</div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackPropagator_html_a11ea8cfd2264c8f033d59e2848f9a871"><div class="ttname"><a href="classoperations__research_1_1KnapsackPropagator.html#a11ea8cfd2264c8f033d59e2848f9a871">operations_research::KnapsackPropagator::profit_lower_bound</a></div><div class="ttdeci">int64 profit_lower_bound() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00447">knapsack_solver.h:447</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893aa6c3b9157b2506f5a53b0c73165c8f9b"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893aa6c3b9157b2506f5a53b0c73165c8f9b">operations_research::KnapsackSolver::KNAPSACK_64ITEMS_SOLVER</a></div><div class="ttdoc">Optimized method for single dimension small problems.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00142">knapsack_solver.h:142</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1KnapsackItem_html"><div class="ttname"><a href="structoperations__research_1_1KnapsackItem.html">operations_research::KnapsackItem</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00293">knapsack_solver.h:293</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackSolver_html_a7c3b5825c8effd86de03a610d1a38ed7"><div class="ttname"><a href="classoperations__research_1_1KnapsackSolver.html#a7c3b5825c8effd86de03a610d1a38ed7">operations_research::KnapsackSolver::Solve</a></div><div class="ttdeci">int64 Solve()</div><div class="ttdoc">Solves the problem and returns the profit of the optimal solution.</div></div>
|
|
<div class="ttc" id="namespaceoperations__research_html_ab6f3adbb119982fdfb9a85d87310f255"><div class="ttname"><a href="namespaceoperations__research.html#ab6f3adbb119982fdfb9a85d87310f255">operations_research::KnapsackItemPtr</a></div><div class="ttdeci">KnapsackItem * KnapsackItemPtr</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00308">knapsack_solver.h:308</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1BaseKnapsackSolver_html_ae19aff92b4b38e712ead1cfcafd81f03"><div class="ttname"><a href="classoperations__research_1_1BaseKnapsackSolver.html#ae19aff92b4b38e712ead1cfcafd81f03">operations_research::BaseKnapsackSolver::GetName</a></div><div class="ttdeci">virtual std::string GetName() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00577">knapsack_solver.h:577</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackState_html"><div class="ttname"><a href="classoperations__research_1_1KnapsackState.html">operations_research::KnapsackState</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00393">knapsack_solver.h:393</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1KnapsackState_html_a9365eaaee4e8e05325f0f12a50a94297"><div class="ttname"><a href="classoperations__research_1_1KnapsackState.html#a9365eaaee4e8e05325f0f12a50a94297">operations_research::KnapsackState::is_in</a></div><div class="ttdeci">bool is_in(int id) const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00406">knapsack_solver.h:406</a></div></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
</div>
|
|
<div id="footer-container">
|
|
<div id="footer">
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|