Approximate dynamic programming using fluid and diffusion approximations with applications to power management