Arguments: int item_id, bool is_item_in,
int64_t* lower_bound,
int64_t* upper_bound
Gets the lower and upper bound when the item is in or out of the knapsack.
To ensure objects are correctly initialized, this method should not be
called before ::Init.
[[["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\u003eBaseKnapsackSolver\u003c/code\u003e serves as the foundational class for all knapsack solvers within the OR-Tools library.\u003c/p\u003e\n"],["\u003cp\u003eIt provides essential functionalities such as initialization with problem data (profits, weights, capacities), solving the knapsack problem, and retrieving the optimal solution.\u003c/p\u003e\n"],["\u003cp\u003eMethods like \u003ccode\u003eGetLowerAndUpperBoundWhenItem\u003c/code\u003e and \u003ccode\u003ebest_solution\u003c/code\u003e offer insights into the solution space and individual item placements.\u003c/p\u003e\n"],["\u003cp\u003eUsers should call \u003ccode\u003eInit\u003c/code\u003e to set up the problem before invoking \u003ccode\u003eSolve\u003c/code\u003e to find the optimal solution within the given time limit.\u003c/p\u003e\n"]]],["`BaseKnapsackSolver` is a foundational class for solving knapsack problems. Key actions include initializing the solver (`Init`) with item profits, weights, and capacities, and solving the problem (`Solve`) to find the optimal profit. The class provides methods to check if an item is in the optimal solution (`best_solution`), retrieve bounds for items being in or out of the knapsack (`GetLowerAndUpperBoundWhenItem`), and get the solver's name (`GetName`). There are methods for the constructor and destructor.\n"],null,["# BaseKnapsackSolver\n\nC++ Reference: class BaseKnapsackSolver\n=======================================\n\n\nNote: This documentation is automatically generated.\n\n----- BaseKnapsackSolver ----- \nThis is the base class for knapsack solvers.\n\n| Method ||\n|---------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`BaseKnapsackSolver`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L575) | Return type: `explicit ` Arguments: `const std::string& solver_name` \u003cbr /\u003e |\n| [`~BaseKnapsackSolver`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L577) | Return type: `virtual ` \u003cbr /\u003e |\n| [`best_solution`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L595) | Return type: `virtual bool ` Arguments: `int item_id` Returns true if the item 'item_id' is packed in the optimal knapsack. |\n| [`GetLowerAndUpperBoundWhenItem`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L587) | Return type: `virtual void ` Arguments: `int item_id, bool is_item_in, int64_t* lower_bound, int64_t* upper_bound` Gets the lower and upper bound when the item is in or out of the knapsack. To ensure objects are correctly initialized, this method should not be called before ::Init. |\n| [`GetName`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L597) | Return type: `virtual std::string ` \u003cbr /\u003e |\n| [`Init`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L580) | Return type: `virtual 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` Initializes the solver and enters the problem to be solved. |\n| [`Solve`](https://github.com/google/or-tools/blob/v9.4/ortools/algorithms/knapsack_solver.h#L592) | Return type: `virtual int64_t ` Arguments: `TimeLimit* time_limit, bool* is_solution_optimal` Solves the problem and returns the profit of the optimal solution. |"]]