A bit of a long shot, but the general algorithmic solution to such problems (not involving actually modelling the underlying physics) involves a PID controller:
http://en.wikipedia.org/wiki/PID_controller
Whether this will get you anywhere, I've no idea, but from your description, you may be trying to do something similar.