pydatastructs icon indicating copy to clipboard operation
pydatastructs copied to clipboard

Generic implementation of optimal grouping of objects using dynamic programming

Open pravalikavis opened this issue 5 years ago • 11 comments

References to other Issues or PRs or Relevant literature

fixes #230

Brief description of what is fixed or changed

  1. Added a file which has an optimal_grouping method which groups the given objects based on the cost input function.
  2. This function uses dynamic programing which reduces the time complexity
  3. 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

pravalikavis avatar May 01 '20 15:05 pravalikavis

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.

czgdp1807 avatar May 01 '20 16:05 czgdp1807

I have moved the file to linear_data_structures.

pravalikavis avatar May 01 '20 17:05 pravalikavis

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

czgdp1807 avatar May 15 '20 15:05 czgdp1807

Hi, I moved the code to the specified file and removed some type checks.

pravalikavis avatar May 16 '20 12:05 pravalikavis

Add some tests for your patch. See tests folder under linear_data_structures. The build is failing. Make it work.

czgdp1807 avatar May 16 '20 14:05 czgdp1807

Codecov Report

Merging #272 into master will decrease coverage by 0.180%. The diff coverage is 89.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:

Impacted file tree graph

codecov[bot] avatar May 27 '20 18:05 codecov[bot]

Hi, I have made the changes.

pravalikavis avatar May 27 '20 18:05 pravalikavis

@pravalikavis Please resolve merge conflicts.

Smit-create avatar Mar 15 '21 04:03 Smit-create

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.

czgdp1807 avatar Mar 15 '21 05:03 czgdp1807

Agreed on this

Smit-create avatar Mar 15 '21 17:03 Smit-create