Files
ortools-clone/docs/cpp/knapsack__solver_8h_source.html
Laurent Perron a2ad6677e1 regenerate doc
2022-01-16 18:02:36 +01:00

220 lines
157 KiB
HTML

<!-- HTML header for doxygen 1.8.18-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>OR-Tools: knapsack_solver.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="styleSheet.tmp.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="orLogo.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">OR-Tools
&#160;<span id="projectnumber">9.2</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></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&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('knapsack__solver_8h_source.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<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>&#160;<span class="comment">// Copyright 2010-2021 Google LLC</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<span class="comment">// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<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>&#160;<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>&#160;<span class="comment">//</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;<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>&#160;<span class="comment">//</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<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>&#160;<span class="comment">// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<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>&#160;<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>&#160;<span class="comment">// limitations under the License.</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;</div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="preprocessor">#ifndef OR_TOOLS_ALGORITHMS_KNAPSACK_SOLVER_H_</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="preprocessor">#define OR_TOOLS_ALGORITHMS_KNAPSACK_SOLVER_H_</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;</div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="preprocessor">#include &lt;math.h&gt;</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;</div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="preprocessor">#include &lt;memory&gt;</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160;</div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;<span class="preprocessor">#include &quot;absl/memory/memory.h&quot;</span></div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="basictypes_8h.html">ortools/base/basictypes.h</a>&quot;</span></div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="integral__types_8h.html">ortools/base/integral_types.h</a>&quot;</span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="base_2logging_8h.html">ortools/base/logging.h</a>&quot;</span></div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="macros_8h.html">ortools/base/macros.h</a>&quot;</span></div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="time__limit_8h.html">ortools/util/time_limit.h</a>&quot;</span></div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160;</div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160;<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>&#160;</div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160;<span class="keyword">class </span>BaseKnapsackSolver;</div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160;</div><div class="line"><a name="l00117"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html"> 117</a></span>&#160;<span class="keyword">class </span><a class="code" href="classoperations__research_1_1_knapsack_solver.html">KnapsackSolver</a> {</div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00124"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ec"> 124</a></span>&#160; <span class="keyword">enum</span> <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ec">SolverType</a> {</div><div class="line"><a name="l00131"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ecac43056d6d2f96cee37fcb8a752b0ff45"> 131</a></span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ecac43056d6d2f96cee37fcb8a752b0ff45">KNAPSACK_BRUTE_FORCE_SOLVER</a> = 0,</div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>&#160;</div><div class="line"><a name="l00139"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ecaa020f211a1ff184e712aa4f372d6ea34"> 139</a></span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ecaa020f211a1ff184e712aa4f372d6ea34">KNAPSACK_64ITEMS_SOLVER</a> = 1,</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160;</div><div class="line"><a name="l00147"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306eca793d998526508cfcc2bfc89fe25b3edd"> 147</a></span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306eca793d998526508cfcc2bfc89fe25b3edd">KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER</a> = 2,</div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160;</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>&#160;<span class="preprocessor">#if defined(USE_CBC)</span></div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span>&#160;</div><div class="line"><a name="l00155"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ecae2ce6e36a247621de398e875d5feb575"> 155</a></span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ecae2ce6e36a247621de398e875d5feb575">KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER</a> = 3,</div><div class="line"><a name="l00156"></a><span class="lineno"> 156</span>&#160;<span class="preprocessor">#endif // USE_CBC</span></div><div class="line"><a name="l00157"></a><span class="lineno"> 157</span>&#160;</div><div class="line"><a name="l00163"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306eca2a4e77eec4f386d17001e7285e812a0b"> 163</a></span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306eca2a4e77eec4f386d17001e7285e812a0b">KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER</a> = 5,</div><div class="line"><a name="l00164"></a><span class="lineno"> 164</span>&#160;</div><div class="line"><a name="l00165"></a><span class="lineno"> 165</span>&#160;<span class="preprocessor">#if defined(USE_SCIP)</span></div><div class="line"><a name="l00166"></a><span class="lineno"> 166</span>&#160;</div><div class="line"><a name="l00171"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306eca1f4e1e2f80ab9c7d4fc1b14d9f5da959"> 171</a></span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306eca1f4e1e2f80ab9c7d4fc1b14d9f5da959">KNAPSACK_MULTIDIMENSION_SCIP_MIP_SOLVER</a> = 6,</div><div class="line"><a name="l00172"></a><span class="lineno"> 172</span>&#160;<span class="preprocessor">#endif // USE_SCIP</span></div><div class="line"><a name="l00173"></a><span class="lineno"> 173</span>&#160;</div><div class="line"><a name="l00174"></a><span class="lineno"> 174</span>&#160;<span class="preprocessor">#if defined(USE_XPRESS)</span></div><div class="line"><a name="l00175"></a><span class="lineno"> 175</span>&#160;</div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span>&#160; KNAPSACK_MULTIDIMENSION_XPRESS_MIP_SOLVER = 7,</div><div class="line"><a name="l00181"></a><span class="lineno"> 181</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00182"></a><span class="lineno"> 182</span>&#160;</div><div class="line"><a name="l00183"></a><span class="lineno"> 183</span>&#160;<span class="preprocessor">#if defined(USE_CPLEX)</span></div><div class="line"><a name="l00184"></a><span class="lineno"> 184</span>&#160;</div><div class="line"><a name="l00189"></a><span class="lineno"> 189</span>&#160; KNAPSACK_MULTIDIMENSION_CPLEX_MIP_SOLVER = 8,</div><div class="line"><a name="l00190"></a><span class="lineno"> 190</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00191"></a><span class="lineno"> 191</span>&#160;</div><div class="line"><a name="l00198"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306eca9d4c4118c9e4dc258e5052c0a457098d"> 198</a></span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306eca9d4c4118c9e4dc258e5052c0a457098d">KNAPSACK_DIVIDE_AND_CONQUER_SOLVER</a> = 9,</div><div class="line"><a name="l00199"></a><span class="lineno"> 199</span>&#160; };</div><div class="line"><a name="l00200"></a><span class="lineno"> 200</span>&#160;</div><div class="line"><a name="l00201"></a><span class="lineno"> 201</span>&#160; <span class="keyword">explicit</span> <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a6b46c35c8977efde66ae7ad97423bdf2">KnapsackSolver</a>(<span class="keyword">const</span> std::string&amp; solver_name);</div><div class="line"><a name="l00202"></a><span class="lineno"> 202</span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a6b46c35c8977efde66ae7ad97423bdf2">KnapsackSolver</a>(<a class="code" href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ec">SolverType</a> solver_type, <span class="keyword">const</span> std::string&amp; solver_name);</div><div class="line"><a name="l00203"></a><span class="lineno"> 203</span>&#160; <span class="keyword">virtual</span> <a class="code" href="classoperations__research_1_1_knapsack_solver.html#abb19dddb08cf912baec8995cfd2f1f42">~KnapsackSolver</a>();</div><div class="line"><a name="l00204"></a><span class="lineno"> 204</span>&#160;</div><div class="line"><a name="l00208"></a><span class="lineno"> 208</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_solver.html#ae5982edf1a2974495d20201775a765e2">Init</a>(<span class="keyword">const</span> std::vector&lt;int64_t&gt;&amp; profits,</div><div class="line"><a name="l00209"></a><span class="lineno"> 209</span>&#160; <span class="keyword">const</span> std::vector&lt;std::vector&lt;int64_t&gt; &gt;&amp; weights,</div><div class="line"><a name="l00210"></a><span class="lineno"> 210</span>&#160; <span class="keyword">const</span> std::vector&lt;int64_t&gt;&amp; capacities);</div><div class="line"><a name="l00211"></a><span class="lineno"> 211</span>&#160;</div><div class="line"><a name="l00215"></a><span class="lineno"> 215</span>&#160; int64_t <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a7f5467b49f2cba3d8804e44ed76e12a2">Solve</a>();</div><div class="line"><a name="l00216"></a><span class="lineno"> 216</span>&#160;</div><div class="line"><a name="l00220"></a><span class="lineno"> 220</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a57d88f584d14b161580550918c8fbf3b">BestSolutionContains</a>(<span class="keywordtype">int</span> item_id) <span class="keyword">const</span>;</div><div class="line"><a name="l00224"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html#a9647a5f765048e8662e5efa54c7d8687"> 224</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a9647a5f765048e8662e5efa54c7d8687">IsSolutionOptimal</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> is_solution_optimal_; }</div><div class="line"><a name="l00225"></a><span class="lineno"> 225</span>&#160; std::string <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a9a98946a64f3893b085f650932c9dfee">GetName</a>() <span class="keyword">const</span>;</div><div class="line"><a name="l00226"></a><span class="lineno"> 226</span>&#160;</div><div class="line"><a name="l00227"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html#ac7d0a3efa2aabe6a3e667b0724f63688"> 227</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_knapsack_solver.html#ac7d0a3efa2aabe6a3e667b0724f63688">use_reduction</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> use_reduction_; }</div><div class="line"><a name="l00228"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html#aa5b8e0a03c593bfc3cef0ba8d178844f"> 228</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_solver.html#aa5b8e0a03c593bfc3cef0ba8d178844f">set_use_reduction</a>(<span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_knapsack_solver.html#ac7d0a3efa2aabe6a3e667b0724f63688">use_reduction</a>) { use_reduction_ = <a class="code" href="classoperations__research_1_1_knapsack_solver.html#ac7d0a3efa2aabe6a3e667b0724f63688">use_reduction</a>; }</div><div class="line"><a name="l00229"></a><span class="lineno"> 229</span>&#160;</div><div class="line"><a name="l00235"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_solver.html#a6b4f6cbb00a64b0e9745938f9b99d0c8"> 235</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_solver.html#a6b4f6cbb00a64b0e9745938f9b99d0c8">set_time_limit</a>(<span class="keywordtype">double</span> time_limit_seconds) {</div><div class="line"><a name="l00236"></a><span class="lineno"> 236</span>&#160; time_limit_seconds_ = time_limit_seconds;</div><div class="line"><a name="l00237"></a><span class="lineno"> 237</span>&#160; time_limit_ = absl::make_unique&lt;TimeLimit&gt;(time_limit_seconds_);</div><div class="line"><a name="l00238"></a><span class="lineno"> 238</span>&#160; }</div><div class="line"><a name="l00239"></a><span class="lineno"> 239</span>&#160;</div><div class="line"><a name="l00240"></a><span class="lineno"> 240</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00241"></a><span class="lineno"> 241</span>&#160; <span class="comment">// Trivial reduction of capacity constraints when the capacity is higher than</span></div><div class="line"><a name="l00242"></a><span class="lineno"> 242</span>&#160; <span class="comment">// the sum of the weights of the items. Returns the number of reduced items.</span></div><div class="line"><a name="l00243"></a><span class="lineno"> 243</span>&#160; <span class="keywordtype">int</span> ReduceCapacities(<span class="keywordtype">int</span> num_items,</div><div class="line"><a name="l00244"></a><span class="lineno"> 244</span>&#160; <span class="keyword">const</span> std::vector&lt;std::vector&lt;int64_t&gt; &gt;&amp; weights,</div><div class="line"><a name="l00245"></a><span class="lineno"> 245</span>&#160; <span class="keyword">const</span> std::vector&lt;int64_t&gt;&amp; capacities,</div><div class="line"><a name="l00246"></a><span class="lineno"> 246</span>&#160; std::vector&lt;std::vector&lt;int64_t&gt; &gt;* reduced_weights,</div><div class="line"><a name="l00247"></a><span class="lineno"> 247</span>&#160; std::vector&lt;int64_t&gt;* reduced_capacities);</div><div class="line"><a name="l00248"></a><span class="lineno"> 248</span>&#160; <span class="keywordtype">int</span> ReduceProblem(<span class="keywordtype">int</span> num_items);</div><div class="line"><a name="l00249"></a><span class="lineno"> 249</span>&#160; <span class="keywordtype">void</span> ComputeAdditionalProfit(<span class="keyword">const</span> std::vector&lt;int64_t&gt;&amp; profits);</div><div class="line"><a name="l00250"></a><span class="lineno"> 250</span>&#160; <span class="keywordtype">void</span> InitReducedProblem(<span class="keyword">const</span> std::vector&lt;int64_t&gt;&amp; profits,</div><div class="line"><a name="l00251"></a><span class="lineno"> 251</span>&#160; <span class="keyword">const</span> std::vector&lt;std::vector&lt;int64_t&gt; &gt;&amp; weights,</div><div class="line"><a name="l00252"></a><span class="lineno"> 252</span>&#160; <span class="keyword">const</span> std::vector&lt;int64_t&gt;&amp; capacities);</div><div class="line"><a name="l00253"></a><span class="lineno"> 253</span>&#160;</div><div class="line"><a name="l00254"></a><span class="lineno"> 254</span>&#160; std::unique_ptr&lt;BaseKnapsackSolver&gt; solver_;</div><div class="line"><a name="l00255"></a><span class="lineno"> 255</span>&#160; std::vector&lt;bool&gt; known_value_;</div><div class="line"><a name="l00256"></a><span class="lineno"> 256</span>&#160; std::vector&lt;bool&gt; best_solution_;</div><div class="line"><a name="l00257"></a><span class="lineno"> 257</span>&#160; <span class="keywordtype">bool</span> is_solution_optimal_ = <span class="keyword">false</span>;</div><div class="line"><a name="l00258"></a><span class="lineno"> 258</span>&#160; std::vector&lt;int&gt; mapping_reduced_item_id_;</div><div class="line"><a name="l00259"></a><span class="lineno"> 259</span>&#160; <span class="keywordtype">bool</span> is_problem_solved_;</div><div class="line"><a name="l00260"></a><span class="lineno"> 260</span>&#160; int64_t additional_profit_;</div><div class="line"><a name="l00261"></a><span class="lineno"> 261</span>&#160; <span class="keywordtype">bool</span> use_reduction_;</div><div class="line"><a name="l00262"></a><span class="lineno"> 262</span>&#160; <span class="keywordtype">double</span> time_limit_seconds_;</div><div class="line"><a name="l00263"></a><span class="lineno"> 263</span>&#160; std::unique_ptr&lt;TimeLimit&gt; time_limit_;</div><div class="line"><a name="l00264"></a><span class="lineno"> 264</span>&#160;</div><div class="line"><a name="l00265"></a><span class="lineno"> 265</span>&#160; DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1_knapsack_solver.html">KnapsackSolver</a>);</div><div class="line"><a name="l00266"></a><span class="lineno"> 266</span>&#160;};</div><div class="line"><a name="l00267"></a><span class="lineno"> 267</span>&#160;</div><div class="line"><a name="l00268"></a><span class="lineno"> 268</span>&#160;<span class="preprocessor">#if !defined(SWIG)</span></div><div class="line"><a name="l00269"></a><span class="lineno"> 269</span>&#160;<span class="comment">// The following code defines needed classes for the KnapsackGenericSolver</span></div><div class="line"><a name="l00270"></a><span class="lineno"> 270</span>&#160;<span class="comment">// class which is the entry point to extend knapsack with new constraints such</span></div><div class="line"><a name="l00271"></a><span class="lineno"> 271</span>&#160;<span class="comment">// as conflicts between items.</span></div><div class="line"><a name="l00272"></a><span class="lineno"> 272</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00273"></a><span class="lineno"> 273</span>&#160;<span class="comment">// Constraints are enforced using KnapsackPropagator objects, in the current</span></div><div class="line"><a name="l00274"></a><span class="lineno"> 274</span>&#160;<span class="comment">// code there is one propagator per dimension (KnapsackCapacityPropagator).</span></div><div class="line"><a name="l00275"></a><span class="lineno"> 275</span>&#160;<span class="comment">// One of those propagators, named master propagator, is used to guide the</span></div><div class="line"><a name="l00276"></a><span class="lineno"> 276</span>&#160;<span class="comment">// search, i.e. decides which item should be assigned next.</span></div><div class="line"><a name="l00277"></a><span class="lineno"> 277</span>&#160;<span class="comment">// Roughly speaking the search algorithm is:</span></div><div class="line"><a name="l00278"></a><span class="lineno"> 278</span>&#160;<span class="comment">// - While not optimal</span></div><div class="line"><a name="l00279"></a><span class="lineno"> 279</span>&#160;<span class="comment">// - Select next search node to expand</span></div><div class="line"><a name="l00280"></a><span class="lineno"> 280</span>&#160;<span class="comment">// - Select next item_i to assign (using master propagator)</span></div><div class="line"><a name="l00281"></a><span class="lineno"> 281</span>&#160;<span class="comment">// - Generate a new search node where item_i is in the knapsack</span></div><div class="line"><a name="l00282"></a><span class="lineno"> 282</span>&#160;<span class="comment">// - Check validity of this new partial solution (using propagators)</span></div><div class="line"><a name="l00283"></a><span class="lineno"> 283</span>&#160;<span class="comment">// - If valid, add this new search node to the search</span></div><div class="line"><a name="l00284"></a><span class="lineno"> 284</span>&#160;<span class="comment">// - Generate a new search node where item_i is not in the knapsack</span></div><div class="line"><a name="l00285"></a><span class="lineno"> 285</span>&#160;<span class="comment">// - Check validity of this new partial solution (using propagators)</span></div><div class="line"><a name="l00286"></a><span class="lineno"> 286</span>&#160;<span class="comment">// - If valid, add this new search node to the search</span></div><div class="line"><a name="l00287"></a><span class="lineno"> 287</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00288"></a><span class="lineno"> 288</span>&#160;<span class="comment">// TODO(user): Add a new propagator class for conflict constraint.</span></div><div class="line"><a name="l00289"></a><span class="lineno"> 289</span>&#160;<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="l00290"></a><span class="lineno"> 290</span>&#160;<span class="comment">// several dimensions.</span></div><div class="line"><a name="l00291"></a><span class="lineno"> 291</span>&#160;</div><div class="line"><a name="l00292"></a><span class="lineno"> 292</span>&#160;<span class="comment">// ----- KnapsackAssignement -----</span></div><div class="line"><a name="l00293"></a><span class="lineno"> 293</span>&#160;<span class="comment">// KnapsackAssignement is a small struct used to pair an item with its</span></div><div class="line"><a name="l00294"></a><span class="lineno"> 294</span>&#160;<span class="comment">// assignment. It is mainly used for search nodes and updates.</span></div><div class="line"><a name="l00295"></a><span class="lineno"><a class="line" href="structoperations__research_1_1_knapsack_assignment.html"> 295</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structoperations__research_1_1_knapsack_assignment.html">KnapsackAssignment</a> {</div><div class="line"><a name="l00296"></a><span class="lineno"><a class="line" href="structoperations__research_1_1_knapsack_assignment.html#a8f85eb172a4c6bed0d042f7d269fc457"> 296</a></span>&#160; <a class="code" href="structoperations__research_1_1_knapsack_assignment.html#a8f85eb172a4c6bed0d042f7d269fc457">KnapsackAssignment</a>(<span class="keywordtype">int</span> _item_id, <span class="keywordtype">bool</span> _is_in)</div><div class="line"><a name="l00297"></a><span class="lineno"> 297</span>&#160; : <a class="code" href="structoperations__research_1_1_knapsack_assignment.html#a1c0c3c835f3c4363b650fba65c7ebf32">item_id</a>(_item_id), <a class="code" href="structoperations__research_1_1_knapsack_assignment.html#a922620900c7a18d22de686d47e25d4ed">is_in</a>(_is_in) {}</div><div class="line"><a name="l00298"></a><span class="lineno"><a class="line" href="structoperations__research_1_1_knapsack_assignment.html#a1c0c3c835f3c4363b650fba65c7ebf32"> 298</a></span>&#160; <span class="keywordtype">int</span> <a class="code" href="structoperations__research_1_1_knapsack_assignment.html#a1c0c3c835f3c4363b650fba65c7ebf32">item_id</a>;</div><div class="line"><a name="l00299"></a><span class="lineno"><a class="line" href="structoperations__research_1_1_knapsack_assignment.html#a922620900c7a18d22de686d47e25d4ed"> 299</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="structoperations__research_1_1_knapsack_assignment.html#a922620900c7a18d22de686d47e25d4ed">is_in</a>;</div><div class="line"><a name="l00300"></a><span class="lineno"> 300</span>&#160;};</div><div class="line"><a name="l00301"></a><span class="lineno"> 301</span>&#160;</div><div class="line"><a name="l00302"></a><span class="lineno"> 302</span>&#160;<span class="comment">// ----- KnapsackItem -----</span></div><div class="line"><a name="l00303"></a><span class="lineno"> 303</span>&#160;<span class="comment">// KnapsackItem is a small struct to pair an item weight with its</span></div><div class="line"><a name="l00304"></a><span class="lineno"> 304</span>&#160;<span class="comment">// corresponding profit.</span></div><div class="line"><a name="l00305"></a><span class="lineno"> 305</span>&#160;<span class="comment">// The aim of the knapsack problem is to pack as many valuable items as</span></div><div class="line"><a name="l00306"></a><span class="lineno"> 306</span>&#160;<span class="comment">// possible. A straight forward heuristic is to take those with the greatest</span></div><div class="line"><a name="l00307"></a><span class="lineno"> 307</span>&#160;<span class="comment">// profit-per-unit-weight. This ratio is called efficiency in this</span></div><div class="line"><a name="l00308"></a><span class="lineno"> 308</span>&#160;<span class="comment">// implementation. So items will be grouped in vectors, and sorted by</span></div><div class="line"><a name="l00309"></a><span class="lineno"> 309</span>&#160;<span class="comment">// decreasing efficiency.</span></div><div class="line"><a name="l00310"></a><span class="lineno"> 310</span>&#160;<span class="comment">// Note that profits are duplicated for each dimension. This is done to</span></div><div class="line"><a name="l00311"></a><span class="lineno"> 311</span>&#160;<span class="comment">// simplify the code, especially the GetEfficiency method and vector sorting.</span></div><div class="line"><a name="l00312"></a><span class="lineno"> 312</span>&#160;<span class="comment">// As there usually are only few dimensions, the overhead should not be an</span></div><div class="line"><a name="l00313"></a><span class="lineno"> 313</span>&#160;<span class="comment">// issue.</span></div><div class="line"><a name="l00314"></a><span class="lineno"><a class="line" href="structoperations__research_1_1_knapsack_item.html"> 314</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structoperations__research_1_1_knapsack_item.html">KnapsackItem</a> {</div><div class="line"><a name="l00315"></a><span class="lineno"><a class="line" href="structoperations__research_1_1_knapsack_item.html#aefc8a61c2edd00c4daf37056b754e6a0"> 315</a></span>&#160; <a class="code" href="structoperations__research_1_1_knapsack_item.html#aefc8a61c2edd00c4daf37056b754e6a0">KnapsackItem</a>(<span class="keywordtype">int</span> _id, int64_t _weight, int64_t _profit)</div><div class="line"><a name="l00316"></a><span class="lineno"> 316</span>&#160; : <a class="code" href="structoperations__research_1_1_knapsack_item.html#a64ae40793ade89d800a8c5646d2980fc">id</a>(_id), <a class="code" href="structoperations__research_1_1_knapsack_item.html#a523234416a08d890505d4b34fb0513ee">weight</a>(_weight), <a class="code" href="structoperations__research_1_1_knapsack_item.html#a75dd99d0e31e3a347e5ebad01561e31d">profit</a>(_profit) {}</div><div class="line"><a name="l00317"></a><span class="lineno"><a class="line" href="structoperations__research_1_1_knapsack_item.html#a7eb6bbc72ec605de6f50d0c90f609a85"> 317</a></span>&#160; <span class="keywordtype">double</span> <a class="code" href="structoperations__research_1_1_knapsack_item.html#a7eb6bbc72ec605de6f50d0c90f609a85">GetEfficiency</a>(int64_t <a class="code" href="knapsack__solver_8cc.html#a3cb2fc3bc89582cef0819ea753e8a44d">profit_max</a>)<span class="keyword"> const </span>{</div><div class="line"><a name="l00318"></a><span class="lineno"> 318</span>&#160; <span class="keywordflow">return</span> (<a class="code" href="structoperations__research_1_1_knapsack_item.html#a523234416a08d890505d4b34fb0513ee">weight</a> &gt; 0)</div><div class="line"><a name="l00319"></a><span class="lineno"> 319</span>&#160; ? static_cast&lt;double&gt;(<a class="code" href="structoperations__research_1_1_knapsack_item.html#a75dd99d0e31e3a347e5ebad01561e31d">profit</a>) / static_cast&lt;double&gt;(<a class="code" href="structoperations__research_1_1_knapsack_item.html#a523234416a08d890505d4b34fb0513ee">weight</a>)</div><div class="line"><a name="l00320"></a><span class="lineno"> 320</span>&#160; : static_cast&lt;double&gt;(<a class="code" href="knapsack__solver_8cc.html#a3cb2fc3bc89582cef0819ea753e8a44d">profit_max</a>);</div><div class="line"><a name="l00321"></a><span class="lineno"> 321</span>&#160; }</div><div class="line"><a name="l00322"></a><span class="lineno"> 322</span>&#160;</div><div class="line"><a name="l00323"></a><span class="lineno"> 323</span>&#160; <span class="comment">// The &#39;id&#39; field is used to retrieve the initial item in order to</span></div><div class="line"><a name="l00324"></a><span class="lineno"> 324</span>&#160; <span class="comment">// communicate with other propagators and state.</span></div><div class="line"><a name="l00325"></a><span class="lineno"><a class="line" href="structoperations__research_1_1_knapsack_item.html#a64ae40793ade89d800a8c5646d2980fc"> 325</a></span>&#160; <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="structoperations__research_1_1_knapsack_item.html#a64ae40793ade89d800a8c5646d2980fc">id</a>;</div><div class="line"><a name="l00326"></a><span class="lineno"><a class="line" href="structoperations__research_1_1_knapsack_item.html#a523234416a08d890505d4b34fb0513ee"> 326</a></span>&#160; <span class="keyword">const</span> int64_t <a class="code" href="structoperations__research_1_1_knapsack_item.html#a523234416a08d890505d4b34fb0513ee">weight</a>;</div><div class="line"><a name="l00327"></a><span class="lineno"><a class="line" href="structoperations__research_1_1_knapsack_item.html#a75dd99d0e31e3a347e5ebad01561e31d"> 327</a></span>&#160; <span class="keyword">const</span> int64_t <a class="code" href="structoperations__research_1_1_knapsack_item.html#a75dd99d0e31e3a347e5ebad01561e31d">profit</a>;</div><div class="line"><a name="l00328"></a><span class="lineno"> 328</span>&#160;};</div><div class="line"><a name="l00329"></a><span class="lineno"><a class="line" href="namespaceoperations__research.html#ada7d9b46f657c6053a197273a85043a7"> 329</a></span>&#160;<span class="keyword">typedef</span> <a class="code" href="structoperations__research_1_1_knapsack_item.html">KnapsackItem</a>* <a class="code" href="namespaceoperations__research.html#ada7d9b46f657c6053a197273a85043a7">KnapsackItemPtr</a>;</div><div class="line"><a name="l00330"></a><span class="lineno"> 330</span>&#160;</div><div class="line"><a name="l00331"></a><span class="lineno"> 331</span>&#160;<span class="comment">// ----- KnapsackSearchNode -----</span></div><div class="line"><a name="l00332"></a><span class="lineno"> 332</span>&#160;<span class="comment">// KnapsackSearchNode is a class used to describe a decision in the decision</span></div><div class="line"><a name="l00333"></a><span class="lineno"> 333</span>&#160;<span class="comment">// search tree.</span></div><div class="line"><a name="l00334"></a><span class="lineno"> 334</span>&#160;<span class="comment">// The node is defined by a pointer to the parent search node and an</span></div><div class="line"><a name="l00335"></a><span class="lineno"> 335</span>&#160;<span class="comment">// assignment (see KnapsackAssignement).</span></div><div class="line"><a name="l00336"></a><span class="lineno"> 336</span>&#160;<span class="comment">// As the current state is not explicitly stored in a search node, one should</span></div><div class="line"><a name="l00337"></a><span class="lineno"> 337</span>&#160;<span class="comment">// go through the search tree to incrementally build a partial solution from</span></div><div class="line"><a name="l00338"></a><span class="lineno"> 338</span>&#160;<span class="comment">// a previous search node.</span></div><div class="line"><a name="l00339"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_node.html"> 339</a></span>&#160;<span class="keyword">class </span><a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a> {</div><div class="line"><a name="l00340"></a><span class="lineno"> 340</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00341"></a><span class="lineno"> 341</span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_search_node.html#ad17e46a2afcf393a4ec9159162c969f2">KnapsackSearchNode</a>(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>* <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html#afe9938cf4bbeb06ed8985c37646433fd">parent</a>,</div><div class="line"><a name="l00342"></a><span class="lineno"> 342</span>&#160; <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1_knapsack_assignment.html">KnapsackAssignment</a>&amp; <a class="code" href="classoperations__research_1_1_knapsack_search_node.html#afca45ec0f9ea0c2b36804720f5fa8655">assignment</a>);</div><div class="line"><a name="l00343"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_node.html#a6fdd73f8011695b97659f2bea29325cb"> 343</a></span>&#160; <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html#a6fdd73f8011695b97659f2bea29325cb">depth</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> depth_; }</div><div class="line"><a name="l00344"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_node.html#afe9938cf4bbeb06ed8985c37646433fd"> 344</a></span>&#160; <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>* <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html#afe9938cf4bbeb06ed8985c37646433fd">parent</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> parent_; }</div><div class="line"><a name="l00345"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_node.html#afca45ec0f9ea0c2b36804720f5fa8655"> 345</a></span>&#160; <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1_knapsack_assignment.html">KnapsackAssignment</a>&amp; <a class="code" href="classoperations__research_1_1_knapsack_search_node.html#afca45ec0f9ea0c2b36804720f5fa8655">assignment</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> assignment_; }</div><div class="line"><a name="l00346"></a><span class="lineno"> 346</span>&#160;</div><div class="line"><a name="l00347"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_node.html#a08beea2d857241d99287935a91be5217"> 347</a></span>&#160; int64_t <a class="code" href="classoperations__research_1_1_knapsack_search_node.html#a08beea2d857241d99287935a91be5217">current_profit</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> current_profit_; }</div><div class="line"><a name="l00348"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_node.html#a48521e7b1a381bd3f3f452fa6e697bde"> 348</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html#a48521e7b1a381bd3f3f452fa6e697bde">set_current_profit</a>(int64_t profit) { current_profit_ = profit; }</div><div class="line"><a name="l00349"></a><span class="lineno"> 349</span>&#160;</div><div class="line"><a name="l00350"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_node.html#aa68069fd1180cb37fcdbc99d6230bc3e"> 350</a></span>&#160; int64_t <a class="code" href="classoperations__research_1_1_knapsack_search_node.html#aa68069fd1180cb37fcdbc99d6230bc3e">profit_upper_bound</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> profit_upper_bound_; }</div><div class="line"><a name="l00351"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_node.html#af991b29f273c53c8b35cb09bcccf3a5d"> 351</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html#af991b29f273c53c8b35cb09bcccf3a5d">set_profit_upper_bound</a>(int64_t profit) { profit_upper_bound_ = profit; }</div><div class="line"><a name="l00352"></a><span class="lineno"> 352</span>&#160;</div><div class="line"><a name="l00353"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_node.html#a94dca4e57f87ba2a9e3b995c267c0821"> 353</a></span>&#160; <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html#a94dca4e57f87ba2a9e3b995c267c0821">next_item_id</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> next_item_id_; }</div><div class="line"><a name="l00354"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_node.html#a9962698a737cd21789c77ff32bef0d98"> 354</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html#a9962698a737cd21789c77ff32bef0d98">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="l00355"></a><span class="lineno"> 355</span>&#160;</div><div class="line"><a name="l00356"></a><span class="lineno"> 356</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00357"></a><span class="lineno"> 357</span>&#160; <span class="comment">// &#39;depth&#39; field is used to navigate efficiently through the search tree</span></div><div class="line"><a name="l00358"></a><span class="lineno"> 358</span>&#160; <span class="comment">// (see KnapsackSearchPath).</span></div><div class="line"><a name="l00359"></a><span class="lineno"> 359</span>&#160; <span class="keywordtype">int</span> depth_;</div><div class="line"><a name="l00360"></a><span class="lineno"> 360</span>&#160; <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>* <span class="keyword">const</span> parent_;</div><div class="line"><a name="l00361"></a><span class="lineno"> 361</span>&#160; <a class="code" href="structoperations__research_1_1_knapsack_assignment.html">KnapsackAssignment</a> assignment_;</div><div class="line"><a name="l00362"></a><span class="lineno"> 362</span>&#160;</div><div class="line"><a name="l00363"></a><span class="lineno"> 363</span>&#160; <span class="comment">// &#39;current_profit&#39; and &#39;profit_upper_bound&#39; fields are used to sort search</span></div><div class="line"><a name="l00364"></a><span class="lineno"> 364</span>&#160; <span class="comment">// nodes using a priority queue. That allows to pop the node with the best</span></div><div class="line"><a name="l00365"></a><span class="lineno"> 365</span>&#160; <span class="comment">// upper bound, and more importantly to stop the search when optimality is</span></div><div class="line"><a name="l00366"></a><span class="lineno"> 366</span>&#160; <span class="comment">// proved.</span></div><div class="line"><a name="l00367"></a><span class="lineno"> 367</span>&#160; int64_t current_profit_;</div><div class="line"><a name="l00368"></a><span class="lineno"> 368</span>&#160; int64_t profit_upper_bound_;</div><div class="line"><a name="l00369"></a><span class="lineno"> 369</span>&#160;</div><div class="line"><a name="l00370"></a><span class="lineno"> 370</span>&#160; <span class="comment">// &#39;next_item_id&#39; field allows to avoid an O(number_of_items) scan to find</span></div><div class="line"><a name="l00371"></a><span class="lineno"> 371</span>&#160; <span class="comment">// next item to select. This is done for free by the upper bound computation.</span></div><div class="line"><a name="l00372"></a><span class="lineno"> 372</span>&#160; <span class="keywordtype">int</span> next_item_id_;</div><div class="line"><a name="l00373"></a><span class="lineno"> 373</span>&#160;</div><div class="line"><a name="l00374"></a><span class="lineno"> 374</span>&#160; DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>);</div><div class="line"><a name="l00375"></a><span class="lineno"> 375</span>&#160;};</div><div class="line"><a name="l00376"></a><span class="lineno"> 376</span>&#160;</div><div class="line"><a name="l00377"></a><span class="lineno"> 377</span>&#160;<span class="comment">// ----- KnapsackSearchPath -----</span></div><div class="line"><a name="l00378"></a><span class="lineno"> 378</span>&#160;<span class="comment">// KnapsackSearchPath is a small class used to represent the path between a</span></div><div class="line"><a name="l00379"></a><span class="lineno"> 379</span>&#160;<span class="comment">// node to another node in the search tree.</span></div><div class="line"><a name="l00380"></a><span class="lineno"> 380</span>&#160;<span class="comment">// As the solution state is not stored for each search node, the state should</span></div><div class="line"><a name="l00381"></a><span class="lineno"> 381</span>&#160;<span class="comment">// be rebuilt at each node. One simple solution is to apply all decisions</span></div><div class="line"><a name="l00382"></a><span class="lineno"> 382</span>&#160;<span class="comment">// between the node &#39;to&#39; and the root. This can be computed in</span></div><div class="line"><a name="l00383"></a><span class="lineno"> 383</span>&#160;<span class="comment">// O(number_of_items).</span></div><div class="line"><a name="l00384"></a><span class="lineno"> 384</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00385"></a><span class="lineno"> 385</span>&#160;<span class="comment">// However, it is possible to achieve better average complexity. Two</span></div><div class="line"><a name="l00386"></a><span class="lineno"> 386</span>&#160;<span class="comment">// consecutively explored nodes are usually close enough (i.e., much less than</span></div><div class="line"><a name="l00387"></a><span class="lineno"> 387</span>&#160;<span class="comment">// number_of_items) to benefit from an incremental update from the node</span></div><div class="line"><a name="l00388"></a><span class="lineno"> 388</span>&#160;<span class="comment">// &#39;from&#39; to the node &#39;to&#39;.</span></div><div class="line"><a name="l00389"></a><span class="lineno"> 389</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00390"></a><span class="lineno"> 390</span>&#160;<span class="comment">// The &#39;via&#39; field is the common parent of &#39;from&#39; field and &#39;to&#39; field.</span></div><div class="line"><a name="l00391"></a><span class="lineno"> 391</span>&#160;<span class="comment">// So the state can be built by reverting all decisions from &#39;from&#39; to &#39;via&#39;</span></div><div class="line"><a name="l00392"></a><span class="lineno"> 392</span>&#160;<span class="comment">// and then applying all decisions from &#39;via&#39; to &#39;to&#39;.</span></div><div class="line"><a name="l00393"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_path.html"> 393</a></span>&#160;<span class="keyword">class </span><a class="code" href="classoperations__research_1_1_knapsack_search_path.html">KnapsackSearchPath</a> {</div><div class="line"><a name="l00394"></a><span class="lineno"> 394</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00395"></a><span class="lineno"> 395</span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_search_path.html#a3dc3602e1a640bc986956e0ce5e88d04">KnapsackSearchPath</a>(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>&amp; <a class="code" href="classoperations__research_1_1_knapsack_search_path.html#aa4d0c972d711bfb97638280fa646f83d">from</a>,</div><div class="line"><a name="l00396"></a><span class="lineno"> 396</span>&#160; <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>&amp; <a class="code" href="classoperations__research_1_1_knapsack_search_path.html#af020a457732b35e71f0bce09433ba4f2">to</a>);</div><div class="line"><a name="l00397"></a><span class="lineno"> 397</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_search_path.html#a1e3b6d38df0786ccf7f938d60e386aae">Init</a>();</div><div class="line"><a name="l00398"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_path.html#aa4d0c972d711bfb97638280fa646f83d"> 398</a></span>&#160; <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>&amp; <a class="code" href="classoperations__research_1_1_knapsack_search_path.html#aa4d0c972d711bfb97638280fa646f83d">from</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> from_; }</div><div class="line"><a name="l00399"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_path.html#a1dcc659f782497ac856c5223c0819713"> 399</a></span>&#160; <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>&amp; <a class="code" href="classoperations__research_1_1_knapsack_search_path.html#a1dcc659f782497ac856c5223c0819713">via</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> *via_; }</div><div class="line"><a name="l00400"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_search_path.html#af020a457732b35e71f0bce09433ba4f2"> 400</a></span>&#160; <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>&amp; <a class="code" href="classoperations__research_1_1_knapsack_search_path.html#af020a457732b35e71f0bce09433ba4f2">to</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> to_; }</div><div class="line"><a name="l00401"></a><span class="lineno"> 401</span>&#160; <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>* <a class="code" href="classoperations__research_1_1_knapsack_search_path.html#a09f219a2226f7c0de0f50b6f00c099e3">MoveUpToDepth</a>(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>&amp; node,</div><div class="line"><a name="l00402"></a><span class="lineno"> 402</span>&#160; <span class="keywordtype">int</span> depth) <span class="keyword">const</span>;</div><div class="line"><a name="l00403"></a><span class="lineno"> 403</span>&#160;</div><div class="line"><a name="l00404"></a><span class="lineno"> 404</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00405"></a><span class="lineno"> 405</span>&#160; <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>&amp; from_;</div><div class="line"><a name="l00406"></a><span class="lineno"> 406</span>&#160; <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>* via_; <span class="comment">// Computed in &#39;Init&#39;.</span></div><div class="line"><a name="l00407"></a><span class="lineno"> 407</span>&#160; <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>&amp; to_;</div><div class="line"><a name="l00408"></a><span class="lineno"> 408</span>&#160;</div><div class="line"><a name="l00409"></a><span class="lineno"> 409</span>&#160; DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1_knapsack_search_path.html">KnapsackSearchPath</a>);</div><div class="line"><a name="l00410"></a><span class="lineno"> 410</span>&#160;};</div><div class="line"><a name="l00411"></a><span class="lineno"> 411</span>&#160;</div><div class="line"><a name="l00412"></a><span class="lineno"> 412</span>&#160;<span class="comment">// ----- KnapsackState -----</span></div><div class="line"><a name="l00413"></a><span class="lineno"> 413</span>&#160;<span class="comment">// KnapsackState represents a partial solution to the knapsack problem.</span></div><div class="line"><a name="l00414"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_state.html"> 414</a></span>&#160;<span class="keyword">class </span><a class="code" href="classoperations__research_1_1_knapsack_state.html">KnapsackState</a> {</div><div class="line"><a name="l00415"></a><span class="lineno"> 415</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00416"></a><span class="lineno"> 416</span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_state.html#a41f9430cc0090383e7797a88c1dbacbc">KnapsackState</a>();</div><div class="line"><a name="l00417"></a><span class="lineno"> 417</span>&#160;</div><div class="line"><a name="l00418"></a><span class="lineno"> 418</span>&#160; <span class="comment">// Initializes vectors with number_of_items set to false (i.e. not bound yet).</span></div><div class="line"><a name="l00419"></a><span class="lineno"> 419</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_state.html#a6308c7a97200f84f6ebf5b2c487b0362">Init</a>(<span class="keywordtype">int</span> number_of_items);</div><div class="line"><a name="l00420"></a><span class="lineno"> 420</span>&#160; <span class="comment">// Updates the state by applying or reverting a decision.</span></div><div class="line"><a name="l00421"></a><span class="lineno"> 421</span>&#160; <span class="comment">// Returns false if fails, i.e. trying to apply an inconsistent decision</span></div><div class="line"><a name="l00422"></a><span class="lineno"> 422</span>&#160; <span class="comment">// to an already assigned item.</span></div><div class="line"><a name="l00423"></a><span class="lineno"> 423</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_knapsack_state.html#ab771ac0e538f991b73b011ee3ba11f05">UpdateState</a>(<span class="keywordtype">bool</span> revert, <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1_knapsack_assignment.html">KnapsackAssignment</a>&amp; assignment);</div><div class="line"><a name="l00424"></a><span class="lineno"> 424</span>&#160;</div><div class="line"><a name="l00425"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_state.html#a5c677592ee5e7312c64475ebae949eab"> 425</a></span>&#160; <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1_knapsack_state.html#a5c677592ee5e7312c64475ebae949eab">GetNumberOfItems</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> is_bound_.size(); }</div><div class="line"><a name="l00426"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_state.html#a89aa280d2321c1316aa1305106f1bb49"> 426</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_knapsack_state.html#a89aa280d2321c1316aa1305106f1bb49">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="l00427"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_state.html#a862bf4e908cd82ea44f72e98558016ad"> 427</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_knapsack_state.html#a862bf4e908cd82ea44f72e98558016ad">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="l00428"></a><span class="lineno"> 428</span>&#160;</div><div class="line"><a name="l00429"></a><span class="lineno"> 429</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00430"></a><span class="lineno"> 430</span>&#160; <span class="comment">// Vectors &#39;is_bound_&#39; and &#39;is_in_&#39; contain a boolean value for each item.</span></div><div class="line"><a name="l00431"></a><span class="lineno"> 431</span>&#160; <span class="comment">// &#39;is_bound_(item_i)&#39; is false when there is no decision for item_i yet.</span></div><div class="line"><a name="l00432"></a><span class="lineno"> 432</span>&#160; <span class="comment">// When item_i is bound, &#39;is_in_(item_i)&#39; represents the presence (true) or</span></div><div class="line"><a name="l00433"></a><span class="lineno"> 433</span>&#160; <span class="comment">// the absence (false) of item_i in the current solution.</span></div><div class="line"><a name="l00434"></a><span class="lineno"> 434</span>&#160; std::vector&lt;bool&gt; is_bound_;</div><div class="line"><a name="l00435"></a><span class="lineno"> 435</span>&#160; std::vector&lt;bool&gt; is_in_;</div><div class="line"><a name="l00436"></a><span class="lineno"> 436</span>&#160;</div><div class="line"><a name="l00437"></a><span class="lineno"> 437</span>&#160; DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1_knapsack_state.html">KnapsackState</a>);</div><div class="line"><a name="l00438"></a><span class="lineno"> 438</span>&#160;};</div><div class="line"><a name="l00439"></a><span class="lineno"> 439</span>&#160;</div><div class="line"><a name="l00440"></a><span class="lineno"> 440</span>&#160;<span class="comment">// ----- KnapsackPropagator -----</span></div><div class="line"><a name="l00441"></a><span class="lineno"> 441</span>&#160;<span class="comment">// KnapsackPropagator is the base class for modeling and propagating a</span></div><div class="line"><a name="l00442"></a><span class="lineno"> 442</span>&#160;<span class="comment">// constraint given an assignment.</span></div><div class="line"><a name="l00443"></a><span class="lineno"> 443</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00444"></a><span class="lineno"> 444</span>&#160;<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="l00445"></a><span class="lineno"> 445</span>&#160;<span class="comment">// a protected pure virtual method ending by &#39;Propagator&#39; is defined.</span></div><div class="line"><a name="l00446"></a><span class="lineno"> 446</span>&#160;<span class="comment">// For instance, &#39;Init&#39; creates a vector of items, and then calls</span></div><div class="line"><a name="l00447"></a><span class="lineno"> 447</span>&#160;<span class="comment">// &#39;InitPropagator&#39; to let the derived class perform its own initialization.</span></div><div class="line"><a name="l00448"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_propagator.html"> 448</a></span>&#160;<span class="keyword">class </span><a class="code" href="classoperations__research_1_1_knapsack_propagator.html">KnapsackPropagator</a> {</div><div class="line"><a name="l00449"></a><span class="lineno"> 449</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00450"></a><span class="lineno"> 450</span>&#160; <span class="keyword">explicit</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#af28391017c090a638200c57b4c8a2ac1">KnapsackPropagator</a>(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_state.html">KnapsackState</a>&amp; <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#a9b748c5fb5e1da5da53026ffb91db51f">state</a>);</div><div class="line"><a name="l00451"></a><span class="lineno"> 451</span>&#160; <span class="keyword">virtual</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#af15d878d664ee8a07cf3b710f8047cba">~KnapsackPropagator</a>();</div><div class="line"><a name="l00452"></a><span class="lineno"> 452</span>&#160;</div><div class="line"><a name="l00453"></a><span class="lineno"> 453</span>&#160; <span class="comment">// Initializes data structure and then calls InitPropagator.</span></div><div class="line"><a name="l00454"></a><span class="lineno"> 454</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#a04d8883567a6e02787f2362e6543a21b">Init</a>(<span class="keyword">const</span> std::vector&lt;int64_t&gt;&amp; profits,</div><div class="line"><a name="l00455"></a><span class="lineno"> 455</span>&#160; <span class="keyword">const</span> std::vector&lt;int64_t&gt;&amp; weights);</div><div class="line"><a name="l00456"></a><span class="lineno"> 456</span>&#160;</div><div class="line"><a name="l00457"></a><span class="lineno"> 457</span>&#160; <span class="comment">// Updates data structure and then calls UpdatePropagator.</span></div><div class="line"><a name="l00458"></a><span class="lineno"> 458</span>&#160; <span class="comment">// Returns false when failure.</span></div><div class="line"><a name="l00459"></a><span class="lineno"> 459</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#af4b38123d3654471f0868774c5ff877d">Update</a>(<span class="keywordtype">bool</span> revert, <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1_knapsack_assignment.html">KnapsackAssignment</a>&amp; assignment);</div><div class="line"><a name="l00460"></a><span class="lineno"> 460</span>&#160; <span class="comment">// ComputeProfitBounds should set &#39;profit_lower_bound_&#39; and</span></div><div class="line"><a name="l00461"></a><span class="lineno"> 461</span>&#160; <span class="comment">// &#39;profit_upper_bound_&#39; which are constraint specific.</span></div><div class="line"><a name="l00462"></a><span class="lineno"> 462</span>&#160; <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#a8ae457a5297bac5ad83517ba54b819d1">ComputeProfitBounds</a>() = 0;</div><div class="line"><a name="l00463"></a><span class="lineno"> 463</span>&#160; <span class="comment">// Returns the id of next item to assign.</span></div><div class="line"><a name="l00464"></a><span class="lineno"> 464</span>&#160; <span class="comment">// Returns kNoSelection when all items are bound.</span></div><div class="line"><a name="l00465"></a><span class="lineno"> 465</span>&#160; <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#a9aea5e61ac71dca1139fda445cc2dfee">GetNextItemId</a>() <span class="keyword">const</span> = 0;</div><div class="line"><a name="l00466"></a><span class="lineno"> 466</span>&#160;</div><div class="line"><a name="l00467"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_propagator.html#a08beea2d857241d99287935a91be5217"> 467</a></span>&#160; int64_t <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#a08beea2d857241d99287935a91be5217">current_profit</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> current_profit_; }</div><div class="line"><a name="l00468"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_propagator.html#ae04e419341e0b9772a057aff10ce63a0"> 468</a></span>&#160; int64_t <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#ae04e419341e0b9772a057aff10ce63a0">profit_lower_bound</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> profit_lower_bound_; }</div><div class="line"><a name="l00469"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_propagator.html#aa68069fd1180cb37fcdbc99d6230bc3e"> 469</a></span>&#160; int64_t <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#aa68069fd1180cb37fcdbc99d6230bc3e">profit_upper_bound</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> profit_upper_bound_; }</div><div class="line"><a name="l00470"></a><span class="lineno"> 470</span>&#160;</div><div class="line"><a name="l00471"></a><span class="lineno"> 471</span>&#160; <span class="comment">// Copies the current state into &#39;solution&#39;.</span></div><div class="line"><a name="l00472"></a><span class="lineno"> 472</span>&#160; <span class="comment">// All unbound items are set to false (i.e. not in the knapsack).</span></div><div class="line"><a name="l00473"></a><span class="lineno"> 473</span>&#160; <span class="comment">// When &#39;has_one_propagator&#39; is true, CopyCurrentSolutionPropagator is called</span></div><div class="line"><a name="l00474"></a><span class="lineno"> 474</span>&#160; <span class="comment">// to have a better solution. When there is only one propagator</span></div><div class="line"><a name="l00475"></a><span class="lineno"> 475</span>&#160; <span class="comment">// there is no need to check the solution with other propagators, so the</span></div><div class="line"><a name="l00476"></a><span class="lineno"> 476</span>&#160; <span class="comment">// partial solution can be smartly completed.</span></div><div class="line"><a name="l00477"></a><span class="lineno"> 477</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#a1fa45af1bf0d6aa9d5f86e2ed9ae5323">CopyCurrentStateToSolution</a>(<span class="keywordtype">bool</span> has_one_propagator,</div><div class="line"><a name="l00478"></a><span class="lineno"> 478</span>&#160; std::vector&lt;bool&gt;* solution) <span class="keyword">const</span>;</div><div class="line"><a name="l00479"></a><span class="lineno"> 479</span>&#160;</div><div class="line"><a name="l00480"></a><span class="lineno"> 480</span>&#160; <span class="keyword">protected</span>:</div><div class="line"><a name="l00481"></a><span class="lineno"> 481</span>&#160; <span class="comment">// Initializes data structure. This method is called after initialization</span></div><div class="line"><a name="l00482"></a><span class="lineno"> 482</span>&#160; <span class="comment">// of KnapsackPropagator data structure.</span></div><div class="line"><a name="l00483"></a><span class="lineno"> 483</span>&#160; <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#a883cd053b1e7322727eb9e19940f69f6">InitPropagator</a>() = 0;</div><div class="line"><a name="l00484"></a><span class="lineno"> 484</span>&#160;</div><div class="line"><a name="l00485"></a><span class="lineno"> 485</span>&#160; <span class="comment">// Updates internal data structure incrementally. This method is called</span></div><div class="line"><a name="l00486"></a><span class="lineno"> 486</span>&#160; <span class="comment">// after update of KnapsackPropagator data structure.</span></div><div class="line"><a name="l00487"></a><span class="lineno"> 487</span>&#160; <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#a5a0d11be6f0d5b521477226fb7573db8">UpdatePropagator</a>(<span class="keywordtype">bool</span> revert,</div><div class="line"><a name="l00488"></a><span class="lineno"> 488</span>&#160; <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1_knapsack_assignment.html">KnapsackAssignment</a>&amp; assignment) = 0;</div><div class="line"><a name="l00489"></a><span class="lineno"> 489</span>&#160;</div><div class="line"><a name="l00490"></a><span class="lineno"> 490</span>&#160; <span class="comment">// Copies the current state into &#39;solution&#39;.</span></div><div class="line"><a name="l00491"></a><span class="lineno"> 491</span>&#160; <span class="comment">// Only unbound items have to be copied as CopyCurrentSolution was already</span></div><div class="line"><a name="l00492"></a><span class="lineno"> 492</span>&#160; <span class="comment">// called with current state.</span></div><div class="line"><a name="l00493"></a><span class="lineno"> 493</span>&#160; <span class="comment">// This method is useful when a propagator is able to find a better solution</span></div><div class="line"><a name="l00494"></a><span class="lineno"> 494</span>&#160; <span class="comment">// than the blind instantiation to false of unbound items.</span></div><div class="line"><a name="l00495"></a><span class="lineno"> 495</span>&#160; <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#ab803770e8e21bb448a2f3d940ab125f8">CopyCurrentStateToSolutionPropagator</a>(</div><div class="line"><a name="l00496"></a><span class="lineno"> 496</span>&#160; std::vector&lt;bool&gt;* solution) <span class="keyword">const</span> = 0;</div><div class="line"><a name="l00497"></a><span class="lineno"> 497</span>&#160;</div><div class="line"><a name="l00498"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_propagator.html#a9b748c5fb5e1da5da53026ffb91db51f"> 498</a></span>&#160; <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_state.html">KnapsackState</a>&amp; <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#a9b748c5fb5e1da5da53026ffb91db51f">state</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> state_; }</div><div class="line"><a name="l00499"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_propagator.html#aa4161d4fb0a577a3e854b7f285d7ace6"> 499</a></span>&#160; <span class="keyword">const</span> std::vector&lt;KnapsackItemPtr&gt;&amp; <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#aa4161d4fb0a577a3e854b7f285d7ace6">items</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> items_; }</div><div class="line"><a name="l00500"></a><span class="lineno"> 500</span>&#160;</div><div class="line"><a name="l00501"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_propagator.html#ae29226a5be6204e26f1d563a6630ab9e"> 501</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#ae29226a5be6204e26f1d563a6630ab9e">set_profit_lower_bound</a>(int64_t profit) { profit_lower_bound_ = profit; }</div><div class="line"><a name="l00502"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_propagator.html#af991b29f273c53c8b35cb09bcccf3a5d"> 502</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#af991b29f273c53c8b35cb09bcccf3a5d">set_profit_upper_bound</a>(int64_t profit) { profit_upper_bound_ = profit; }</div><div class="line"><a name="l00503"></a><span class="lineno"> 503</span>&#160;</div><div class="line"><a name="l00504"></a><span class="lineno"> 504</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00505"></a><span class="lineno"> 505</span>&#160; std::vector&lt;KnapsackItemPtr&gt; items_;</div><div class="line"><a name="l00506"></a><span class="lineno"> 506</span>&#160; int64_t current_profit_;</div><div class="line"><a name="l00507"></a><span class="lineno"> 507</span>&#160; int64_t profit_lower_bound_;</div><div class="line"><a name="l00508"></a><span class="lineno"> 508</span>&#160; int64_t profit_upper_bound_;</div><div class="line"><a name="l00509"></a><span class="lineno"> 509</span>&#160; <span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_state.html">KnapsackState</a>&amp; state_;</div><div class="line"><a name="l00510"></a><span class="lineno"> 510</span>&#160;</div><div class="line"><a name="l00511"></a><span class="lineno"> 511</span>&#160; DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1_knapsack_propagator.html">KnapsackPropagator</a>);</div><div class="line"><a name="l00512"></a><span class="lineno"> 512</span>&#160;};</div><div class="line"><a name="l00513"></a><span class="lineno"> 513</span>&#160;</div><div class="line"><a name="l00514"></a><span class="lineno"> 514</span>&#160;<span class="comment">// ----- KnapsackCapacityPropagator -----</span></div><div class="line"><a name="l00515"></a><span class="lineno"> 515</span>&#160;<span class="comment">// KnapsackCapacityPropagator is a KnapsackPropagator used to enforce</span></div><div class="line"><a name="l00516"></a><span class="lineno"> 516</span>&#160;<span class="comment">// a capacity constraint.</span></div><div class="line"><a name="l00517"></a><span class="lineno"> 517</span>&#160;<span class="comment">// As a KnapsackPropagator is supposed to compute profit lower and upper</span></div><div class="line"><a name="l00518"></a><span class="lineno"> 518</span>&#160;<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="l00519"></a><span class="lineno"> 519</span>&#160;<span class="comment">// solver. The most efficient way to compute the upper bound is to iterate on</span></div><div class="line"><a name="l00520"></a><span class="lineno"> 520</span>&#160;<span class="comment">// items in profit-per-unit-weight decreasing order. The break item is</span></div><div class="line"><a name="l00521"></a><span class="lineno"> 521</span>&#160;<span class="comment">// commonly defined as the first item for which there is not enough remaining</span></div><div class="line"><a name="l00522"></a><span class="lineno"> 522</span>&#160;<span class="comment">// capacity. Selecting this break item as the next-item-to-assign usually</span></div><div class="line"><a name="l00523"></a><span class="lineno"> 523</span>&#160;<span class="comment">// gives the best results (see Greenberg &amp; Hegerich).</span></div><div class="line"><a name="l00524"></a><span class="lineno"> 524</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00525"></a><span class="lineno"> 525</span>&#160;<span class="comment">// This is exactly what is implemented in this class.</span></div><div class="line"><a name="l00526"></a><span class="lineno"> 526</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00527"></a><span class="lineno"> 527</span>&#160;<span class="comment">// When there is only one propagator, it is possible to compute a better</span></div><div class="line"><a name="l00528"></a><span class="lineno"> 528</span>&#160;<span class="comment">// profit lower bound almost for free. During the scan to find the</span></div><div class="line"><a name="l00529"></a><span class="lineno"> 529</span>&#160;<span class="comment">// break element all unbound items are added just as if they were part of</span></div><div class="line"><a name="l00530"></a><span class="lineno"> 530</span>&#160;<span class="comment">// the current solution. This is used in both ComputeProfitBounds and</span></div><div class="line"><a name="l00531"></a><span class="lineno"> 531</span>&#160;<span class="comment">// CopyCurrentSolutionPropagator.</span></div><div class="line"><a name="l00532"></a><span class="lineno"> 532</span>&#160;<span class="comment">// For incrementality reasons, the ith item should be accessible in O(1). That&#39;s</span></div><div class="line"><a name="l00533"></a><span class="lineno"> 533</span>&#160;<span class="comment">// the reason why the item vector has to be duplicated &#39;sorted_items_&#39;.</span></div><div class="line"><a name="l00534"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_capacity_propagator.html"> 534</a></span>&#160;<span class="keyword">class </span><a class="code" href="classoperations__research_1_1_knapsack_capacity_propagator.html">KnapsackCapacityPropagator</a> : <span class="keyword">public</span> <a class="code" href="classoperations__research_1_1_knapsack_propagator.html">KnapsackPropagator</a> {</div><div class="line"><a name="l00535"></a><span class="lineno"> 535</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00536"></a><span class="lineno"> 536</span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_capacity_propagator.html#a2ce43dc07784f3d9634df0a5c0dc39b0">KnapsackCapacityPropagator</a>(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_state.html">KnapsackState</a>&amp; <a class="code" href="classoperations__research_1_1_knapsack_propagator.html#a9b748c5fb5e1da5da53026ffb91db51f">state</a>, int64_t <a class="code" href="routing__flow_8cc.html#a2acb49f4df5288066c43610bede123ec">capacity</a>);</div><div class="line"><a name="l00537"></a><span class="lineno"> 537</span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_capacity_propagator.html#aa14e63156675c18c06073ac1cb8aa170">~KnapsackCapacityPropagator</a>() <span class="keyword">override</span>;</div><div class="line"><a name="l00538"></a><span class="lineno"> 538</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_capacity_propagator.html#a9921c39ed90a9cd32301ee0fee9491cb">ComputeProfitBounds</a>() <span class="keyword">override</span>;</div><div class="line"><a name="l00539"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_capacity_propagator.html#afccfe4a5a27c2c805016d82886795da9"> 539</a></span>&#160; <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1_knapsack_capacity_propagator.html#afccfe4a5a27c2c805016d82886795da9">GetNextItemId</a>()<span class="keyword"> const override </span>{ <span class="keywordflow">return</span> break_item_id_; }</div><div class="line"><a name="l00540"></a><span class="lineno"> 540</span>&#160;</div><div class="line"><a name="l00541"></a><span class="lineno"> 541</span>&#160; <span class="keyword">protected</span>:</div><div class="line"><a name="l00542"></a><span class="lineno"> 542</span>&#160; <span class="comment">// Initializes KnapsackCapacityPropagator (e.g., sort items in decreasing</span></div><div class="line"><a name="l00543"></a><span class="lineno"> 543</span>&#160; <span class="comment">// order).</span></div><div class="line"><a name="l00544"></a><span class="lineno"> 544</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_capacity_propagator.html#ae2545020be753ee6a66c277daac41784">InitPropagator</a>() <span class="keyword">override</span>;</div><div class="line"><a name="l00545"></a><span class="lineno"> 545</span>&#160; <span class="comment">// Updates internal data structure incrementally (i.e., &#39;consumed_capacity_&#39;)</span></div><div class="line"><a name="l00546"></a><span class="lineno"> 546</span>&#160; <span class="comment">// to avoid a O(number_of_items) scan.</span></div><div class="line"><a name="l00547"></a><span class="lineno"> 547</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_knapsack_capacity_propagator.html#a3cde41b7fa0c9734783a562aadd9ef8c">UpdatePropagator</a>(<span class="keywordtype">bool</span> revert,</div><div class="line"><a name="l00548"></a><span class="lineno"> 548</span>&#160; <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1_knapsack_assignment.html">KnapsackAssignment</a>&amp; assignment) <span class="keyword">override</span>;</div><div class="line"><a name="l00549"></a><span class="lineno"> 549</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_capacity_propagator.html#a706a3a7c9568016131afd718f347ec8d">CopyCurrentStateToSolutionPropagator</a>(</div><div class="line"><a name="l00550"></a><span class="lineno"> 550</span>&#160; std::vector&lt;bool&gt;* solution) <span class="keyword">const override</span>;</div><div class="line"><a name="l00551"></a><span class="lineno"> 551</span>&#160;</div><div class="line"><a name="l00552"></a><span class="lineno"> 552</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00553"></a><span class="lineno"> 553</span>&#160; <span class="comment">// An obvious additional profit upper bound corresponds to the linear</span></div><div class="line"><a name="l00554"></a><span class="lineno"> 554</span>&#160; <span class="comment">// relaxation: remaining_capacity * efficiency of the break item.</span></div><div class="line"><a name="l00555"></a><span class="lineno"> 555</span>&#160; <span class="comment">// It is possible to do better in O(1), using Martello-Toth bound U2.</span></div><div class="line"><a name="l00556"></a><span class="lineno"> 556</span>&#160; <span class="comment">// The main idea is to enforce integrality constraint on the break item,</span></div><div class="line"><a name="l00557"></a><span class="lineno"> 557</span>&#160; <span class="comment">// ie. either the break item is part of the solution, either it is not.</span></div><div class="line"><a name="l00558"></a><span class="lineno"> 558</span>&#160; <span class="comment">// So basically the linear relaxation is done on the item before the break</span></div><div class="line"><a name="l00559"></a><span class="lineno"> 559</span>&#160; <span class="comment">// item, or the one after the break item.</span></div><div class="line"><a name="l00560"></a><span class="lineno"> 560</span>&#160; <span class="comment">// This is what GetAdditionalProfit method implements.</span></div><div class="line"><a name="l00561"></a><span class="lineno"> 561</span>&#160; int64_t GetAdditionalProfit(int64_t remaining_capacity,</div><div class="line"><a name="l00562"></a><span class="lineno"> 562</span>&#160; <span class="keywordtype">int</span> break_item_id) <span class="keyword">const</span>;</div><div class="line"><a name="l00563"></a><span class="lineno"> 563</span>&#160;</div><div class="line"><a name="l00564"></a><span class="lineno"> 564</span>&#160; <span class="keyword">const</span> int64_t capacity_;</div><div class="line"><a name="l00565"></a><span class="lineno"> 565</span>&#160; int64_t consumed_capacity_;</div><div class="line"><a name="l00566"></a><span class="lineno"> 566</span>&#160; <span class="keywordtype">int</span> break_item_id_;</div><div class="line"><a name="l00567"></a><span class="lineno"> 567</span>&#160; std::vector&lt;KnapsackItemPtr&gt; sorted_items_;</div><div class="line"><a name="l00568"></a><span class="lineno"> 568</span>&#160; int64_t profit_max_;</div><div class="line"><a name="l00569"></a><span class="lineno"> 569</span>&#160;</div><div class="line"><a name="l00570"></a><span class="lineno"> 570</span>&#160; DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1_knapsack_capacity_propagator.html">KnapsackCapacityPropagator</a>);</div><div class="line"><a name="l00571"></a><span class="lineno"> 571</span>&#160;};</div><div class="line"><a name="l00572"></a><span class="lineno"> 572</span>&#160;</div><div class="line"><a name="l00573"></a><span class="lineno"> 573</span>&#160;<span class="comment">// ----- BaseKnapsackSolver -----</span></div><div class="line"><a name="l00574"></a><span class="lineno"> 574</span>&#160;<span class="comment">// This is the base class for knapsack solvers.</span></div><div class="line"><a name="l00575"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_base_knapsack_solver.html"> 575</a></span>&#160;<span class="keyword">class </span><a class="code" href="classoperations__research_1_1_base_knapsack_solver.html">BaseKnapsackSolver</a> {</div><div class="line"><a name="l00576"></a><span class="lineno"> 576</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00577"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_base_knapsack_solver.html#ac6518fa5a6dd37173c7700bc2d9b6071"> 577</a></span>&#160; <span class="keyword">explicit</span> <a class="code" href="classoperations__research_1_1_base_knapsack_solver.html#ac6518fa5a6dd37173c7700bc2d9b6071">BaseKnapsackSolver</a>(<span class="keyword">const</span> std::string&amp; solver_name)</div><div class="line"><a name="l00578"></a><span class="lineno"> 578</span>&#160; : solver_name_(solver_name) {}</div><div class="line"><a name="l00579"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_base_knapsack_solver.html#ab5b44517ac32ba76590129831a826096"> 579</a></span>&#160; <span class="keyword">virtual</span> <a class="code" href="classoperations__research_1_1_base_knapsack_solver.html#ab5b44517ac32ba76590129831a826096">~BaseKnapsackSolver</a>() {}</div><div class="line"><a name="l00580"></a><span class="lineno"> 580</span>&#160;</div><div class="line"><a name="l00581"></a><span class="lineno"> 581</span>&#160; <span class="comment">// Initializes the solver and enters the problem to be solved.</span></div><div class="line"><a name="l00582"></a><span class="lineno"> 582</span>&#160; <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_base_knapsack_solver.html#abb1c2efb23ee210447502a9baab0812a">Init</a>(<span class="keyword">const</span> std::vector&lt;int64_t&gt;&amp; profits,</div><div class="line"><a name="l00583"></a><span class="lineno"> 583</span>&#160; <span class="keyword">const</span> std::vector&lt;std::vector&lt;int64_t&gt; &gt;&amp; weights,</div><div class="line"><a name="l00584"></a><span class="lineno"> 584</span>&#160; <span class="keyword">const</span> std::vector&lt;int64_t&gt;&amp; capacities) = 0;</div><div class="line"><a name="l00585"></a><span class="lineno"> 585</span>&#160;</div><div class="line"><a name="l00586"></a><span class="lineno"> 586</span>&#160; <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="l00587"></a><span class="lineno"> 587</span>&#160; <span class="comment">// To ensure objects are correctly initialized, this method should not be</span></div><div class="line"><a name="l00588"></a><span class="lineno"> 588</span>&#160; <span class="comment">// called before ::Init.</span></div><div class="line"><a name="l00589"></a><span class="lineno"> 589</span>&#160; <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_base_knapsack_solver.html#a4b0049f92bd893d89f1c03ec066d72af">GetLowerAndUpperBoundWhenItem</a>(<span class="keywordtype">int</span> item_id, <span class="keywordtype">bool</span> is_item_in,</div><div class="line"><a name="l00590"></a><span class="lineno"> 590</span>&#160; int64_t* <a class="code" href="gscip__solver_8cc.html#a1e2f9a2352c1d9a6cada9544898fceec">lower_bound</a>,</div><div class="line"><a name="l00591"></a><span class="lineno"> 591</span>&#160; int64_t* <a class="code" href="gscip__solver_8cc.html#a1ba5ca0f61f2fa13bd23bf0f89004f35">upper_bound</a>);</div><div class="line"><a name="l00592"></a><span class="lineno"> 592</span>&#160;</div><div class="line"><a name="l00593"></a><span class="lineno"> 593</span>&#160; <span class="comment">// Solves the problem and returns the profit of the optimal solution.</span></div><div class="line"><a name="l00594"></a><span class="lineno"> 594</span>&#160; <span class="keyword">virtual</span> int64_t <a class="code" href="classoperations__research_1_1_base_knapsack_solver.html#aae09d1be6e3ce3d746c833f7da003de9">Solve</a>(<a class="code" href="classoperations__research_1_1_time_limit.html">TimeLimit</a>* <a class="code" href="cp__model__solver_8cc.html#aec8af5c1be4e1b6d4330e1161028de21">time_limit</a>, <span class="keywordtype">bool</span>* is_solution_optimal) = 0;</div><div class="line"><a name="l00595"></a><span class="lineno"> 595</span>&#160;</div><div class="line"><a name="l00596"></a><span class="lineno"> 596</span>&#160; <span class="comment">// Returns true if the item &#39;item_id&#39; is packed in the optimal knapsack.</span></div><div class="line"><a name="l00597"></a><span class="lineno"> 597</span>&#160; <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_base_knapsack_solver.html#af75968e8e76e35de6e7cdfaa0488b131">best_solution</a>(<span class="keywordtype">int</span> item_id) <span class="keyword">const</span> = 0;</div><div class="line"><a name="l00598"></a><span class="lineno"> 598</span>&#160;</div><div class="line"><a name="l00599"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_base_knapsack_solver.html#ae194e7bee4a383e5ee6c8ed341b49b7e"> 599</a></span>&#160; <span class="keyword">virtual</span> std::string <a class="code" href="classoperations__research_1_1_base_knapsack_solver.html#ae194e7bee4a383e5ee6c8ed341b49b7e">GetName</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> solver_name_; }</div><div class="line"><a name="l00600"></a><span class="lineno"> 600</span>&#160;</div><div class="line"><a name="l00601"></a><span class="lineno"> 601</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00602"></a><span class="lineno"> 602</span>&#160; <span class="keyword">const</span> std::string solver_name_;</div><div class="line"><a name="l00603"></a><span class="lineno"> 603</span>&#160;};</div><div class="line"><a name="l00604"></a><span class="lineno"> 604</span>&#160;</div><div class="line"><a name="l00605"></a><span class="lineno"> 605</span>&#160;<span class="comment">// ----- KnapsackGenericSolver -----</span></div><div class="line"><a name="l00606"></a><span class="lineno"> 606</span>&#160;<span class="comment">// KnapsackGenericSolver is the multi-dimensional knapsack solver class.</span></div><div class="line"><a name="l00607"></a><span class="lineno"> 607</span>&#160;<span class="comment">// In the current implementation, the next item to assign is given by the</span></div><div class="line"><a name="l00608"></a><span class="lineno"> 608</span>&#160;<span class="comment">// master propagator. Using SetMasterPropagator allows changing the default</span></div><div class="line"><a name="l00609"></a><span class="lineno"> 609</span>&#160;<span class="comment">// (propagator of the first dimension), and selecting another dimension when</span></div><div class="line"><a name="l00610"></a><span class="lineno"> 610</span>&#160;<span class="comment">// more constrained.</span></div><div class="line"><a name="l00611"></a><span class="lineno"> 611</span>&#160;<span class="comment">// TODO(user): In the case of a multi-dimensional knapsack problem, implement</span></div><div class="line"><a name="l00612"></a><span class="lineno"> 612</span>&#160;<span class="comment">// an aggregated propagator to combine all dimensions and give a better guide</span></div><div class="line"><a name="l00613"></a><span class="lineno"> 613</span>&#160;<span class="comment">// to select the next item (see, for instance, Dobson&#39;s aggregated efficiency).</span></div><div class="line"><a name="l00614"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_generic_solver.html"> 614</a></span>&#160;<span class="keyword">class </span><a class="code" href="classoperations__research_1_1_knapsack_generic_solver.html">KnapsackGenericSolver</a> : <span class="keyword">public</span> <a class="code" href="classoperations__research_1_1_base_knapsack_solver.html">BaseKnapsackSolver</a> {</div><div class="line"><a name="l00615"></a><span class="lineno"> 615</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00616"></a><span class="lineno"> 616</span>&#160; <span class="keyword">explicit</span> <a class="code" href="classoperations__research_1_1_knapsack_generic_solver.html#a2a7bff5cf8a51192eadec54eb0499064">KnapsackGenericSolver</a>(<span class="keyword">const</span> std::string&amp; solver_name);</div><div class="line"><a name="l00617"></a><span class="lineno"> 617</span>&#160; <a class="code" href="classoperations__research_1_1_knapsack_generic_solver.html#a2a25594d97a0a532f9d814bdc6dea380">~KnapsackGenericSolver</a>() <span class="keyword">override</span>;</div><div class="line"><a name="l00618"></a><span class="lineno"> 618</span>&#160;</div><div class="line"><a name="l00619"></a><span class="lineno"> 619</span>&#160; <span class="comment">// Initializes the solver and enters the problem to be solved.</span></div><div class="line"><a name="l00620"></a><span class="lineno"> 620</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_generic_solver.html#a734b6464309adbbdeb63ef759f690ff1">Init</a>(<span class="keyword">const</span> std::vector&lt;int64_t&gt;&amp; profits,</div><div class="line"><a name="l00621"></a><span class="lineno"> 621</span>&#160; <span class="keyword">const</span> std::vector&lt;std::vector&lt;int64_t&gt; &gt;&amp; weights,</div><div class="line"><a name="l00622"></a><span class="lineno"> 622</span>&#160; <span class="keyword">const</span> std::vector&lt;int64_t&gt;&amp; capacities) <span class="keyword">override</span>;</div><div class="line"><a name="l00623"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_generic_solver.html#a5c677592ee5e7312c64475ebae949eab"> 623</a></span>&#160; <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1_knapsack_generic_solver.html#a5c677592ee5e7312c64475ebae949eab">GetNumberOfItems</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> state_.<a class="code" href="classoperations__research_1_1_knapsack_state.html#a5c677592ee5e7312c64475ebae949eab">GetNumberOfItems</a>(); }</div><div class="line"><a name="l00624"></a><span class="lineno"> 624</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_generic_solver.html#ac9849a7043959c65033fa6f4a63bb10e">GetLowerAndUpperBoundWhenItem</a>(<span class="keywordtype">int</span> item_id, <span class="keywordtype">bool</span> is_item_in,</div><div class="line"><a name="l00625"></a><span class="lineno"> 625</span>&#160; int64_t* <a class="code" href="gscip__solver_8cc.html#a1e2f9a2352c1d9a6cada9544898fceec">lower_bound</a>,</div><div class="line"><a name="l00626"></a><span class="lineno"> 626</span>&#160; int64_t* <a class="code" href="gscip__solver_8cc.html#a1ba5ca0f61f2fa13bd23bf0f89004f35">upper_bound</a>) <span class="keyword">override</span>;</div><div class="line"><a name="l00627"></a><span class="lineno"> 627</span>&#160;</div><div class="line"><a name="l00628"></a><span class="lineno"> 628</span>&#160; <span class="comment">// Sets which propagator should be used to guide the search.</span></div><div class="line"><a name="l00629"></a><span class="lineno"> 629</span>&#160; <span class="comment">// &#39;master_propagator_id&#39; should be in 0..p-1 with p the number of</span></div><div class="line"><a name="l00630"></a><span class="lineno"> 630</span>&#160; <span class="comment">// propagators.</span></div><div class="line"><a name="l00631"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_generic_solver.html#a3df2fc3d96fbcac78a632d7dbf3b8550"> 631</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_knapsack_generic_solver.html#a3df2fc3d96fbcac78a632d7dbf3b8550">set_master_propagator_id</a>(<span class="keywordtype">int</span> master_propagator_id) {</div><div class="line"><a name="l00632"></a><span class="lineno"> 632</span>&#160; master_propagator_id_ = master_propagator_id;</div><div class="line"><a name="l00633"></a><span class="lineno"> 633</span>&#160; }</div><div class="line"><a name="l00634"></a><span class="lineno"> 634</span>&#160;</div><div class="line"><a name="l00635"></a><span class="lineno"> 635</span>&#160; <span class="comment">// Solves the problem and returns the profit of the optimal solution.</span></div><div class="line"><a name="l00636"></a><span class="lineno"> 636</span>&#160; int64_t <a class="code" href="classoperations__research_1_1_knapsack_generic_solver.html#a788a597dac89a082d3ed4994d654dec1">Solve</a>(<a class="code" href="classoperations__research_1_1_time_limit.html">TimeLimit</a>* <a class="code" href="cp__model__solver_8cc.html#aec8af5c1be4e1b6d4330e1161028de21">time_limit</a>, <span class="keywordtype">bool</span>* is_solution_optimal) <span class="keyword">override</span>;</div><div class="line"><a name="l00637"></a><span class="lineno"> 637</span>&#160; <span class="comment">// Returns true if the item &#39;item_id&#39; is packed in the optimal knapsack.</span></div><div class="line"><a name="l00638"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_knapsack_generic_solver.html#abfd4cb3faa2f1d6840b8123765fa2fc4"> 638</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_knapsack_generic_solver.html#abfd4cb3faa2f1d6840b8123765fa2fc4">best_solution</a>(<span class="keywordtype">int</span> item_id)<span class="keyword"> const override </span>{</div><div class="line"><a name="l00639"></a><span class="lineno"> 639</span>&#160; <span class="keywordflow">return</span> best_solution_.at(item_id);</div><div class="line"><a name="l00640"></a><span class="lineno"> 640</span>&#160; }</div><div class="line"><a name="l00641"></a><span class="lineno"> 641</span>&#160;</div><div class="line"><a name="l00642"></a><span class="lineno"> 642</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00643"></a><span class="lineno"> 643</span>&#160; <span class="comment">// Clears internal data structure.</span></div><div class="line"><a name="l00644"></a><span class="lineno"> 644</span>&#160; <span class="keywordtype">void</span> Clear();</div><div class="line"><a name="l00645"></a><span class="lineno"> 645</span>&#160;</div><div class="line"><a name="l00646"></a><span class="lineno"> 646</span>&#160; <span class="comment">// Updates all propagators reverting/applying all decision on the path.</span></div><div class="line"><a name="l00647"></a><span class="lineno"> 647</span>&#160; <span class="comment">// Returns true if fails. Note that, even if fails, all propagators should</span></div><div class="line"><a name="l00648"></a><span class="lineno"> 648</span>&#160; <span class="comment">// be updated to be in a stable state in order to stay incremental.</span></div><div class="line"><a name="l00649"></a><span class="lineno"> 649</span>&#160; <span class="keywordtype">bool</span> UpdatePropagators(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_path.html">KnapsackSearchPath</a>&amp; path);</div><div class="line"><a name="l00650"></a><span class="lineno"> 650</span>&#160; <span class="comment">// Updates all propagators reverting/applying one decision.</span></div><div class="line"><a name="l00651"></a><span class="lineno"> 651</span>&#160; <span class="comment">// Return true if fails. Note that, even if fails, all propagators should</span></div><div class="line"><a name="l00652"></a><span class="lineno"> 652</span>&#160; <span class="comment">// be updated to be in a stable state in order to stay incremental.</span></div><div class="line"><a name="l00653"></a><span class="lineno"> 653</span>&#160; <span class="keywordtype">bool</span> IncrementalUpdate(<span class="keywordtype">bool</span> revert, <span class="keyword">const</span> <a class="code" href="structoperations__research_1_1_knapsack_assignment.html">KnapsackAssignment</a>&amp; assignment);</div><div class="line"><a name="l00654"></a><span class="lineno"> 654</span>&#160; <span class="comment">// Updates the best solution if the current solution has a better profit.</span></div><div class="line"><a name="l00655"></a><span class="lineno"> 655</span>&#160; <span class="keywordtype">void</span> UpdateBestSolution();</div><div class="line"><a name="l00656"></a><span class="lineno"> 656</span>&#160;</div><div class="line"><a name="l00657"></a><span class="lineno"> 657</span>&#160; <span class="comment">// Returns true if new relevant search node was added to the nodes array, that</span></div><div class="line"><a name="l00658"></a><span class="lineno"> 658</span>&#160; <span class="comment">// means this node should be added to the search queue too.</span></div><div class="line"><a name="l00659"></a><span class="lineno"> 659</span>&#160; <span class="keywordtype">bool</span> MakeNewNode(<span class="keyword">const</span> <a class="code" href="classoperations__research_1_1_knapsack_search_node.html">KnapsackSearchNode</a>&amp; node, <span class="keywordtype">bool</span> is_in);</div><div class="line"><a name="l00660"></a><span class="lineno"> 660</span>&#160;</div><div class="line"><a name="l00661"></a><span class="lineno"> 661</span>&#160; <span class="comment">// Gets the aggregated (min) profit upper bound among all propagators.</span></div><div class="line"><a name="l00662"></a><span class="lineno"> 662</span>&#160; int64_t GetAggregatedProfitUpperBound() <span class="keyword">const</span>;</div><div class="line"><a name="l00663"></a><span class="lineno"> 663</span>&#160; <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="l00664"></a><span class="lineno"> 664</span>&#160; int64_t GetCurrentProfit()<span class="keyword"> const </span>{</div><div class="line"><a name="l00665"></a><span class="lineno"> 665</span>&#160; <span class="keywordflow">return</span> propagators_.at(master_propagator_id_)-&gt;current_profit();</div><div class="line"><a name="l00666"></a><span class="lineno"> 666</span>&#160; }</div><div class="line"><a name="l00667"></a><span class="lineno"> 667</span>&#160; int64_t GetNextItemId()<span class="keyword"> const </span>{</div><div class="line"><a name="l00668"></a><span class="lineno"> 668</span>&#160; <span class="keywordflow">return</span> propagators_.at(master_propagator_id_)-&gt;GetNextItemId();</div><div class="line"><a name="l00669"></a><span class="lineno"> 669</span>&#160; }</div><div class="line"><a name="l00670"></a><span class="lineno"> 670</span>&#160;</div><div class="line"><a name="l00671"></a><span class="lineno"> 671</span>&#160; std::vector&lt;KnapsackPropagator*&gt; propagators_;</div><div class="line"><a name="l00672"></a><span class="lineno"> 672</span>&#160; <span class="keywordtype">int</span> master_propagator_id_;</div><div class="line"><a name="l00673"></a><span class="lineno"> 673</span>&#160; std::vector&lt;KnapsackSearchNode*&gt; search_nodes_;</div><div class="line"><a name="l00674"></a><span class="lineno"> 674</span>&#160; KnapsackState state_;</div><div class="line"><a name="l00675"></a><span class="lineno"> 675</span>&#160; int64_t best_solution_profit_;</div><div class="line"><a name="l00676"></a><span class="lineno"> 676</span>&#160; std::vector&lt;bool&gt; best_solution_;</div><div class="line"><a name="l00677"></a><span class="lineno"> 677</span>&#160;</div><div class="line"><a name="l00678"></a><span class="lineno"> 678</span>&#160; DISALLOW_COPY_AND_ASSIGN(<a class="code" href="classoperations__research_1_1_knapsack_generic_solver.html#a2a7bff5cf8a51192eadec54eb0499064">KnapsackGenericSolver</a>);</div><div class="line"><a name="l00679"></a><span class="lineno"> 679</span>&#160;};</div><div class="line"><a name="l00680"></a><span class="lineno"> 680</span>&#160;<span class="preprocessor">#endif // SWIG</span></div><div class="line"><a name="l00681"></a><span class="lineno"> 681</span>&#160;} <span class="comment">// namespace operations_research</span></div><div class="line"><a name="l00682"></a><span class="lineno"> 682</span>&#160;</div><div class="line"><a name="l00683"></a><span class="lineno"> 683</span>&#160;<span class="preprocessor">#endif // OR_TOOLS_ALGORITHMS_KNAPSACK_SOLVER_H_</span></div><div class="ttc" id="classoperations__research_1_1_knapsack_search_node_html_aa68069fd1180cb37fcdbc99d6230bc3e"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_node.html#aa68069fd1180cb37fcdbc99d6230bc3e">operations_research::KnapsackSearchNode::profit_upper_bound</a></div><div class="ttdeci">int64_t profit_upper_bound() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00350">knapsack_solver.h:350</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_a1fa45af1bf0d6aa9d5f86e2ed9ae5323"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#a1fa45af1bf0d6aa9d5f86e2ed9ae5323">operations_research::KnapsackPropagator::CopyCurrentStateToSolution</a></div><div class="ttdeci">void CopyCurrentStateToSolution(bool has_one_propagator, std::vector&lt; bool &gt; *solution) const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00198">knapsack_solver.cc:198</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_node_html_afe9938cf4bbeb06ed8985c37646433fd"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_node.html#afe9938cf4bbeb06ed8985c37646433fd">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#l00344">knapsack_solver.h:344</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_state_html_a89aa280d2321c1316aa1305106f1bb49"><div class="ttname"><a href="classoperations__research_1_1_knapsack_state.html#a89aa280d2321c1316aa1305106f1bb49">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#l00426">knapsack_solver.h:426</a></div></div>
<div class="ttc" id="classoperations__research_1_1_time_limit_html"><div class="ttname"><a href="classoperations__research_1_1_time_limit.html">operations_research::TimeLimit</a></div><div class="ttdoc">A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...</div><div class="ttdef"><b>Definition:</b> <a href="time__limit_8h_source.html#l00106">time_limit.h:106</a></div></div>
<div class="ttc" id="structoperations__research_1_1_knapsack_item_html_aefc8a61c2edd00c4daf37056b754e6a0"><div class="ttname"><a href="structoperations__research_1_1_knapsack_item.html#aefc8a61c2edd00c4daf37056b754e6a0">operations_research::KnapsackItem::KnapsackItem</a></div><div class="ttdeci">KnapsackItem(int _id, int64_t _weight, int64_t _profit)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00315">knapsack_solver.h:315</a></div></div>
<div class="ttc" id="structoperations__research_1_1_knapsack_item_html_a64ae40793ade89d800a8c5646d2980fc"><div class="ttname"><a href="structoperations__research_1_1_knapsack_item.html#a64ae40793ade89d800a8c5646d2980fc">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#l00325">knapsack_solver.h:325</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_ae29226a5be6204e26f1d563a6630ab9e"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#ae29226a5be6204e26f1d563a6630ab9e">operations_research::KnapsackPropagator::set_profit_lower_bound</a></div><div class="ttdeci">void set_profit_lower_bound(int64_t profit)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00501">knapsack_solver.h:501</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_capacity_propagator_html_aa14e63156675c18c06073ac1cb8aa170"><div class="ttname"><a href="classoperations__research_1_1_knapsack_capacity_propagator.html#aa14e63156675c18c06073ac1cb8aa170">operations_research::KnapsackCapacityPropagator::~KnapsackCapacityPropagator</a></div><div class="ttdeci">~KnapsackCapacityPropagator() override</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00220">knapsack_solver.cc:220</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_ae5982edf1a2974495d20201775a765e2"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#ae5982edf1a2974495d20201775a765e2">operations_research::KnapsackSolver::Init</a></div><div class="ttdeci">void Init(const std::vector&lt; int64_t &gt; &amp;profits, const std::vector&lt; std::vector&lt; int64_t &gt; &gt; &amp;weights, const std::vector&lt; int64_t &gt; &amp;capacities)</div><div class="ttdoc">Initializes the solver and enters the problem to be solved.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l01320">knapsack_solver.cc:1320</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_a8b06041d7c1fb05f379714f4312306ec"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ec">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#l00124">knapsack_solver.h:124</a></div></div>
<div class="ttc" id="structoperations__research_1_1_knapsack_assignment_html_a922620900c7a18d22de686d47e25d4ed"><div class="ttname"><a href="structoperations__research_1_1_knapsack_assignment.html#a922620900c7a18d22de686d47e25d4ed">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#l00299">knapsack_solver.h:299</a></div></div>
<div class="ttc" id="cp__model__solver_8cc_html_aec8af5c1be4e1b6d4330e1161028de21"><div class="ttname"><a href="cp__model__solver_8cc.html#aec8af5c1be4e1b6d4330e1161028de21">time_limit</a></div><div class="ttdeci">ModelSharedTimeLimit * time_limit</div><div class="ttdef"><b>Definition:</b> <a href="cp__model__solver_8cc_source.html#l01951">cp_model_solver.cc:1951</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_af28391017c090a638200c57b4c8a2ac1"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#af28391017c090a638200c57b4c8a2ac1">operations_research::KnapsackPropagator::KnapsackPropagator</a></div><div class="ttdeci">KnapsackPropagator(const KnapsackState &amp;state)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00164">knapsack_solver.cc:164</a></div></div>
<div class="ttc" id="classoperations__research_1_1_base_knapsack_solver_html_abb1c2efb23ee210447502a9baab0812a"><div class="ttname"><a href="classoperations__research_1_1_base_knapsack_solver.html#abb1c2efb23ee210447502a9baab0812a">operations_research::BaseKnapsackSolver::Init</a></div><div class="ttdeci">virtual void Init(const std::vector&lt; int64_t &gt; &amp;profits, const std::vector&lt; std::vector&lt; int64_t &gt; &gt; &amp;weights, const std::vector&lt; int64_t &gt; &amp;capacities)=0</div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_path_html_a1e3b6d38df0786ccf7f938d60e386aae"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_path.html#a1e3b6d38df0786ccf7f938d60e386aae">operations_research::KnapsackSearchPath::Init</a></div><div class="ttdeci">void Init()</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00117">knapsack_solver.cc:117</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_node_html_a48521e7b1a381bd3f3f452fa6e697bde"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_node.html#a48521e7b1a381bd3f3f452fa6e697bde">operations_research::KnapsackSearchNode::set_current_profit</a></div><div class="ttdeci">void set_current_profit(int64_t profit)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00348">knapsack_solver.h:348</a></div></div>
<div class="ttc" id="time__limit_8h_html"><div class="ttname"><a href="time__limit_8h.html">time_limit.h</a></div></div>
<div class="ttc" id="namespaceoperations__research_html_ada7d9b46f657c6053a197273a85043a7"><div class="ttname"><a href="namespaceoperations__research.html#ada7d9b46f657c6053a197273a85043a7">operations_research::KnapsackItemPtr</a></div><div class="ttdeci">KnapsackItem * KnapsackItemPtr</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_1_knapsack_state_html_a41f9430cc0090383e7797a88c1dbacbc"><div class="ttname"><a href="classoperations__research_1_1_knapsack_state.html#a41f9430cc0090383e7797a88c1dbacbc">operations_research::KnapsackState::KnapsackState</a></div><div class="ttdeci">KnapsackState()</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00140">knapsack_solver.cc:140</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_a7f5467b49f2cba3d8804e44ed76e12a2"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a7f5467b49f2cba3d8804e44ed76e12a2">operations_research::KnapsackSolver::Solve</a></div><div class="ttdeci">int64_t Solve()</div><div class="ttdoc">Solves the problem and returns the profit of the optimal solution.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l01504">knapsack_solver.cc:1504</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.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#l00117">knapsack_solver.h:117</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_a57d88f584d14b161580550918c8fbf3b"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a57d88f584d14b161580550918c8fbf3b">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 class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l01511">knapsack_solver.cc:1511</a></div></div>
<div class="ttc" id="classoperations__research_1_1_base_knapsack_solver_html_aae09d1be6e3ce3d746c833f7da003de9"><div class="ttname"><a href="classoperations__research_1_1_base_knapsack_solver.html#aae09d1be6e3ce3d746c833f7da003de9">operations_research::BaseKnapsackSolver::Solve</a></div><div class="ttdeci">virtual int64_t Solve(TimeLimit *time_limit, bool *is_solution_optimal)=0</div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_state_html_a6308c7a97200f84f6ebf5b2c487b0362"><div class="ttname"><a href="classoperations__research_1_1_knapsack_state.html#a6308c7a97200f84f6ebf5b2c487b0362">operations_research::KnapsackState::Init</a></div><div class="ttdeci">void Init(int number_of_items)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00142">knapsack_solver.cc:142</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_a8b06041d7c1fb05f379714f4312306eca793d998526508cfcc2bfc89fe25b3edd"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306eca793d998526508cfcc2bfc89fe25b3edd">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#l00147">knapsack_solver.h:147</a></div></div>
<div class="ttc" id="classoperations__research_1_1_base_knapsack_solver_html_a4b0049f92bd893d89f1c03ec066d72af"><div class="ttname"><a href="classoperations__research_1_1_base_knapsack_solver.html#a4b0049f92bd893d89f1c03ec066d72af">operations_research::BaseKnapsackSolver::GetLowerAndUpperBoundWhenItem</a></div><div class="ttdeci">virtual void GetLowerAndUpperBoundWhenItem(int item_id, bool is_item_in, int64_t *lower_bound, int64_t *upper_bound)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l01522">knapsack_solver.cc:1522</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_a8b06041d7c1fb05f379714f4312306eca2a4e77eec4f386d17001e7285e812a0b"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306eca2a4e77eec4f386d17001e7285e812a0b">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#l00163">knapsack_solver.h:163</a></div></div>
<div class="ttc" id="integral__types_8h_html"><div class="ttname"><a href="integral__types_8h.html">integral_types.h</a></div></div>
<div class="ttc" id="macros_8h_html"><div class="ttname"><a href="macros_8h.html">macros.h</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_node_html_a08beea2d857241d99287935a91be5217"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_node.html#a08beea2d857241d99287935a91be5217">operations_research::KnapsackSearchNode::current_profit</a></div><div class="ttdeci">int64_t current_profit() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00347">knapsack_solver.h:347</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_path_html"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_path.html">operations_research::KnapsackSearchPath</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_1_knapsack_propagator_html_aa68069fd1180cb37fcdbc99d6230bc3e"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#aa68069fd1180cb37fcdbc99d6230bc3e">operations_research::KnapsackPropagator::profit_upper_bound</a></div><div class="ttdeci">int64_t profit_upper_bound() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00469">knapsack_solver.h:469</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_generic_solver_html_a2a25594d97a0a532f9d814bdc6dea380"><div class="ttname"><a href="classoperations__research_1_1_knapsack_generic_solver.html#a2a25594d97a0a532f9d814bdc6dea380">operations_research::KnapsackGenericSolver::~KnapsackGenericSolver</a></div><div class="ttdeci">~KnapsackGenericSolver() override</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00348">knapsack_solver.cc:348</a></div></div>
<div class="ttc" id="gscip__solver_8cc_html_a1ba5ca0f61f2fa13bd23bf0f89004f35"><div class="ttname"><a href="gscip__solver_8cc.html#a1ba5ca0f61f2fa13bd23bf0f89004f35">upper_bound</a></div><div class="ttdeci">double upper_bound</div><div class="ttdef"><b>Definition:</b> <a href="gscip__solver_8cc_source.html#l00126">gscip_solver.cc:126</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_node_html_a9962698a737cd21789c77ff32bef0d98"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_node.html#a9962698a737cd21789c77ff32bef0d98">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#l00354">knapsack_solver.h:354</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_ab803770e8e21bb448a2f3d940ab125f8"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#ab803770e8e21bb448a2f3d940ab125f8">operations_research::KnapsackPropagator::CopyCurrentStateToSolutionPropagator</a></div><div class="ttdeci">virtual void CopyCurrentStateToSolutionPropagator(std::vector&lt; bool &gt; *solution) const =0</div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_generic_solver_html_a5c677592ee5e7312c64475ebae949eab"><div class="ttname"><a href="classoperations__research_1_1_knapsack_generic_solver.html#a5c677592ee5e7312c64475ebae949eab">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#l00623">knapsack_solver.h:623</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_a6b46c35c8977efde66ae7ad97423bdf2"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a6b46c35c8977efde66ae7ad97423bdf2">operations_research::KnapsackSolver::KnapsackSolver</a></div><div class="ttdeci">KnapsackSolver(const std::string &amp;solver_name)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l01258">knapsack_solver.cc:1258</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_a8b06041d7c1fb05f379714f4312306ecac43056d6d2f96cee37fcb8a752b0ff45"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ecac43056d6d2f96cee37fcb8a752b0ff45">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#l00131">knapsack_solver.h:131</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_capacity_propagator_html_ae2545020be753ee6a66c277daac41784"><div class="ttname"><a href="classoperations__research_1_1_knapsack_capacity_propagator.html#ae2545020be753ee6a66c277daac41784">operations_research::KnapsackCapacityPropagator::InitPropagator</a></div><div class="ttdeci">void InitPropagator() override</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00255">knapsack_solver.cc:255</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_a8b06041d7c1fb05f379714f4312306eca1f4e1e2f80ab9c7d4fc1b14d9f5da959"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306eca1f4e1e2f80ab9c7d4fc1b14d9f5da959">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#l00171">knapsack_solver.h:171</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_capacity_propagator_html_a9921c39ed90a9cd32301ee0fee9491cb"><div class="ttname"><a href="classoperations__research_1_1_knapsack_capacity_propagator.html#a9921c39ed90a9cd32301ee0fee9491cb">operations_research::KnapsackCapacityPropagator::ComputeProfitBounds</a></div><div class="ttdeci">void ComputeProfitBounds() override</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00224">knapsack_solver.cc:224</a></div></div>
<div class="ttc" id="classoperations__research_1_1_base_knapsack_solver_html_ae194e7bee4a383e5ee6c8ed341b49b7e"><div class="ttname"><a href="classoperations__research_1_1_base_knapsack_solver.html#ae194e7bee4a383e5ee6c8ed341b49b7e">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#l00599">knapsack_solver.h:599</a></div></div>
<div class="ttc" id="gscip__solver_8cc_html_a1e2f9a2352c1d9a6cada9544898fceec"><div class="ttname"><a href="gscip__solver_8cc.html#a1e2f9a2352c1d9a6cada9544898fceec">lower_bound</a></div><div class="ttdeci">double lower_bound</div><div class="ttdef"><b>Definition:</b> <a href="gscip__solver_8cc_source.html#l00125">gscip_solver.cc:125</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_a9647a5f765048e8662e5efa54c7d8687"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a9647a5f765048e8662e5efa54c7d8687">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#l00224">knapsack_solver.h:224</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_generic_solver_html_a2a7bff5cf8a51192eadec54eb0499064"><div class="ttname"><a href="classoperations__research_1_1_knapsack_generic_solver.html#a2a7bff5cf8a51192eadec54eb0499064">operations_research::KnapsackGenericSolver::KnapsackGenericSolver</a></div><div class="ttdeci">KnapsackGenericSolver(const std::string &amp;solver_name)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00339">knapsack_solver.cc:339</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_generic_solver_html_abfd4cb3faa2f1d6840b8123765fa2fc4"><div class="ttname"><a href="classoperations__research_1_1_knapsack_generic_solver.html#abfd4cb3faa2f1d6840b8123765fa2fc4">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#l00638">knapsack_solver.h:638</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_generic_solver_html_ac9849a7043959c65033fa6f4a63bb10e"><div class="ttname"><a href="classoperations__research_1_1_knapsack_generic_solver.html#ac9849a7043959c65033fa6f4a63bb10e">operations_research::KnapsackGenericSolver::GetLowerAndUpperBoundWhenItem</a></div><div class="ttdeci">void GetLowerAndUpperBoundWhenItem(int item_id, bool is_item_in, int64_t *lower_bound, int64_t *upper_bound) override</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00372">knapsack_solver.cc:372</a></div></div>
<div class="ttc" id="structoperations__research_1_1_knapsack_item_html_a7eb6bbc72ec605de6f50d0c90f609a85"><div class="ttname"><a href="structoperations__research_1_1_knapsack_item.html#a7eb6bbc72ec605de6f50d0c90f609a85">operations_research::KnapsackItem::GetEfficiency</a></div><div class="ttdeci">double GetEfficiency(int64_t profit_max) const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00317">knapsack_solver.h:317</a></div></div>
<div class="ttc" id="routing__flow_8cc_html_a2acb49f4df5288066c43610bede123ec"><div class="ttname"><a href="routing__flow_8cc.html#a2acb49f4df5288066c43610bede123ec">capacity</a></div><div class="ttdeci">int64_t capacity</div><div class="ttdef"><b>Definition:</b> <a href="routing__flow_8cc_source.html#l00151">routing_flow.cc:151</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_af4b38123d3654471f0868774c5ff877d"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#af4b38123d3654471f0868774c5ff877d">operations_research::KnapsackPropagator::Update</a></div><div class="ttdeci">bool Update(bool revert, const KnapsackAssignment &amp;assignment)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00186">knapsack_solver.cc:186</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_node_html"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_node.html">operations_research::KnapsackSearchNode</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00339">knapsack_solver.h:339</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_node_html_af991b29f273c53c8b35cb09bcccf3a5d"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_node.html#af991b29f273c53c8b35cb09bcccf3a5d">operations_research::KnapsackSearchNode::set_profit_upper_bound</a></div><div class="ttdeci">void set_profit_upper_bound(int64_t profit)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00351">knapsack_solver.h:351</a></div></div>
<div class="ttc" id="classoperations__research_1_1_base_knapsack_solver_html_af75968e8e76e35de6e7cdfaa0488b131"><div class="ttname"><a href="classoperations__research_1_1_base_knapsack_solver.html#af75968e8e76e35de6e7cdfaa0488b131">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_1_knapsack_solver_html_a6b4f6cbb00a64b0e9745938f9b99d0c8"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a6b4f6cbb00a64b0e9745938f9b99d0c8">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#l00235">knapsack_solver.h:235</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_state_html"><div class="ttname"><a href="classoperations__research_1_1_knapsack_state.html">operations_research::KnapsackState</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00414">knapsack_solver.h:414</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_a883cd053b1e7322727eb9e19940f69f6"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#a883cd053b1e7322727eb9e19940f69f6">operations_research::KnapsackPropagator::InitPropagator</a></div><div class="ttdeci">virtual void InitPropagator()=0</div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_generic_solver_html"><div class="ttname"><a href="classoperations__research_1_1_knapsack_generic_solver.html">operations_research::KnapsackGenericSolver</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00614">knapsack_solver.h:614</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_path_html_a1dcc659f782497ac856c5223c0819713"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_path.html#a1dcc659f782497ac856c5223c0819713">operations_research::KnapsackSearchPath::via</a></div><div class="ttdeci">const KnapsackSearchNode &amp; via() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00399">knapsack_solver.h:399</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_node_html_ad17e46a2afcf393a4ec9159162c969f2"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_node.html#ad17e46a2afcf393a4ec9159162c969f2">operations_research::KnapsackSearchNode::KnapsackSearchNode</a></div><div class="ttdeci">KnapsackSearchNode(const KnapsackSearchNode *const parent, const KnapsackAssignment &amp;assignment)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00103">knapsack_solver.cc:103</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_af15d878d664ee8a07cf3b710f8047cba"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#af15d878d664ee8a07cf3b710f8047cba">operations_research::KnapsackPropagator::~KnapsackPropagator</a></div><div class="ttdeci">virtual ~KnapsackPropagator()</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00171">knapsack_solver.cc:171</a></div></div>
<div class="ttc" id="structoperations__research_1_1_knapsack_assignment_html_a1c0c3c835f3c4363b650fba65c7ebf32"><div class="ttname"><a href="structoperations__research_1_1_knapsack_assignment.html#a1c0c3c835f3c4363b650fba65c7ebf32">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#l00298">knapsack_solver.h:298</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_a9b748c5fb5e1da5da53026ffb91db51f"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#a9b748c5fb5e1da5da53026ffb91db51f">operations_research::KnapsackPropagator::state</a></div><div class="ttdeci">const KnapsackState &amp; state() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00498">knapsack_solver.h:498</a></div></div>
<div class="ttc" id="base_2logging_8h_html"><div class="ttname"><a href="base_2logging_8h.html">logging.h</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_abb19dddb08cf912baec8995cfd2f1f42"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#abb19dddb08cf912baec8995cfd2f1f42">operations_research::KnapsackSolver::~KnapsackSolver</a></div><div class="ttdeci">virtual ~KnapsackSolver()</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l01318">knapsack_solver.cc:1318</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_af991b29f273c53c8b35cb09bcccf3a5d"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#af991b29f273c53c8b35cb09bcccf3a5d">operations_research::KnapsackPropagator::set_profit_upper_bound</a></div><div class="ttdeci">void set_profit_upper_bound(int64_t profit)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00502">knapsack_solver.h:502</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_generic_solver_html_a734b6464309adbbdeb63ef759f690ff1"><div class="ttname"><a href="classoperations__research_1_1_knapsack_generic_solver.html#a734b6464309adbbdeb63ef759f690ff1">operations_research::KnapsackGenericSolver::Init</a></div><div class="ttdeci">void Init(const std::vector&lt; int64_t &gt; &amp;profits, const std::vector&lt; std::vector&lt; int64_t &gt; &gt; &amp;weights, const std::vector&lt; int64_t &gt; &amp;capacities) override</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00350">knapsack_solver.cc:350</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_generic_solver_html_a3df2fc3d96fbcac78a632d7dbf3b8550"><div class="ttname"><a href="classoperations__research_1_1_knapsack_generic_solver.html#a3df2fc3d96fbcac78a632d7dbf3b8550">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#l00631">knapsack_solver.h:631</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_path_html_a3dc3602e1a640bc986956e0ce5e88d04"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_path.html#a3dc3602e1a640bc986956e0ce5e88d04">operations_research::KnapsackSearchPath::KnapsackSearchPath</a></div><div class="ttdeci">KnapsackSearchPath(const KnapsackSearchNode &amp;from, const KnapsackSearchNode &amp;to)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00113">knapsack_solver.cc:113</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_state_html_a5c677592ee5e7312c64475ebae949eab"><div class="ttname"><a href="classoperations__research_1_1_knapsack_state.html#a5c677592ee5e7312c64475ebae949eab">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#l00425">knapsack_solver.h:425</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_a04d8883567a6e02787f2362e6543a21b"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#a04d8883567a6e02787f2362e6543a21b">operations_research::KnapsackPropagator::Init</a></div><div class="ttdeci">void Init(const std::vector&lt; int64_t &gt; &amp;profits, const std::vector&lt; int64_t &gt; &amp;weights)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00173">knapsack_solver.cc:173</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_ae04e419341e0b9772a057aff10ce63a0"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#ae04e419341e0b9772a057aff10ce63a0">operations_research::KnapsackPropagator::profit_lower_bound</a></div><div class="ttdeci">int64_t profit_lower_bound() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00468">knapsack_solver.h:468</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_capacity_propagator_html_afccfe4a5a27c2c805016d82886795da9"><div class="ttname"><a href="classoperations__research_1_1_knapsack_capacity_propagator.html#afccfe4a5a27c2c805016d82886795da9">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#l00539">knapsack_solver.h:539</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_capacity_propagator_html"><div class="ttname"><a href="classoperations__research_1_1_knapsack_capacity_propagator.html">operations_research::KnapsackCapacityPropagator</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00534">knapsack_solver.h:534</a></div></div>
<div class="ttc" id="structoperations__research_1_1_knapsack_item_html_a75dd99d0e31e3a347e5ebad01561e31d"><div class="ttname"><a href="structoperations__research_1_1_knapsack_item.html#a75dd99d0e31e3a347e5ebad01561e31d">operations_research::KnapsackItem::profit</a></div><div class="ttdeci">const int64_t 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_1_base_knapsack_solver_html"><div class="ttname"><a href="classoperations__research_1_1_base_knapsack_solver.html">operations_research::BaseKnapsackSolver</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00575">knapsack_solver.h:575</a></div></div>
<div class="ttc" id="structoperations__research_1_1_knapsack_assignment_html_a8f85eb172a4c6bed0d042f7d269fc457"><div class="ttname"><a href="structoperations__research_1_1_knapsack_assignment.html#a8f85eb172a4c6bed0d042f7d269fc457">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#l00296">knapsack_solver.h:296</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_a5a0d11be6f0d5b521477226fb7573db8"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#a5a0d11be6f0d5b521477226fb7573db8">operations_research::KnapsackPropagator::UpdatePropagator</a></div><div class="ttdeci">virtual bool UpdatePropagator(bool revert, const KnapsackAssignment &amp;assignment)=0</div></div>
<div class="ttc" id="classoperations__research_1_1_base_knapsack_solver_html_ac6518fa5a6dd37173c7700bc2d9b6071"><div class="ttname"><a href="classoperations__research_1_1_base_knapsack_solver.html#ac6518fa5a6dd37173c7700bc2d9b6071">operations_research::BaseKnapsackSolver::BaseKnapsackSolver</a></div><div class="ttdeci">BaseKnapsackSolver(const std::string &amp;solver_name)</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_1_knapsack_search_node_html_a94dca4e57f87ba2a9e3b995c267c0821"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_node.html#a94dca4e57f87ba2a9e3b995c267c0821">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#l00353">knapsack_solver.h:353</a></div></div>
<div class="ttc" id="namespaceoperations__research_html"><div class="ttname"><a href="namespaceoperations__research.html">operations_research</a></div><div class="ttdoc">Collection of objects used to extend the Constraint Solver library.</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="classoperations__research_1_1_knapsack_generic_solver_html_a788a597dac89a082d3ed4994d654dec1"><div class="ttname"><a href="classoperations__research_1_1_knapsack_generic_solver.html#a788a597dac89a082d3ed4994d654dec1">operations_research::KnapsackGenericSolver::Solve</a></div><div class="ttdeci">int64_t Solve(TimeLimit *time_limit, bool *is_solution_optimal) override</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00396">knapsack_solver.cc:396</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_aa4161d4fb0a577a3e854b7f285d7ace6"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#aa4161d4fb0a577a3e854b7f285d7ace6">operations_research::KnapsackPropagator::items</a></div><div class="ttdeci">const std::vector&lt; KnapsackItemPtr &gt; &amp; items() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00499">knapsack_solver.h:499</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_capacity_propagator_html_a2ce43dc07784f3d9634df0a5c0dc39b0"><div class="ttname"><a href="classoperations__research_1_1_knapsack_capacity_propagator.html#a2ce43dc07784f3d9634df0a5c0dc39b0">operations_research::KnapsackCapacityPropagator::KnapsackCapacityPropagator</a></div><div class="ttdeci">KnapsackCapacityPropagator(const KnapsackState &amp;state, int64_t capacity)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00211">knapsack_solver.cc:211</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_ac7d0a3efa2aabe6a3e667b0724f63688"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#ac7d0a3efa2aabe6a3e667b0724f63688">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#l00227">knapsack_solver.h:227</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_capacity_propagator_html_a3cde41b7fa0c9734783a562aadd9ef8c"><div class="ttname"><a href="classoperations__research_1_1_knapsack_capacity_propagator.html#a3cde41b7fa0c9734783a562aadd9ef8c">operations_research::KnapsackCapacityPropagator::UpdatePropagator</a></div><div class="ttdeci">bool UpdatePropagator(bool revert, const KnapsackAssignment &amp;assignment) override</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00269">knapsack_solver.cc:269</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_node_html_a6fdd73f8011695b97659f2bea29325cb"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_node.html#a6fdd73f8011695b97659f2bea29325cb">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#l00343">knapsack_solver.h:343</a></div></div>
<div class="ttc" id="structoperations__research_1_1_knapsack_item_html"><div class="ttname"><a href="structoperations__research_1_1_knapsack_item.html">operations_research::KnapsackItem</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00314">knapsack_solver.h:314</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_a8b06041d7c1fb05f379714f4312306ecae2ce6e36a247621de398e875d5feb575"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ecae2ce6e36a247621de398e875d5feb575">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#l00155">knapsack_solver.h:155</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_a8b06041d7c1fb05f379714f4312306eca9d4c4118c9e4dc258e5052c0a457098d"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306eca9d4c4118c9e4dc258e5052c0a457098d">operations_research::KnapsackSolver::KNAPSACK_DIVIDE_AND_CONQUER_SOLVER</a></div><div class="ttdoc">Divide and Conquer approach for single dimension problems.</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00198">knapsack_solver.h:198</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_path_html_af020a457732b35e71f0bce09433ba4f2"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_path.html#af020a457732b35e71f0bce09433ba4f2">operations_research::KnapsackSearchPath::to</a></div><div class="ttdeci">const KnapsackSearchNode &amp; to() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00400">knapsack_solver.h:400</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_a8ae457a5297bac5ad83517ba54b819d1"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#a8ae457a5297bac5ad83517ba54b819d1">operations_research::KnapsackPropagator::ComputeProfitBounds</a></div><div class="ttdeci">virtual void ComputeProfitBounds()=0</div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_a8b06041d7c1fb05f379714f4312306ecaa020f211a1ff184e712aa4f372d6ea34"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a8b06041d7c1fb05f379714f4312306ecaa020f211a1ff184e712aa4f372d6ea34">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#l00139">knapsack_solver.h:139</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_a08beea2d857241d99287935a91be5217"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#a08beea2d857241d99287935a91be5217">operations_research::KnapsackPropagator::current_profit</a></div><div class="ttdeci">int64_t current_profit() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00467">knapsack_solver.h:467</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html">operations_research::KnapsackPropagator</a></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_1_knapsack_search_path_html_aa4d0c972d711bfb97638280fa646f83d"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_path.html#aa4d0c972d711bfb97638280fa646f83d">operations_research::KnapsackSearchPath::from</a></div><div class="ttdeci">const KnapsackSearchNode &amp; from() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00398">knapsack_solver.h:398</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_capacity_propagator_html_a706a3a7c9568016131afd718f347ec8d"><div class="ttname"><a href="classoperations__research_1_1_knapsack_capacity_propagator.html#a706a3a7c9568016131afd718f347ec8d">operations_research::KnapsackCapacityPropagator::CopyCurrentStateToSolutionPropagator</a></div><div class="ttdeci">void CopyCurrentStateToSolutionPropagator(std::vector&lt; bool &gt; *solution) const override</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00284">knapsack_solver.cc:284</a></div></div>
<div class="ttc" id="structoperations__research_1_1_knapsack_item_html_a523234416a08d890505d4b34fb0513ee"><div class="ttname"><a href="structoperations__research_1_1_knapsack_item.html#a523234416a08d890505d4b34fb0513ee">operations_research::KnapsackItem::weight</a></div><div class="ttdeci">const int64_t weight</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_1_knapsack_solver_html_a9a98946a64f3893b085f650932c9dfee"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#a9a98946a64f3893b085f650932c9dfee">operations_research::KnapsackSolver::GetName</a></div><div class="ttdeci">std::string GetName() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l01519">knapsack_solver.cc:1519</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_state_html_a862bf4e908cd82ea44f72e98558016ad"><div class="ttname"><a href="classoperations__research_1_1_knapsack_state.html#a862bf4e908cd82ea44f72e98558016ad">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#l00427">knapsack_solver.h:427</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_solver_html_aa5b8e0a03c593bfc3cef0ba8d178844f"><div class="ttname"><a href="classoperations__research_1_1_knapsack_solver.html#aa5b8e0a03c593bfc3cef0ba8d178844f">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#l00228">knapsack_solver.h:228</a></div></div>
<div class="ttc" id="basictypes_8h_html"><div class="ttname"><a href="basictypes_8h.html">basictypes.h</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_node_html_afca45ec0f9ea0c2b36804720f5fa8655"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_node.html#afca45ec0f9ea0c2b36804720f5fa8655">operations_research::KnapsackSearchNode::assignment</a></div><div class="ttdeci">const KnapsackAssignment &amp; assignment() const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00345">knapsack_solver.h:345</a></div></div>
<div class="ttc" id="knapsack__solver_8cc_html_a3cb2fc3bc89582cef0819ea753e8a44d"><div class="ttname"><a href="knapsack__solver_8cc.html#a3cb2fc3bc89582cef0819ea753e8a44d">profit_max</a></div><div class="ttdeci">const int64_t profit_max</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00046">knapsack_solver.cc:46</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_propagator_html_a9aea5e61ac71dca1139fda445cc2dfee"><div class="ttname"><a href="classoperations__research_1_1_knapsack_propagator.html#a9aea5e61ac71dca1139fda445cc2dfee">operations_research::KnapsackPropagator::GetNextItemId</a></div><div class="ttdeci">virtual int GetNextItemId() const =0</div></div>
<div class="ttc" id="classoperations__research_1_1_base_knapsack_solver_html_ab5b44517ac32ba76590129831a826096"><div class="ttname"><a href="classoperations__research_1_1_base_knapsack_solver.html#ab5b44517ac32ba76590129831a826096">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#l00579">knapsack_solver.h:579</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_search_path_html_a09f219a2226f7c0de0f50b6f00c099e3"><div class="ttname"><a href="classoperations__research_1_1_knapsack_search_path.html#a09f219a2226f7c0de0f50b6f00c099e3">operations_research::KnapsackSearchPath::MoveUpToDepth</a></div><div class="ttdeci">const KnapsackSearchNode * MoveUpToDepth(const KnapsackSearchNode &amp;node, int depth) const</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00130">knapsack_solver.cc:130</a></div></div>
<div class="ttc" id="classoperations__research_1_1_knapsack_state_html_ab771ac0e538f991b73b011ee3ba11f05"><div class="ttname"><a href="classoperations__research_1_1_knapsack_state.html#ab771ac0e538f991b73b011ee3ba11f05">operations_research::KnapsackState::UpdateState</a></div><div class="ttdeci">bool UpdateState(bool revert, const KnapsackAssignment &amp;assignment)</div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8cc_source.html#l00148">knapsack_solver.cc:148</a></div></div>
<div class="ttc" id="structoperations__research_1_1_knapsack_assignment_html"><div class="ttname"><a href="structoperations__research_1_1_knapsack_assignment.html">operations_research::KnapsackAssignment</a></div><div class="ttdef"><b>Definition:</b> <a href="knapsack__solver_8h_source.html#l00295">knapsack_solver.h:295</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.18-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_a7cc1eeded8f693d0da6c729bc88c45a.html">ortools</a></li><li class="navelem"><a class="el" href="dir_80dda7a75b0dfcf996988638a63eb03a.html">algorithms</a></li><li class="navelem"><a class="el" href="knapsack__solver_8h.html">knapsack_solver.h</a></li>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.15 </li>
</ul>
</div>
</body>
</html>