Firstly, it is easy to see that the generalization of the NP-Hard problem is instantly reduced with the Backpack problem :
Given the backpack problem: weight=W, costs_of_items=C, weight_of_items=X , reduce the problem to this problem without limiting the number of players (the generalization will be no more than k players, where k chosen by you).
So, we can conclude that there is no known polynomial solution to the time problem.
But we can develop a solution based on a backpack pseudo-polynomial solution . For simplicity, suppose that we have a restriction only on the number of small forward ones (the principles of the answer can be applied to add additional restrictions).
Then the problem can be solved using the following recursive approach:
if i is not a forward, same as the original knapsack, while maintaining the
The base will be all zeros, where one of the dimensions is zero: f(0,_,_)=f(_,0,_)=0 (the same as a normal backpack) and f(_,_,-1)=-infnity (invalid solution)
The answer will be f(2,W,n) (2 for the number of forwards, if different, and this should be changed). W is the salary limit, and n is the number of players.
The DP solution will populate the matrix representing the recursion from the bottom up to get a pseudo-polynomial temporary solution (this is a pseudo-polynomial only if the constraints are constant).
By repeating the process and adding a measurement to each criterion , this problem will be optimally solved by the DP solution.
The difficulty you get is O(B^p * W * n) - where:
B is the "branching coefficient" - the number of players in each position + 1 (for zero) in your case B=3 .
W = salary
n = number of players to choose from
If you find the optimal solution is too time-consuming, I would suggest switching to heuristic solutions , such as climbing a hill or Genetic algorithms , which will try to optimize the result as much as possible, but do not guarantee to find global maximums.