I have some code that targets a task to a desired cost. It adjusts each resource assignment using a ratio of the desired cost over current cost. In general, it works great except in a very specific situation.

If the delta between the current cost and desired cost is very small, it is almost impossible to get the cost to the exact penny. It ends up being 1 or 2 cents above or below. Every time you run it, it flip flops between being 1-2 cents high and 1-2 cents low.

I have tried changing the current cost, the number of units, and the initial cost at the beginning to achieve a greater delta so that it will work but the results are mixed.

Does anyone know of a way to ensure that you can target to cost the first time every time?