knapsack-problems
When the user wants to solve knapsack optimization problems, select items with constraints, or maximize value with limited capacity. Also use when the user mentions "0/1 knapsack," "bounded knapsack," "unbounded knapsack," "multiple knapsack," "multidimensional knapsack," "value-based packing," "capacity-constrained selection," or "resource allocation with limits." For bin packing, see 2d-bin-packing or 3d-bin-packing. For general optimization, see optimization-modeling.
npx skills add majiayu000/claude-skill-registry --skill knapsack-problems-kishorkukreja-awesome-supply-chain --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
The skill presents an expert-driven framework for solving knapsack optimization problems and resource allocation. It categorizes problem types (0/1, bounded, unbounded, multiple, multidimensional, quadratic) and provides mathematical formulations, algorithms, and example implementations to maximize value under capacity constraints.
How it works
- It first classifies the problem into a knapsack variant (e.g., 0/1 Knapsack, Bounded Knapsack, Unbounded Knapsack, Multidimensional Knapsack, Multiple Knapsack, Quadratic Knapsack).
- For each variant, it states the decision variables, objective (maximize value), and relevant constraints (e.g., weight, volume, or multiple resources).
- It includes algorithmic approaches and concrete code blocks: dynamic programming for 0/1 (with a detailed Python implementation), a space-optimized DP variant, branch-and-bound for larger problems, a greedy approximation, a bounded knapsack approach via expanding items and solving as 0/1, unbounded knapsack with backtracking, and a multidimensional greedy approach.
- For the Multidimensional Knapsack, it outlines a greedy + local search method with a note on NP-hardness.
- For the Multiple Knapsack, it provides a skeleton that imports a linear programming tool (e.g., from pulp) to handle assignment across knapsacks.
When to use it
Use this skill when the user asks to solve knapsack optimization problems, select constrained items, or maximize value with limited capacity. It also directs usage when the user mentions variants like 0/1 knapsack, bounded, unbounded, multiple, multidimensional, value-based packing, capacity-constrained selection, or resource allocation with limits. It also points to related areas (bin packing and general optimization) for broader contexts.
What it can touch
- Code blocks labeled with function definitions and algorithms for:
- knapsack_01_dynamic
- knapsack_01_space_optimized
- knapsack_branch_and_bound
- knapsack_greedy_approximation
- bounded_knapsack
- unbounded_knapsack
- multidimensional_knapsack
- multiple_knapsack (example scaffolding using pulp)
- It relies on standard Python data structures and mathematical formulations to compute optimal or approximate solutions.
Caveats
- It notes NP-hardness for the multidimensional knapsack and suggests greedy + local search as an approximate approach.
- The multiple knapsack section uses an external tool (pulp) as part of the implementation scaffolding; licensing or installation considerations would apply outside the skill text.
- The skill provides sample code and formulations but does not guarantee optimality for all problem sizes, particularly for NP-hard variants.
# Knapsack Problems You are an expert in knapsack optimization problems and resource allocation. Your goal is to help select optimal combinations of items subject to capacity constraints, maximizing value or profit while respecting weight, volume, or other resource limits. ## Initial Assessment Before solving knapsack problems, understand: 1. **Problem Type** - 0/1 Knapsack? (each item taken once or not at all) - Bounded Knapsack? (limited quantity of each item) - Unbounded Knapsack? (unlimited quantity of each item) - Multiple Knapsack? (multiple containers/resources) - Multidimensional? (multiple constraints like weight AND volume) 2. **Items and Values** - How many item types? (10s, 100s, 1000s) - Item values (profit, utility, priority)? - Item costs (weight, volume, price)? - Any item dependencies or conflicts? 3. **Capacity Constraints** - Single constraint (weight only) or multiple (weight + volume)? - Capacity limits (weight capacity, volume capacity, budget)? - Multiple knapsacks with different capacities? 4. **Optimization Goal** - Maximize total value? - Minimize total cost while meeting requirements? - Multi-objective (value vs. weight)? 5. **Special Requirements** - Mus
- Initial Assessment
- Knapsack Problem Framework
- Problem Classification
- Mathematical Formulation
- Basic 0/1 Knapsack
- Multidimensional Knapsack
- Algorithms and Solution Methods
- Dynamic Programming for 0/1 Knapsack
- Branch and Bound for 0/1 Knapsack
- Greedy Approximation
- Bounded Knapsack
- Unbounded Knapsack
- Multiple Knapsack Problem
- Complete Knapsack Solver
What does the knapsack-problems skill do?
When the user wants to solve knapsack optimization problems, select items with constraints, or maximize value with limited capacity. Also use when the user mentions "0/1 knapsack," "bounded knapsack," "unbounded knapsack," "multiple knapsack," "multidimensional knapsack," "value-based packing," "capacity-constrained selection," or "resource allocation with limits." For bin packing, see 2d-bin-packing or 3d-bin-packing. For general optimization, see optimization-modeling.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill knapsack-problems-kishorkukreja-awesome-supply-chain --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
