fix(optimizer): отсечь заведомо худшие назначения проб
This commit is contained in:
1 parent
1ad6b4a6b6
commit
833225d169
7 files changed
+106
-4
No files matched your search
@@ -345,6 +345,30 @@ export function buildLiveOptimizerData(
|
||||
}
|
||||
return
|
||||
}
|
||||
if (bestAssign) {
|
||||
// Ignore competition for probes: independent maxima are an upper bound
|
||||
// on every possible completion, including a WAN with no compatible probe.
|
||||
let upper = sum
|
||||
const candidateMax = new Map<string, number>()
|
||||
for (let next = i; next < wanList.length; next++) {
|
||||
let maximum = 0
|
||||
for (const candidate of pool) {
|
||||
if (used.has(candidate.id)) continue
|
||||
const value = scoreProbeForWanIface(candidate, wanList[next]!.iface)
|
||||
maximum = Math.max(maximum, value)
|
||||
candidateMax.set(candidate.id, Math.max(candidateMax.get(candidate.id) ?? 0, value))
|
||||
}
|
||||
upper += maximum
|
||||
}
|
||||
// A completion uses at most one distinct probe per remaining WAN.
|
||||
// Its weight is bounded by the highest remaining probe maxima, even
|
||||
// when those maxima cannot actually be assigned to different WANs.
|
||||
const distinctUpper = sum + [...candidateMax.values()].sort((a, b) => b - a)
|
||||
.slice(0, wanList.length - i).reduce((total, value) => total + value, 0)
|
||||
upper = Math.min(upper, distinctUpper)
|
||||
// Equal totals keep the first assignment in the original DFS order.
|
||||
if (upper <= bestSum) return
|
||||
}
|
||||
const wan = wanList[i]!
|
||||
let picked = false
|
||||
for (const p of pool) {
|
||||
|
||||
Reference in new issue
Block a user