Let me describe my problem: I've got around 1500 items, all of them described by 15 numeric (rational numbers, positive and negative) attributes.
As an minimalized example:
Item A: - value I: 34 - value II: 12335 - value III: -10 - value IV: 0 .... Item B: - value I: 500 - value II: -2332 - value III: 0 - value IV: 9 ... No i have to combine them and find the best combination. There is space for about 70 items and each item can be used n times.
The performance of each combination can be determinated by a simple math formular using 3 of the attributes, while the other attributes has to match min or max requirements to determinate if a combination is valid or not.
because some items have good values for a single attribute, but negative for other attributes, other items have to be taken to compensate these negative aspects
Now I'm looking for an approach/algorithm/tooling to find the best combination or at least get near to it.
My approaches were to (in pseudocode)
//approach A while(true) var best = generateRandomCombination() var challenger = generateRandomCombination() best = betterPerformanceIndicator(best, challenger) at some point i have to stop it and use the result. tried it, let it run for an hour and loggt every single improvement. horrific performance, to much randomness means repetition. and of course it does not came near to a result i'd produce on my own.
//approach B var best = generateRandomCombination(); while(true) var challenger = replaceSingleItemWithRandomOne(best) while (!challenger.isBetter(best) && untestedItemsLeft()){ challenger = replaceWithOtherItem(best); } best = betterPerformanceIndicator(best, challenger) This approach is some kind of approximation, but i think because of the needed compensations it won't be very efficient to change only one item.
So i see two possible ways to improve: - perhaps i should give the items some kind of weighting - replace more than on item
Do you have any suggestions to improve my approaches or replace it with better ones? Is this some kind of data-mining problem? What should i learn to deal with it?
(if my question is wrong in here, i'm sorry. would be nice if you would redirect me to the correct stack exchange section)
added information due to comments:
- in the beginning i have to fix the container properties, to determinate if there is space for 70, 71 or an other amout of items. And to to determinate the multiplicator of each attribute. As an example: the containers multiplicator of "value I" would be 1,1 - adding Item A and Item B wour result in (34 + 500) * 1,1 = 587,4.
- So you see, adding the items is simple math (addition and multiplication) Concerning speed, my first approaches were written in java using Lists, but i have not tracked the speed of these single operations.
- the order of the item does not effect the outcome, so it's about building an unordered set, just like Neil asked.
The formula to compute the total value is:
square root of ( (sum of all valueI) multiplied by (sum of all valueII and valueIII) )
- min and max requiremants are just natural numbers, that the sum of all valueN should (not) reach at least