Optimal Control in a Cooperative Network of Smart Power Grids