Seite 1 von 1

distributeRemaining backwards

Verfasst: Sonntag 12. Februar 2017, 21:28
von jmichael
A comment in SystemManager says that distributeRemaining is supposed to assign leftover workers to the building types with the highest fractional assignments. The code I see sorts, but does not reverse the list, or process the list backwards. I think this is responsible for a tiny part of the apparent unpredictability of labor assignments.

Re: distributeRemaining backwards

Verfasst: Montag 13. Februar 2017, 09:33
von blotunga
It is sorted then reversed at the end, see here

Re: distributeRemaining backwards

Verfasst: Dienstag 14. Februar 2017, 05:20
von jmichael
calc sorts and reverses before returning. It sorts based on count.

Right before this, calc calls distributeRemaining, which sorts on fPart, but does not reverse before adding one worker to each category (until it runs out of idle workers).

Re: distributeRemaining backwards

Verfasst: Dienstag 14. Februar 2017, 10:40
von blotunga
jmichael hat geschrieben:calc sorts and reverses before returning. It sorts based on count.

Right before this, calc calls distributeRemaining, which sorts on fPart, but does not reverse before adding one worker to each category (until it runs out of idle workers).
Ah, I missed that. Yes that should be iterated in reverse. It probably won't make a huge difference, but yes that's the correct way.