optimizer
optimizer
¶
Squad optimization: two-level ILP, mean-variance, LP relaxation.
OptimizationResult
dataclass
¶
OptimizationResult(
full_squad: FullSquad,
objective_value: float = 0.0,
solve_time: float = 0.0,
lp_objective: Optional[float] = None,
integrality_gap: Optional[float] = None,
shadow_prices: dict = dict(),
binding_constraints: list = list(),
)
Container for optimization outputs including duality analysis.
TwoLevelILPOptimizer
¶
Bases: BaseOptimizer
Two-level ILP: select 15-player squad then 11-player lineup jointly.
Supports risk-neutral and risk-averse (mean-variance) objectives. Also exposes LP relaxation for shadow price extraction.
| PARAMETER | DESCRIPTION |
|---|---|
budget
|
Maximum total squad budget (applied to 15 players).
TYPE:
|
max_from_team
|
Maximum players from same club.
TYPE:
|
risk_aversion
|
Lambda for mean-variance penalty. 0 = risk-neutral.
TYPE:
|
Source code in fplx/selection/optimizer.py
solve
¶
optimize
¶
optimize(
players: list[Player],
expected_points: dict[int, float],
expected_variance: Optional[dict[int, float]] = None,
downside_risk: Optional[dict[int, float]] = None,
formation: Optional[str] = None,
) -> FullSquad
Solve the two-level ILP.
| PARAMETER | DESCRIPTION |
|---|---|
players
|
Available player pool.
TYPE:
|
expected_points
|
E[P_i] per player.
TYPE:
|
expected_variance
|
Var[P_i] per player.
TYPE:
|
downside_risk
|
Downside spread per player. If provided, risk penalty uses this directly (instead of sqrt(variance)).
TYPE:
|
formation
|
Not used (formation is optimized automatically).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FullSquad
|
|
Source code in fplx/selection/optimizer.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
solve_lp_relaxation
¶
solve_lp_relaxation(
players: list[Player],
expected_points: dict[int, float],
expected_variance: Optional[dict[int, float]] = None,
downside_risk: Optional[dict[int, float]] = None,
) -> OptimizationResult
Solve the LP relaxation and extract shadow prices.
| RETURNS | DESCRIPTION |
|---|---|
OptimizationResult
|
Contains LP objective, shadow prices, binding constraints. |
Source code in fplx/selection/optimizer.py
GreedyOptimizer
¶
Bases: BaseOptimizer
Greedy baseline: select best-value players per position.
Fast heuristic for comparison. Selects 15-player squad, then picks best 11 as lineup.
Source code in fplx/selection/optimizer.py
optimize
¶
optimize(
players: list[Player],
expected_points: dict[int, float],
expected_variance: Optional[dict[int, float]] = None,
formation: Optional[str] = None,
) -> FullSquad
Greedy squad + lineup selection.