[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003e\u003ccode\u003eKnapsackSolver\u003c/code\u003e is a C++ class within the Google OR-Tools library designed for solving knapsack problems, offering various methods for initialization, problem-solving, and solution analysis.\u003c/p\u003e\n"],["\u003cp\u003eUsers can initialize the solver with item profits, weights, and knapsack capacities using the \u003ccode\u003eInit\u003c/code\u003e method, and then invoke the \u003ccode\u003eSolve\u003c/code\u003e method to find the optimal solution.\u003c/p\u003e\n"],["\u003cp\u003eThe class provides functionalities like \u003ccode\u003eBestSolutionContains\u003c/code\u003e to check if an item is part of the optimal solution, and \u003ccode\u003eIsSolutionOptimal\u003c/code\u003e to determine the solution's optimality.\u003c/p\u003e\n"],["\u003cp\u003eAdditional features include setting time limits for the solver using \u003ccode\u003eset_time_limit\u003c/code\u003e and controlling problem reduction techniques with \u003ccode\u003eset_use_reduction\u003c/code\u003e.\u003c/p\u003e\n"]]],["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,["# KnapsackSolver\n\nC++ Reference: class KnapsackSolver\n===================================\n\n\nNote: This documentation is automatically generated.\n\n| Method ||\n|------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`BestSolutionContains`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L218) | Return type: `bool ` Arguments: `int item_id` \u003cbr /\u003e |\n| [`GetName`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L223) | Return type: `std::string ` \u003cbr /\u003e |\n| [`Init`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L206) | Return type: `void ` Arguments: `const std::vector\u003cint64_t\u003e& profits, const std::vector\u003cstd::vector\u003cint64_t\u003e \u003e& weights, const std::vector\u003cint64_t\u003e& capacities` \u003cbr /\u003e |\n| [`IsSolutionOptimal`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L222) | Return type: `bool ` \u003cbr /\u003e |\n| [`KnapsackSolver`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L199) | Return type: `explicit ` Arguments: `const std::string& solver_name` \u003cbr /\u003e |\n| [`KnapsackSolver`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L200) | \u003cbr /\u003e Arguments: `SolverType solver_type, const std::string& solver_name` \u003cbr /\u003e |\n| [`~KnapsackSolver`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L201) | Return type: `virtual ` \u003cbr /\u003e |\n| [`set_time_limit`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L233) | Return type: `void ` Arguments: `double time_limit_seconds` \u003cbr /\u003e |\n| [`set_use_reduction`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L226) | Return type: `void ` Arguments: `bool use_reduction` \u003cbr /\u003e |\n| [`Solve`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L213) | Return type: `int64_t ` \u003cbr /\u003e |\n| [`use_reduction`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L225) | Return type: `bool ` \u003cbr /\u003e |"]]