Spaces:
Running
Running
Commit ·
753837d
1
Parent(s): 28b0a00
updates
Browse files
solver.py
CHANGED
|
@@ -63,8 +63,8 @@ def run_milp_model(data: dict):
|
|
| 63 |
# Bench weights (Strictly trusts the payload dictionary)
|
| 64 |
raw_bw = settings["bench_weights"]
|
| 65 |
bench_weights = {int(k): float(v) for k, v in raw_bw.items()}
|
| 66 |
-
gk_bench_w = bench_weights.get(0, 0.03)
|
| 67 |
-
of_bench_ws = [bench_weights.get(i, 0.0) for i in [1, 2, 3]]
|
| 68 |
avg_of_bench_w = sum(of_bench_ws) / len(of_bench_ws) if of_bench_ws else 0.05
|
| 69 |
|
| 70 |
chip_gws: dict[int, str] = {}
|
|
@@ -344,16 +344,12 @@ def run_milp_model(data: dict):
|
|
| 344 |
prob += pulp.lpSum(transfer_in[p][w] for p in players) == 0
|
| 345 |
|
| 346 |
if chip == "fh":
|
| 347 |
-
# THE FIX: Decouple the
|
| 348 |
-
|
| 349 |
-
# 1. The Affordability Check: Ensure the new squad cost is <= total wealth
|
| 350 |
prob += itb[eff_prev] + pulp.lpSum(
|
| 351 |
fh_sell_price[p] * squad[p][eff_prev] for p in players
|
| 352 |
) >= pulp.lpSum(fh_sell_price[p] * squad[p][w] for p in players)
|
| 353 |
-
|
| 354 |
-
# 2. The Freeze Check: The real bank carries forward untouched.
|
| 355 |
-
# Because unspent money vanishes into the void instead of returning to itb[w],
|
| 356 |
-
# the solver gets 0 EV for hoarding it and is forced to spend every cent on the bench!
|
| 357 |
prob += itb[w] == itb[eff_prev]
|
| 358 |
else:
|
| 359 |
prob += (
|
|
|
|
| 63 |
# Bench weights (Strictly trusts the payload dictionary)
|
| 64 |
raw_bw = settings["bench_weights"]
|
| 65 |
bench_weights = {int(k): float(v) for k, v in raw_bw.items()}
|
| 66 |
+
gk_bench_w = max(float(bench_weights.get(0, 0.03)), 0.0001)
|
| 67 |
+
of_bench_ws = [max(float(bench_weights.get(i, 0.0)), 0.0001) for i in [1, 2, 3]]
|
| 68 |
avg_of_bench_w = sum(of_bench_ws) / len(of_bench_ws) if of_bench_ws else 0.05
|
| 69 |
|
| 70 |
chip_gws: dict[int, str] = {}
|
|
|
|
| 344 |
prob += pulp.lpSum(transfer_in[p][w] for p in players) == 0
|
| 345 |
|
| 346 |
if chip == "fh":
|
| 347 |
+
# THE FIX: Decouple the Free Hit budget from the continuous bank!
|
| 348 |
+
# The new squad cost must simply be <= total wealth.
|
|
|
|
| 349 |
prob += itb[eff_prev] + pulp.lpSum(
|
| 350 |
fh_sell_price[p] * squad[p][eff_prev] for p in players
|
| 351 |
) >= pulp.lpSum(fh_sell_price[p] * squad[p][w] for p in players)
|
| 352 |
+
# The real bank is completely frozen and carries over untouched.
|
|
|
|
|
|
|
|
|
|
| 353 |
prob += itb[w] == itb[eff_prev]
|
| 354 |
else:
|
| 355 |
prob += (
|