TWO STAGE CHARGE AND DISCHARGE OPTIMIZATION OF BATTERY ENERGY STORAGE