(svn r26166) -Fix: Scale flows only after mapping to avoid rounding errors.
This commit is contained in:
@@ -4289,6 +4289,22 @@ void FlowStat::ReleaseShare(StationID st)
|
||||
assert(!this->shares.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale all shares from link graph's runtime to monthly values.
|
||||
* @param runtime Time the link graph has been running without compression.
|
||||
*/
|
||||
void FlowStat::ScaleToMonthly(uint runtime)
|
||||
{
|
||||
SharesMap new_shares;
|
||||
uint share = 0;
|
||||
for (SharesMap::iterator i = this->shares.begin(); i != this->shares.end(); ++i) {
|
||||
share = max(share + 1, i->first * 30 / runtime);
|
||||
new_shares[share] = i->second;
|
||||
if (this->unrestricted == i->first) this->unrestricted = share;
|
||||
}
|
||||
this->shares.swap(new_shares);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add some flow from "origin", going via "via".
|
||||
* @param origin Origin of the flow.
|
||||
|
Reference in New Issue
Block a user