https://github.com/fpgmaas/squadsub
Python code that helps you optimize your substitution strategy during a match
https://github.com/fpgmaas/squadsub
cplex operations-research optimization optimization-algorithms python sports
Last synced: about 1 month ago
JSON representation
Python code that helps you optimize your substitution strategy during a match
- Host: GitHub
- URL: https://github.com/fpgmaas/squadsub
- Owner: fpgmaas
- Created: 2018-10-31T10:19:46.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-09-23T06:41:40.000Z (about 5 years ago)
- Last Synced: 2025-07-09T13:09:49.826Z (3 months ago)
- Topics: cplex, operations-research, optimization, optimization-algorithms, python, sports
- Language: Python
- Homepage:
- Size: 600 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## The Squad Substitution Optimization Problem

### Problem definition
During a football match, players can be substituted. Different players have different skills, so not every substitution is beneficial to the team performance. This raises the question; which *player* should play at which *position* at which *time* such that the team performance is optimal? In this repository, a solution approach is proposed and implemented.
Obviously, the optimal strategy would be to create one optimal squad and have that squad play during the entire match, but that would mean some players do not get to play at all. Therefore, we make the assumption of fairness; players should play an approximately equal amount of time. We also assume that players are not allowed to change positions on the pitch without substituting in between, since that could lead to a lot of confusion on the pitch.
### Solution approachThis problem can be solved by modelling it as a Linear Programming problem. The input for this LP is the skillmatrix, containing the skills of a set of players at a set of positions.
| | Left Back | Right Midfielder | Striker |
| -------- | ---------- | ---------- | ---------- |
| Wall-E | 5 | 3 | 3 |
| Eve | 1 | 5 | 5 |
| Mike Mazowski | 3 | 3 | 3 |
| James P. Sullivan | 2 | 5 | 2 |To model this problem, the match is split up into *w* periods of equal length. The decision variables for this LP problem can then be defined as *xpqw* , where *xpqw* is 1 if player *p* plays at position *q* during time window *w* and 0 otherwise. The entire formulation can be found [here.](https://github.com/flo12392/squadsub/blob/master/formulation/formulation.pdf)
### How to run?
- First, edit the file in *data/skillmatrix.csv* so it contains the skillmatrix of your team.
- Make sure you have [PuLP](https://pythonhosted.org/PuLP/main/installing_pulp_at_home.html) installed.
- run *main.py*
- When the script is done running, the solutions to your problem can be found in the *results* folder. An example of a resulting file can be found [here](https://github.com/flo12392/squadsub/blob/master/results/example_result.txt).