C++ Reference: class BaseKnapsackSolver

Note: This documentation is automatically generated.


   ----- BaseKnapsackSolver -----
This is the base class for knapsack solvers.
Method
BaseKnapsackSolver

Return type: explicit

Arguments: const std::string& solver_name

~BaseKnapsackSolver

Return type: virtual

best_solution

Return type: virtual bool

Arguments: int item_id

Returns true if the item 'item_id' is packed in the optimal knapsack.

GetLowerAndUpperBoundWhenItem

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.

GetName

Return type: virtual std::string

Init

Return type: virtual void

Arguments: const std::vector<int64_t>& profits, const std::vector<std::vector<int64_t> >& weights, const std::vector<int64_t>& capacities

Initializes the solver and enters the problem to be solved.

Solve

Return type: virtual int64_t

Arguments: TimeLimit* time_limit, bool* is_solution_optimal

Solves the problem and returns the profit of the optimal solution.