C++ Reference: class KnapsackGenericSolver

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 master propagator. Using SetMasterPropagator 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).
Method
best_solution

Return type: bool

Arguments: int item_id

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

GetLowerAndUpperBoundWhenItem

Return type: void

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

GetNumberOfItems

Return type: int

Init

Return type: void

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

Initializes the solver and enters the problem to be solved.

KnapsackGenericSolver

Return type: explicit

Arguments: const std::string& solver_name

~KnapsackGenericSolver

set_master_propagator_id

Return type: void

Arguments: int master_propagator_id

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

Solve

Return type: int64

Arguments: TimeLimit* time_limit, bool* is_solution_optimal

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