So you initialize the vector with zeros for each peer? I'm not sure if this is a bug, but it definitely seems confusing, since the number of peers with devices could be less than the total number of peers, and you only overwrite the zeros later for peers with devices. What if the device with the highest demand has negative power, then it will get incorrectly set to zero below. (So it is a bug. :)

How about not pre-filling the vector, and just adding new elements as needed with `push_back()` instead: that seems safer.