Equation (10) ensures that the battery power during charge or discharge does not exceed the power rating of the battery. To limit the depth of discharge of the battery to the recommended level, (11) ensures that the battery energy at any instant is not less than the minimum allowed state of charge. this equation also does not permit the energy inside the battery to exceed the battery rating the charging period. In general, the contract between the utility and the system owner specifies the power rating of the PV system installed at a certain location. Thus, the power generation from the PV/BS system should not exceed the ratings specified in the contract, as shown in (12). The last constraint in the optimization problem is the nonnegativity constraint, 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.