C++ Reference: class KnapsackGenericSolver

Note: This documentation is automatically generated.

   ----- KnapsackGenericSolver -----
KnapsackGenericSolver is the multi-dimensional knapsack solver class. In the current implementation, the next item to assign is given by the primary propagator. Using SetPrimaryPropagator allows changing the default (propagator of the first dimension), and selecting another dimension when more constrained. TODO(user): In the case of a multi-dimensional knapsack problem, implement an aggregated propagator to combine all dimensions and give a better guide to select the next item (see, for instance, Dobson's aggregated efficiency).

Return type: bool

Arguments: int item_id

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


Return type: void

Arguments: int item_id, bool is_item_in, int64_t* lower_bound, int64_t* upper_bound


Return type: int


Return type: 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.


Return type: explicit

Arguments: const std::string& solver_name



Return type: void

Arguments: int primary_propagator_id

Sets which propagator should be used to guide the search. 'primary_propagator_id' should be in 0..p-1 with p the number of propagators.


Return type: int64_t

Arguments: TimeLimit* time_limit, bool* is_solution_optimal

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