Distributed Dual Subgradient Methods with Averaging and Applications to Grid Optimization