Distributed Optimization in Adaptive Networks