![]() |
Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
|
KnapsackItem is a small struct to pair an item weight with its corresponding profit.
The aim of the knapsack problem is to pack as many valuable items as possible. A straight forward heuristic is to take those with the greatest profit-per-unit-weight. This ratio is called efficiency in this implementation. So items will be grouped in vectors, and sorted by decreasing efficiency.
Definition at line 293 of file knapsack_solver.h.
#include <knapsack_solver.h>
Public Member Functions | |
| KnapsackItem (int _id, int64_t _weight, int64_t _profit) | |
| double | GetEfficiency (int64_t profit_max) const |
Public Attributes | |
| const int | id |
| const int64_t | weight |
| const int64_t | profit |
|
inline |
Definition at line 294 of file knapsack_solver.h.
|
inline |
Definition at line 296 of file knapsack_solver.h.
| const int operations_research::KnapsackItem::id |
The 'id' field is used to retrieve the initial item in order to communicate with other propagators and state.
Definition at line 304 of file knapsack_solver.h.
| const int64_t operations_research::KnapsackItem::profit |
Definition at line 306 of file knapsack_solver.h.
| const int64_t operations_research::KnapsackItem::weight |
Definition at line 305 of file knapsack_solver.h.