How about the payment coin optimization; quick (not very throughtful) peek at the code reveals it tries to first pay with one coin and then some optimization for paying with more than one coins. AFAIK,it is optimized for the current, ongoing payment.
Maybe it should be optimized for future payments, ie so that the end result is as good wallet as possible; not too small coins (which are expensive to spend) and the coin size as variable as possible.
Ie, woudn't optimal wallet be such that there is coins of different sizes, every coin size double the smaller one. Fex. 1BTC,2BTC,4BTC, 8BTC etc.
Or at least try to make the wallet so that future payments could be most likely to be payed with 2 input coins.
The coin selection is certainly non-optimal. Part of the difficulty is optimal is highly subjective and variable depending on the user. Still a "better" (albeit not optimal) algorithm could probably be used. Honestly I don't really see it as a priority for current developers. There are much more important changes to the client and protocol. It is open source. You could make improved coin selection your contribution.
In order for a transaction to be free, three conditions must be met:
--Transaction is less than 3.5 kB (approx)
--Transaction does not have any dust outputs (<0.01 BTC)
--Transaction inputs have priority-sum greater than 1 bitcoin-day-per-250-bytes
If the transaction cannot be free, then use the folllowing fee:
--If transaction is less than 3.5 kB, use fee 0.0005 BTC
--Otherwise, use (0.0005 * roundup(numkB))
There are more fees required to get it into the next block, if there's already a lot of transactions being included in the next block. But this fee will always get it included in one of the next blocks. So far, I haven't experienced any users (or myself) getting coins stuck in Armory.
Well, based on this, the optimal wallet is One Big Old Fat Coin ;-) And every payment can be (and should be) used to defragment the wallet...
But the problem is that after every transaction, you get change, which is a brand new coin.. Without the coin age priorization, one should allways use the whole wallet for every payment, as long as it fits to 3.5 kb limit. If it does not, use as many of the biggest coins as possible.
For the long run, this would be good also for the block chain. When the pruning comes to work, the coins would be more on the new blocks and they would be bigger.
Edit: this princible is ok, but formula sucks. Must rethink it..
But sinze there is coin age, the wallet should ask the user how many payments one makes per day and then collect (by payments) as many big old coins as she/he gives as an answer divided by 120 and multiplied by wallet coins. So, if your wallet size is 120 BTC or more, you can keep them in one coin.