Distributed optimisation in dynamic wireless sensor networks