I just realized that this is very similar to the well-known
Knapsack problem, only you don't need to find the optimal solution, just need to list them all:
https://en.wikipedia.org/wiki/Knapsack_problem[
^].
From this article, you can find the overview of known solutions. Not all of them will be helpful for you, because you need to list all solutions not exceeding the maximum total value, not the best one. Anyway, as the problem is found to be
NP-complete (
https://en.wikipedia.org/wiki/NP-completeness[
^]), you have nothing to do but try all possible solutions, so you just need to list them.
Let's call the "solution" the set of numbers representing the number of caught fish of each species. So, you need to fill in the array of integers representing the number of caught fish with numbers 0 to N and choose only the solution with total point amount not exceeding the allowed maximum for total amount.
First, I would find the maximum numbers of caught fish of each species, not exceeding the maximum total amount in the case you catch fish of only this species. Having N species i = 1... N, your maximum fish numbers for each species will be inside the ranges
species
0: [ 0.. Max
species0 ]
species
1: [ 0.. Max
species1 ]
...
species
N-1: [ 0.. Max
speciesN−1 ]
The total number of variants to check up won't exceed the number
(Max
species0+1) * (Max
species1+1) *... (Max
speciesN−1+1).
You can try all those combinations in some order, that's it.
—SA