Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of the Knapsack Problem Solver #11401

Closed
MFRADJ opened this issue May 12, 2024 · 1 comment · May be fixed by #11406
Closed

Implementation of the Knapsack Problem Solver #11401

MFRADJ opened this issue May 12, 2024 · 1 comment · May be fixed by #11406
Labels
enhancement This PR modified some existing files

Comments

@MFRADJ
Copy link

MFRADJ commented May 12, 2024

Feature description

Description
I propose the addition of a new feature to solve the Knapsack Problem, a fundamental challenge in combinatorial optimization. This problem involves selecting items with specific weights and values to maximize the total value without exceeding the weight capacity of the knapsack. It has applications in resource allocation, logistics, finance, and more.

Suggested Implementation
The solver could be implemented using Python, and I recommend starting with a dynamic programming approach for the 0/1 Knapsack Problem. Future enhancements might include other variations like the Bounded and Unbounded Knapsack Problems.

Educational Value: Great for demonstrating algorithm efficiency and optimization techniques.
Utility: Can be used as a utility for other features within the project that may require optimization capabilities.
Community Engagement: Offers a well-defined problem that could help new contributors get involved with the project through clear, manageable goals.

Requirements
A function to accept arrays/lists of weights, values, and the maximum capacity of the knapsack.
An algorithm to compute the maximum value that can be carried in the knapsack without exceeding the weight limit.
Unit tests to ensure the functionality works correctly under various scenarios.

Possible Extensions
Adding support for fractional items (for the fractional knapsack problem).
Implementing different algorithms for comparison, such as a greedy approach, branch and bound, or genetic algorithms.
I believe this feature would be a valuable addition to the project and look forward to the community's feedback and ideas on this proposal.

Example_Knapsack Problem.pdf

@MFRADJ MFRADJ added the enhancement This PR modified some existing files label May 12, 2024
snigdha510 added a commit to snigdha510/Python that referenced this issue May 15, 2024
@tianyizheng02
Copy link
Contributor

We literally have a knapsack/ directory just for solutions to the knapsack problem. Please look over the repo contents before you open an issue.

Also, if you want to contribute an algorithm, just open a PR. There's no need to open an issue, as there is no "issue".

@tianyizheng02 tianyizheng02 closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This PR modified some existing files
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@tianyizheng02 @MFRADJ and others