ONLINE CONTROL AND NEAR OPTIMAL ALGORITHM FOR DISTRIBUTED ENERGY