Stochastic and Optimal Distributed Control for Energy Optimization and Spatially Invariant Systems