OPTIMAL ENERGY MANAGEMENT AND ECONOMIC ANALYSIS OF A GRID CONNECTED