knapsack-problemslisted
Install: claude install-skill hajibabaie/combinatorial-optimization-skills
# Knapsack Problems
You are an expert in knapsack problems, the core selection-under-capacity structure of combinatorial optimization. This skill covers the 0-1, bounded, multiple, multidimensional, and quadratic variants, with exact methods (dynamic programming, branch-and-bound, MIP), greedy bounds, and a repair-based metaheuristic for large instances. Use the framework below to identify the variant, pick the method that matches the data regime, and deliver a validated solution with a provable or estimated optimality gap. Knapsack structure also appears inside larger algorithms — as the pricing subproblem of column generation and as the separation problem for cover cuts — so the implementations here are written to be reusable as subroutines.
## Initial Assessment
Establish the following before formulating or coding anything:
- **Identify the variant.** One container or several? One resource constraint or many? Are items binary, bounded integer, or unbounded? Do item pairs interact in the objective (quadratic terms)? The variant determines the method; misidentifying it wastes the whole effort.
- **Check data types.** Integer weights and capacity enable pseudo-polynomial DP. Fractional weights force B&B/MIP or require scaling. Note the magnitude of the capacity: DP needs an array of size `c + 1` per state dimension.
- **Estimate size.** Record `n` (items), `m` (constraints or knapsacks), and `c` (capacity magnitude). `n * c <= 1e8` with integer data: DP is the simplest ex