Finding the profit function I am programming a bargain composer. The composer tries buy the cheapest auctions till the specified quantity is reached. A auction has two important properties. Quantity and Buyout price. I use the 0-1 knapsack algorithm to cope with this problem. I choose this algorithm, because it can takes the quantity and a value list.
A better algorithm suited for this job is also welcome :)
Problem
I am having problems to calculate the value list. The buyout price is not the value you want to put on the 0-1 knapsack. It would return the most expensive items. So I need to inverse the value list. However a BO * -1 would't work since my 0-1 knapsack implementation doesn't work with negative values.
Substracting from a value would inverse the buyout value aswell, however the question from what value? I've tried the max buyout value of the list itself, but it is really a wild guess since I don't really know how to approach this problem (low math experience :<). The following formula works till you hit the maxValue item itself 0 * q = 0
$$P = (maxBO - bo) * q$$


*

*P = inversed buyout value

*maxBO = maximum buyout in the current list of auctions

*bo = buyout

*q = quantity


Edit: Removed the confusing example. Clarified the problem
 A: First to make sure that I understood the problem correctly, I state it in my own words: It is about buying a certain quantity of a commodity, and there is a set of traders who offer the commodity in their individual quantity for their individual price, and you want to find a subset of the set of traders such that the sum of their quantities is at least the required quantity, and the sum of prices is as small as possible.
Is this the problem you want to solve? If so, this is exactly a knapsack problem (selecting items with specified weight and utility such that the sum of weights is at most a given threshold and the sum of utilities is as large as possible) if you interpret selecting items for the knapsack as not buying them.
A: I found the formula:
$$inverseBuyout = (2 * ( 1 / ( buyout / quantity ))) * quantity$$
simplified:
$$inverseBuyout = {\frac{2\cdot quantity^2}{buyout}}$$
Thanks to: http://www.khanacademy.org/video/direct-and-inverse-variation?playlist=Algebra
A: It is true item 2 plus item 3 costs more than item 1.  You have item1=10*int.Max-5000, item2=5*int.Max-500, item3=5*int.Max-2000, so item2 + item3 - item1 = 2500.  Why do you find this surprising?  I don't understand 

It seems (m-bo) is breaking the inversion of the buyout to most profit. If m is either maxBO (max buyout) or int.Max or mBO + 1 it breaks.

at all
