<ahref="knapsack__solver_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="comment">// Copyright 2010-2018 Google LLC</span></div><divclass="line"><aname="l00002"></a><spanclass="lineno"> 2</span> <spanclass="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div><divclass="line"><aname="l00003"></a><spanclass="lineno"> 3</span> <spanclass="comment">// you may not use this file except in compliance with the License.</span></div><divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment">// You may obtain a copy of the License at</span></div><divclass="line"><aname="l00005"></a><spanclass="lineno"> 5</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00006"></a><spanclass="lineno"> 6</span> <spanclass="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></div><divclass="line"><aname="l00007"></a><spanclass="lineno"> 7</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00008"></a><spanclass="lineno"> 8</span> <spanclass="comment">// Unless required by applicable law or agreed to in writing, software</span></div><divclass="line"><aname="l00009"></a><spanclass="lineno"> 9</span> <spanclass="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div><divclass="line"><aname="l00010"></a><spanclass="lineno"> 10</span> <spanclass="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div><divclass="line"><aname="l00011"></a><spanclass="lineno"> 11</span> <spanclass="comment">// See the License for the specific language governing permissions and</span></div><divclass="line"><aname="l00012"></a><spanclass="lineno"> 12</span> <spanclass="comment">// limitations under the License.</span></div><divclass="line"><aname="l00013"></a><spanclass="lineno"> 13</span> </div><divclass="line"><aname="l00014"></a><spanclass="lineno"> 14</span> <spanclass="preprocessor">#ifndef OR_TOOLS_ALGORITHMS_KNAPSACK_SOLVER_H_</span></div><divclass="line"><aname="l00015"></a><spanclass="lineno"> 15</span> <spanclass="preprocessor">#define OR_TOOLS_ALGORITHMS_KNAPSACK_SOLVER_H_</span></div><divclass="line"><aname="l00016"></a><spanclass="lineno"> 16</span> </div><divclass="line"><aname="l00017"></a><spanclass="lineno"> 17</span> <spanclass="preprocessor">#include <math.h></span></div><divclass="line"><aname="l00018"></a><spanclass="lineno"> 18</span> </div><divclass="line"><aname="l00019"></a><spanclass="lineno"> 19</span> <spanclass="preprocessor">#include <memory></span></div><divclass="line"><aname="l00020"></a><spanclass="lineno"> 20</span> <spanclass="preprocessor">#include <string></span></div><divclass="line"><aname="l00021"></a><spanclass="lineno"> 21</span> <spanclass="preprocessor">#include <vector></span></div><divclass="line"><aname="l00022"></a><spanclass="lineno"> 22</span> </div><divclass="line"><aname="l00023"></a><spanclass="lineno"> 23</span> <spanclass="preprocessor">#include "absl/memory/memory.h"</span></div><divclass="line"><aname="l00024"></a><spanclass="lineno"> 24</span> <spanclass="preprocessor">#include "ortools/base/basictypes.h"</span></div><divclass="line"><aname="l00025"></a><spanclass="lineno"> 25</span> <spanclass="preprocessor">#include "ortools/base/integral_types.h"</span></div><divclass="line"><aname="l00026"></a><spanclass="lineno"> 26</span> <spanclass="preprocessor">#include "ortools/base/logging.h"</span></div><divclass="line"><aname="l00027"></a><spanclass="lineno"> 27</span> <spanclass="preprocessor">#include "ortools/base/macros.h"</span></div><div
<divclass="ttc"id="classoperations__research_1_1KnapsackSolver_html_a96f960b29496f637af7a3eeb10e606ab"><divclass="ttname"><ahref="classoperations__research_1_1KnapsackSolver.html#a96f960b29496f637af7a3eeb10e606ab">operations_research::KnapsackSolver::IsSolutionOptimal</a></div><divclass="ttdeci">bool IsSolutionOptimal() const</div><divclass="ttdoc">Returns true if the solution was proven optimal.</div><divclass="ttdef"><b>Definition:</b><ahref="knapsack__solver_8h_source.html#l00201">knapsack_solver.h:201</a></div></div>
<divclass="ttc"id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893a4d72c45990d1a81e3f5bcdaf6de72096"><divclass="ttname"><ahref="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893a4d72c45990d1a81e3f5bcdaf6de72096">operations_research::KnapsackSolver::KNAPSACK_BRUTE_FORCE_SOLVER</a></div><divclass="ttdoc">Brute force method.</div><divclass="ttdef"><b>Definition:</b><ahref="knapsack__solver_8h_source.html#l00134">knapsack_solver.h:134</a></div></div>
<divclass="ttc"id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893"><divclass="ttname"><ahref="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893">operations_research::KnapsackSolver::SolverType</a></div><divclass="ttdeci">SolverType</div><divclass="ttdoc">Enum controlling which underlying algorithm is used.</div><divclass="ttdef"><b>Definition:</b><ahref="knapsack__solver_8h_source.html#l00127">knapsack_solver.h:127</a></div></div>
<divclass="ttc"id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893ae1b7e0ea856a376a9c04130e0abdf812"><divclass="ttname"><ahref="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893ae1b7e0ea856a376a9c04130e0abdf812">operations_research::KnapsackSolver::KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER</a></div><divclass="ttdoc">CBC Based Solver.</div><divclass="ttdef"><b>Definition:</b><ahref="knapsack__solver_8h_source.html#l00158">knapsack_solver.h:158</a></div></div>
<divclass="ttc"id="classoperations__research_1_1KnapsackSolver_html_ad2a0397c061a1cf0bfc759b35f23e463"><divclass="ttname"><ahref="classoperations__research_1_1KnapsackSolver.html#ad2a0397c061a1cf0bfc759b35f23e463">operations_research::KnapsackSolver::Init</a></div><divclass="ttdeci">void Init(const std::vector< int64 >&profits, const std::vector< std::vector< int64 >>&weights, const std::vector< int64 >&capacities)</div><divclass="ttdoc">Initializes the solver and enters the problem to be solved.</div></div>
<divclass="ttc"id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893a9c02fa29c925bc1d37cba92490998132"><divclass="ttname"><ahref="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893a9c02fa29c925bc1d37cba92490998132">operations_research::KnapsackSolver::KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER</a></div><divclass="ttdoc">Dynamic Programming approach for single dimension problems.</div><divclass="ttdef"><b>Definition:</b><ahref="knapsack__solver_8h_source.html#l00150">knapsack_solver.h:150</a></div></div>
<divclass="ttc"id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893aa6d83fc5b8d17db1f82c1b414a4e8b20"><divclass="ttname"><ahref="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893aa6d83fc5b8d17db1f82c1b414a4e8b20">operations_research::KnapsackSolver::KNAPSACK_MULTIDIMENSION_SCIP_MIP_SOLVER</a></div><divclass="ttdoc">SCIP based solver.</div><divclass="ttdef"><b>Definition:</b><ahref="knapsack__solver_8h_source.html#l00174">knapsack_solver.h:174</a></div></div>
<divclass="ttc"id="classoperations__research_1_1KnapsackSolver_html_a81ce17438663c39f7793e8db92ff1893aa6c3b9157b2506f5a53b0c73165c8f9b"><divclass="ttname"><ahref="classoperations__research_1_1KnapsackSolver.html#a81ce17438663c39f7793e8db92ff1893aa6c3b9157b2506f5a53b0c73165c8f9b">operations_research::KnapsackSolver::KNAPSACK_64ITEMS_SOLVER</a></div><divclass="ttdoc">Optimized method for single dimension small problems.</div><divclass="ttdef"><b>Definition:</b><ahref="knapsack__solver_8h_source.html#l00142">knapsack_solver.h:142</a></div></div>
<divclass="ttc"id="classoperations__research_1_1KnapsackSolver_html_a7c3b5825c8effd86de03a610d1a38ed7"><divclass="ttname"><ahref="classoperations__research_1_1KnapsackSolver.html#a7c3b5825c8effd86de03a610d1a38ed7">operations_research::KnapsackSolver::Solve</a></div><divclass="ttdeci">int64 Solve()</div><divclass="ttdoc">Solves the problem and returns the profit of the optimal solution.</div></div>