Assume there are $N$ market participants (on the order of several hundred), and $M$ items (several thousand) being bought and sold on a market.
For each participant/item pair, you know how many units $Q(n, m)$ and at what price a participant is willing to buy $B(n, m)$ and sell $S(n, m)$.
There are pure arbitrage opportunities (i.e., you know that you are able to buy cheaper than you can sell).
How do you go about maximizing profits, while also minimizing the number of transactions? How would you alter the algorithm when you can only pay and receive whole units, but prices are in fractional units (i.e. buy and sell in dollars, but prices are in cents)?