Battery-constrained optimization