Generic implementation of optimal grouping of objects using dynamic programming
References to other Issues or PRs or Relevant literature
fixes #230
Brief description of what is fixed or changed
- Added a file which has an optimal_grouping method which groups the given objects based on the cost input function.
- This function uses dynamic programing which reduces the time complexity
- It can be used on problems like Matrix chain multiplication, optimal binary search tree and on any other problem that follows the two rules of dynamic programming along with divide and conquer.
Other comments
The algorithm will work on an array of objects if I am not wrong. So, the code should be shifted to pydatastructs/pydatastructs/linear_data_structures/algorithms.py.
I have moved the file to linear_data_structures.
Hi, The code is having too many checks. Can you please simplify it? And the code should be appended to https://github.com/codezonediitj/pydatastructs/blob/master/pydatastructs/linear_data_structures/algorithms.py
Hi, I moved the code to the specified file and removed some type checks.
Add some tests for your patch. See tests folder under linear_data_structures. The build is failing. Make it work.
Codecov Report
Merging #272 into master will decrease coverage by
0.180%. The diff coverage is89.583%.
@@ Coverage Diff @@
## master #272 +/- ##
=============================================
- Coverage 98.842% 98.662% -0.181%
=============================================
Files 23 23
Lines 2420 2467 +47
=============================================
+ Hits 2392 2434 +42
- Misses 28 33 +5
| Impacted Files | Coverage Δ | |
|---|---|---|
| pydatastructs/linear_data_structures/__init__.py | 100.000% <ø> (ø) |
|
| pydatastructs/linear_data_structures/algorithms.py | 96.815% <89.583%> (-3.185%) |
:arrow_down: |
Hi, I have made the changes.
@pravalikavis Please resolve merge conflicts.
My only concern with dynamic programming problems is that they aren't that abstract and generalized. Moreover, they are pseudo-polynomial solutions to optimisation problems (mostly discrete). So possibly, we can add a separate optimisation module and put the dynamic programming solutions there. In fact they can also contain parametrised approximation algorithm. Anyways, we should first check if there is already a python package for solving these kind of formulations.
Agreed on this