|
@@ -21,7 +21,7 @@ DEFAULT_THRESHOLDS = {
|
|
|
"weights": {"P1": 0.35, "P2": 0.25, "P3": 0.15, "P4": 0.15, "P5": 0.10},
|
|
"weights": {"P1": 0.35, "P2": 0.25, "P3": 0.15, "P4": 0.15, "P5": 0.10},
|
|
|
"stale_hook_limit": 10, "burst_hook_limit": 5,
|
|
"stale_hook_limit": 10, "burst_hook_limit": 5,
|
|
|
"no_advance_limit": 5,
|
|
"no_advance_limit": 5,
|
|
|
- "payoff_interval_min": 2000, "payoff_interval_max": 5000,
|
|
|
|
|
|
|
+ "payoff_interval_min": 300, "payoff_interval_max": 500,
|
|
|
"weak_hook_consecutive_max": 3,
|
|
"weak_hook_consecutive_max": 3,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -125,12 +125,35 @@ class QualityTuner:
|
|
|
applied.append({**s, "applied": True})
|
|
applied.append({**s, "applied": True})
|
|
|
elif s["type"] == "weight_adjust":
|
|
elif s["type"] == "weight_adjust":
|
|
|
target = s["target_pass"]
|
|
target = s["target_pass"]
|
|
|
- redistribute = s.get("redistribute_from")
|
|
|
|
|
old_w = self.thresholds["weights"][target]
|
|
old_w = self.thresholds["weights"][target]
|
|
|
|
|
+ delta = s["suggested_weight"] - old_w
|
|
|
self.thresholds["weights"][target] = s["suggested_weight"]
|
|
self.thresholds["weights"][target] = s["suggested_weight"]
|
|
|
- if redistribute:
|
|
|
|
|
- self.thresholds["weights"][redistribute] -= (s["suggested_weight"] - old_w)
|
|
|
|
|
- self.adjustments.append({"what": f"weight_{target}", "from": old_w, "to": s["suggested_weight"]})
|
|
|
|
|
|
|
+
|
|
|
|
|
+ # 从其他维度扣减 delta,每维度不低于 floor=0.05
|
|
|
|
|
+ floor = 0.05
|
|
|
|
|
+ donors = sorted(
|
|
|
|
|
+ [(dim, w) for dim, w in self.thresholds["weights"].items()
|
|
|
|
|
+ if dim != target and w > floor],
|
|
|
|
|
+ key=lambda x: x[1], reverse=True
|
|
|
|
|
+ )
|
|
|
|
|
+ remaining = delta
|
|
|
|
|
+ for dim, w in donors:
|
|
|
|
|
+ if remaining <= 0:
|
|
|
|
|
+ break
|
|
|
|
|
+ available = w - floor
|
|
|
|
|
+ take = min(available, remaining)
|
|
|
|
|
+ self.thresholds["weights"][dim] -= take
|
|
|
|
|
+ remaining -= take
|
|
|
|
|
+
|
|
|
|
|
+ # 归一化到 1.0,避免浮点累积
|
|
|
|
|
+ total = sum(self.thresholds["weights"].values())
|
|
|
|
|
+ for dim in self.thresholds["weights"]:
|
|
|
|
|
+ self.thresholds["weights"][dim] = round(
|
|
|
|
|
+ self.thresholds["weights"][dim] / total, 10
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ self.adjustments.append({"what": f"weight_{target}", "from": old_w,
|
|
|
|
|
+ "to": self.thresholds["weights"][target]})
|
|
|
applied.append({**s, "applied": True})
|
|
applied.append({**s, "applied": True})
|
|
|
return applied
|
|
return applied
|
|
|
|
|
|