SciRuby / daru

Data Analysis in RUby
BSD 2-Clause "Simplified" License
1.04k stars 139 forks source link

Linear Programming - Algorithms for DataFrames #320

Closed athityakumar closed 7 years ago

athityakumar commented 7 years ago

Given that Daru is going to work on analyzing DataFrames, it seems logical to me to include LPP (Linear Programming Problems) algorithms - like Simplex, Big M, 2 phase simplex, Dual simplex, Revised simplex, Primal-dual, etc.

I wasn't able to find any such LPP methods in pandas, but this may be because pandas is able to work with numpy ndarrays. However, I don't think this is the case with Daru.

So, I would prefer a test case like -

constraints  =  Daru::DataFrame.rows [[1,1,0,:mteq,1],[2,0,1,:lteq,5]], order: [:x1,:x2,:x3,:case,1]
objective    =  Daru::Vector.new [4,8,3,0], index: [:x1,:x2,:x3,1]

constraints.optimal objective, :min
=> Daru::Vector.new [2,0,0,8], index: [:x1,:x2,:x3,:z]

ie, 
 => #<Daru::Vector(4)>
  x1   2
  x2   0
  x3   0
   z   8 

Here, the optimal should be able to decide the appropriate method (Big M / Revised Simplex / etc.) has to be used for the given set of constraints and objective - as different methods support only specific types (say, non-negative) of input. There should also be support for Un-bounded and In-feasible cases.

Other technicalities like Basic Feasible Solution, Degenerate Solution, etc. can also be implemented if required. However, IMO - the user would have more use of the Daru::DataFrame#optimal function rather than type of solutions.

gnilrets commented 7 years ago

I think I'd rather see Daru be really good at dataframes. By good, I mean that manipulating dataframes - reading, writing, filtering, joining, grouping, transforming - should be fast and bug free. For this LP work, it would make more sense to build it into a separate package - e.g., "Daru Data Science Library"

v0dro commented 7 years ago

I agree with @gnilrets. We can probably have a separate gem that specifically caters to this need.

dansbits commented 7 years ago

+1 I like the idea but but it doesn't seem like core functionality for Daru.

v0dro commented 7 years ago

Closing this issue. Maybe we should discuss in the mailing list about making a separate gem for this purpose.