Distributed Optimization for Energy Management in Building Networks