battery optimization algorithms