where the power and energy ratings of the battery, the energy of the battery at any instant, and the power injected into the grid at any instant are all positive. The problem is modeled in the general algebraic modeling system (GAMS) and solved using the MoSEK solver.