Stay organized with collections
Save and categorize content based on your preferences.
C++ Reference: class KnapsackSolver
Note: This documentation is automatically generated.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-08-06 UTC.
[null,null,["Last updated 2024-08-06 UTC."],[],["The `KnapsackSolver` class provides methods for solving knapsack problems. Key actions include initializing the solver with `Init`, providing profits, weights, and capacities. The `Solve` method computes the solution, returning the maximum total profit. `BestSolutionContains` checks if a specific item is included in the optimal solution. Other functionalities include retrieving the `GetName`, determining if the solution is optimal with `IsSolutionOptimal`, enabling/disabling reduction with `set_use_reduction`/ `use_reduction` and setting a time limit via `set_time_limit`. It can be constructed using `KnapsackSolver` and destructed with `~KnapsackSolver`.\n"],null,[]]