Optimization of Energy Storage Operation