2

I need a way to get highest points players within salary range i.e 50,000 There is a similar question here Algorithm to select Player with max points but with a given cost. Basically I have to select optimal 9-player line-up.

I googling lot and I found this can be achieve using linear programming.But I don't know how can I use Lp in php.

Any idea how can I achieve this or there is any other way to do this?

Community
  • 1
  • 1
Rahul
  • 440
  • 7
  • 24
  • What format is your data in and what code have you tried so far? – M1ke Feb 12 '16 at 11:25
  • This sounds like a **knapsack problem**: You have a certain budget (the "size" of the knapsack) and want to spend it on the subset of goods that will maximize your payoff. Some googling on knapsack problem will point you in the right direction, if indeed this is the form your problem takes. – LarrySnyder610 Feb 13 '16 at 00:39

1 Answers1

0

If you store the information in arrays, I believe you could achieve the result using array_multisort which would give result similar to SQL order by. For example, order by points DESC, salary ASC. This would give back the array having top points players at top and if any of them have the same amount of points, the first would be the one with the lowest salary.

The answer to this question shows how to use array_multisort.

Community
  • 1
  • 1
eggnukes
  • 180
  • 3
  • 20
  • I have already sort the array on the basis of highest point DESC This is what I did so far. [link] (http://stackoverflow.com/questions/35102337/sort-php-array-on-the-basis-of-salary-and-point?noredirect=1#comment57925728_35102337) This is my previous post. – Rahul Feb 12 '16 at 13:25