A Reinforcement Learning Theory for Homeostatic Regulation