EA FC Automated SBC Solving ⚽ 
This project utilizes integer programming to solve squad building challenges (SBCs). The optimization problem is solved using Google CP-SAT solver. This approach offers extensive customization capabilities, alongside the ability to determine solution optimality.
The goal is to obtain the squad with the minimum total cost.
-
To download the club dataset, use the extension (version >= 1.1.0.3).
-
The inputs to the different constraints can be found in the
input.py. Configure the appropriate inputs for each SBC constraint ininput.py(L43-77andL28-30) and then navigate tooptimize.py (L581-615)and uncomment the relevant line based on the SBC requirements. Also don't forget to set theformationininput.py! -
For example, if the requirement is
Same League Count: Max 5orMax 5 Players from the Same Leaguethen setMAX_NUM_LEAGUE = 5(L53ininput.py) and then uncommentmodel = create_max_league_constraint(df, model, player, map_idx, players_grouped, num_cnts)(L589inoptimize.py). -
If the requirement is
Nations: Max 2then setNUM_UNIQUE_COUNTRY = [2, "Max"](L62ininput.py) and then uncommentmodel = create_unique_country_constraint(df, model, player, map_idx, players_grouped, num_cnts)(L598inoptimize.py). -
If you are prioritizing duplicates by setting (
L28-L30) ininput.pythenmodel = prioritize_duplicates(df, model, player)inoptimize.py(L615) should be uncommented. -
If for instance, the SBC wants
at least 3 players from Real Madrid and Arsenal combinedandat least 2 players from Bayern Munich, then setCLUB = [["Real Madrid", "Arsenal"], ["FC Bayern"]]andNUM_CLUB = [3, 2](L43-44ininput.py) and then uncommentmodel = create_club_constraint(df, model, player, map_idx, players_grouped, num_cnts)(L581inoptimize.py). -
If the SBC requires at least
6 Rareand8 Goldthen setRARITY_2 = ["Rare", "Gold"]andNUM_RARITY_2 = [6, 8]ininput.py (L71-72)and then uncommentmodel = create_rarity_2_constraint(df, model, player, map_idx, players_grouped, num_cnts)(L603inoptimize.py). -
Constraints such as
Chemistry(optimize.py,L620) orFIX_PLAYERS(optimize.py,L623) do not require explicit activation. If there is no need forChemistry, set it to0ininput.py (L79). Similarly, if no players need fixing, leaveFIX_PLAYERSempty ininput.py (L12). -
The
objectiveis set inoptimize.py(L626). The nature of theobjectivecan be changed ininput.py(L20-21). Currently the objective is tominimizethetotal cost. -
Additional parameters in
input.pyshould be reviewed for more information. -
In
main.py, specify the name of theclub datasetinL57. The dataset is preprocessed inpreprocess_data_2withinmain.py. Additional filters can be added in a manner similar to the existing ones. -
Currently the inputs are set to solve this SBC challenge. The final list of players is written into the file
output.xlsx. To execute the program, simply runpy main.pyafter installing the required dependencies. Note: This seems to be a very hard SBC and so had to enable the filter on rating inmain.py (L41).
Run pip3 install -r requirements.txt to install the required dependencies.
-
Python 3.9
-
pandas and openpyxl
-
https://github.com/bartlomiej-niemiec/eafc-sbc-solver
-
https://github.com/kosciukiewicz/sbc-solver
Thank you GregoryWullimann for making the model creation process insanely faster.
Thank you Jacobi from EasySBC for helping with the squad_rating_constraint.
Thank you GeekFiro for testing the solver and providing valuable feedback and discussions.
Thank you fifagamer#1515 and Frederik for providing your club datasets (Real_Madrid_FC_24.csv and Frederik FC_24.csv) and your feedback.
Thank you ckalgos for creating the extension to download club dataset.
Thank you drRobertDev for providing the dataset Fc25Players.csv.
Thank you to everyone who have opened issues on the repo and provided their feedback.
Thank you to all the folks who commented on the reddit post.
Thank you FutDB for providing the API which allowed me to test the solver originally on 10k players (input.csv)