Regista6 / EA-FC-24-Automated-SBC-Solving

EA FC 24 Automated SBC Solving using Integer Programming ⚽
MIT License
31 stars 7 forks source link

UNKNOWN: Simple Input #7

Open carterlasalle opened 8 months ago

carterlasalle commented 8 months ago

Hey!

Thanks so much for making this. It looks awesome. Im simply trying to create a config for an 86 squad with at least 1 prem player. How can I do this. I keep getting unknown. Thanks @Regista6 !

I only have these two uncommented. 
`model = create_league_constraint(df, model, player, map_idx, players_grouped, num_cnts)`
`model = create_league_constraint(df, model, player, map_idx, players_grouped, num_cnts)`

My config:
 `FORMATION = "4-3-2-1"
USE_PREFERRED_POSITION = False  
USE_ALTERNATE_POSITIONS = True

NUM_PLAYERS = 11 

FIX_PLAYERS = 1

LEAGUE = [["Premier League"]]
NUM_LEAGUE = [1]  

SQUAD_RATING = 86

# Comment out other constraints 
CLUB = []  
NUM_CLUB = []

COUNTRY = []
NUM_COUNTRY = []

RARITY_1 = []
NUM_RARITY_1 = []

RARITY_2 = []
NUM_RARITY_2 = []

MIN_OVERALL = []
NUM_MIN_OVERALL = []

MAX_NUM_CLUB = 0  
MIN_NUM_CLUB = 0
NUM_UNIQUE_CLUB = [0, "Exactly"]

MAX_NUM_LEAGUE = 0 
MIN_NUM_LEAGUE = 0
NUM_UNIQUE_LEAGUE = [0, "Exactly"]

MAX_NUM_COUNTRY = 0
MIN_NUM_COUNTRY = 0 
NUM_UNIQUE_COUNTRY = [0, "Exactly"]

CHEMISTRY = 0
CHEM_PER_PLAYER = 0

'''INPUTS'''

formation_dict = {
    "3-4-1-2": ["GK", "CB", "CB", "CB", "LM", "CM", "CM", "RM", "CAM", "ST", "ST"],
    "3-4-2-1": ["GK", "CB", "CB", "CB", "LM", "CM", "CM", "RM", "CF", "ST", "CF"],
    "3-1-4-2": ["GK", "CB", "CB", "CB", "LM", "CM", "CDM", "CM", "RM", "ST", "ST"],
    "3-4-3": ["GK", "CB", "CB", "CB", "LM", "CM", "CM", "RM", "CAM", "ST", "ST"],
    "3-5-2": ["GK", "CB", "CB", "CB", "CDM", "CDM", "LM", "CAM", "RM", "ST", "ST"],
    "3-4-3": ["GK", "CB", "CB", "CB", "LM", "CM", "CM", "RM", "LW", "ST", "RW"],
    "4-1-2-1-2": ["GK", "LB", "CB", "CB", "RB", "CDM", "LM", "CAM", "RM", "ST", "ST"],
    "4-1-2-1-2[2]": ["GK", "LB", "CB", "CB", "RB", "CDM", "CM", "CAM", "CM", "ST", "ST"],
    "4-1-4-1": ["GK", "LB", "CB", "CB", "RB", "CDM", "LM", "CM", "CM", "RM", "ST"],
    "4-2-1-3": ["GK", "LB", "CB", "CB", "RB", "CDM", "CDM", "CAM", "LW", "ST", "RW"],
    "4-2-3-1": ["GK", "LB", "CB", "CB", "RB", "CDM", "CDM", "CAM", "CAM", "CAM", "ST"],
    "4-2-3-1[2]": ["GK", "LB", "CB", "CB", "RB", "CDM", "CDM", "CAM", "LM", "ST", "RM"],
    "4-2-2-2": ["GK", "LB", "CB", "CB", "RB", "CDM", "CDM", "CAM", "CAM", "ST", "ST"],
    "4-2-4": ["GK", "LB", "CB", "CB", "RB", "CM", "CM", "LW", "ST", "ST", "RW"],
    "4-3-1-2": ["GK", "CB", "CB", "LB", "RB", "CM", "CM", "CM", "CAM", "ST", "ST"],
    "4-1-3-2": ["GK", "LB", "CB", "CB", "RB", "CDM", "LM", "CM", "RM", "ST", "ST"],
    "4-3-2-1": ["GK", "LB", "CB", "CB", "RB", "CM", "CM", "CM", "CF", "ST", "CF"],
    "4-3-3": ["GK", "LB", "CB", "CB", "RB", "CM", "CM", "CM", "LW", "ST", "RW"],
    "4-3-3[2]": ["GK", "LB", "CB", "CB", "RB", "CM", "CDM", "CM", "LW", "ST", "RW"],
    "4-3-3[3]": ["GK", "LB", "CB", "CB", "RB", "CDM", "CDM", "CM", "LW", "ST", "RW"],
    "4-3-3[4]": ["GK", "LB", "CB", "CB", "RB", "CM", "CM", "CAM", "LW", "ST", "RW"],
    "4-3-3[5]": ["GK", "LB", "CB", "CB", "RB", "CDM", "CM", "CM", "LW", "CF", "RW"],
    "4-4-1-1": ["GK", "LB", "CB", "CB", "RB", "CM", "CM", "LM", "CF", "RM", "ST"],
    "4-4-1-1[2]": ["GK", "LB", "CB", "CB", "RB", "CM", "CM", "LM", "CAM", "RM", "ST"],
    "4-4-2": ["GK", "LB", "CB", "CB", "RB", "LM", "CM", "CM", "RM", "ST", "ST"],
    "4-4-2[2]": ["GK", "LB", "CB", "CB", "RB", "LM", "CDM", "CDM", "RM", "ST", "ST"],
    "4-5-1": ["GK", "CB", "CB", "LB", "RB", "CM", "LM", "CAM", "CAM", "RM", "ST"],
    "4-5-1[2]": ["GK", "CB", "CB", "LB", "RB", "CM", "LM", "CM", "CM", "RM", "ST"],
    "5-2-1-2":["GK", "LWB", "CB", "CB", "CB", "RWB", "CM", "CM", "CAM", "ST", "ST"],
    "5-2-2-1": ["GK", "LWB", "CB", "CB", "CB", "RWB", "CM", "CM", "LW", "ST", "RW"],
    "5-3-2": ["GK", "LWB", "CB", "CB", "CB", "RWB", "CM", "CDM", "CM", "ST", "ST"],
    "5-4-1": ["GK", "LWB", "CB", "CB", "CB", "RWB", "CM", "CM", "LM", "RM", "ST"]
    }

status_dict = {
    0: "UNKNOWN: The status of the model is still unknown. A search limit has been reached before any of the statuses below could be determined.",
    1: "MODEL_INVALID: The given CpModelProto didn't pass the validation step.",
    2: "FEASIBLE: A feasible solution has been found. But the search was stopped before we could prove optimality.",
    3: "INFEASIBLE: The problem has been proven infeasible.",
    4: "OPTIMAL: An optimal feasible solution has been found."
}

def calc_squad_rating(rating):
    '''https://www.reddit.com/r/EASportsFC/comments/5osq7k/new_overall_rating_figured_out'''
    rat_sum = sum(rating)
    avg_rat = rat_sum / NUM_PLAYERS
    excess = sum(max(rat - avg_rat, 0) for rat in rating)
    return round(rat_sum + excess) // NUM_PLAYERS

LOG_RUNTIME = True
`
carterlasalle commented 8 months ago

@Regista6 Actually I got it working, but its not optimizing


'''INPUTS'''

FORMATION = "4-3-2-1"

NUM_PLAYERS = 11

FIX_PLAYERS = 0  # FIX_PLAYERS = 1 => players will be picked based on the formation and 0 otherwise.

# Set only one of the below to True and the other to False. Both can't be False.
USE_PREFERRED_POSITION = False
USE_ALTERNATE_POSITIONS = True

# Set only one of the below to True and the others to False if duplicates are to be prioritized.
USE_ALL_DUPLICATES = False
USE_AT_LEAST_HALF_DUPLICATES = False
USE_AT_LEAST_ONE_DUPLICATE = False

LEAGUE = [["Premier League"]]
NUM_LEAGUE = [1]  # Exactly 1 player from Premier League

MIN_OVERALL = [86]
NUM_MIN_OVERALL = [11]  # All players should have a minimum OVR of 86

SQUAD_RATING = 86  # Squad Rating: Min 86

CHEMISTRY = 0  # Squad Total Chemistry Points: Min X
               # If there is no constraint on total chemistry, then set this to 0.

CHEM_PER_PLAYER = 0  # Chemistry Points Per Player: Min X.` 

OUTPUT:
`Processing time create_var: 0.01 seconds
Processing time create_basic_constraints: 0.0 seconds
Processing time create_league_constraint: 0.0 seconds
Processing time create_squad_rating_constraint_2: 0.08 seconds
Processing time create_chemistry_constraint: 0.05 seconds
Processing time set_objective: 0.0 seconds
Solve Started

Starting CP-SAT solver v9.7.2996
Parameters: max_time_in_seconds: 600 log_search_progress: true num_search_workers: 8

Initial optimization model '': (model_fingerprint: 0xdf950cf225fe2571)
#Variables: 1'916 (#bools: 158 in objective)
  - 1'354 Booleans in [0,1]
  - 404 in [0,3]
  - 158 in [0,70]
#kExactlyOne: 88 (#literals: 352)
#kIntProd: 668
#kLinMax: 158 (#expressions: 316)
#kLinear0: 16 (#enforced: 16)
#kLinear1: 883 (#enforced: 726)
#kLinear2: 127 (#enforced: 84)
#kLinear3: 234 (#enforced: 220)
#kLinearN: 182 (#enforced: 168) (#terms: 1'744)

Starting presolve at 0.00s
[ExtractEncodingFromLinear] #potential_supersets=38 #potential_subsets=0 #at_most_one_encodings=0 #exactly_one_encodings=0 #unique_terms=0 #multiple_terms=0 #literals=0 time=2.127e-05s
[SAT presolve] num removable Booleans: 867 / 1916
[SAT presolve] num trivial clauses: 0
[SAT presolve] [0s] clauses:1537 literals:3670 vars:701 one_side_vars:43 simple_definition:359 singleton_clauses:0
[SAT presolve] [0.0001525s] clauses:1525 literals:3586 vars:701 one_side_vars:43 simple_definition:359 singleton_clauses:0
[SAT presolve] [0.00051287s] clauses:1304 literals:3128 vars:604 one_side_vars:44 simple_definition:326 singleton_clauses:0
[Probing] implications and bool_or (work_done=66207).
[MaxClique] Merged 907(1858 literals) into 395(834 literals) at_most_ones. time=0.00078376s
[DetectDuplicateConstraints] #duplicates=265 #without_enforcements=65 time=0.00179708s
[DetectDominatedLinearConstraints] #relevant_constraints=5 #work_done=2222 #num_inclusions=1 #num_redundant=0 time=6.304e-05s
[ProcessSetPPC] #relevant_constraints=526 #num_inclusions=354 work=27564 time=0.00075596s
[FindBigHorizontalLinearOverlap] #blocks=0 #saved_nz=0 #linears=48 #work_done=23264/1e+09 time=0.00011919s
[FindBigVerticalLinearOverlap] #blocks=1 #nz_reduction=24 #work_done=162756 time=0.00034801s
[MergeClauses] #num_collisions=18 #num_merges=18 #num_saved_literals=40 work=523/100000000 time=0.00010899s
[SAT presolve] num removable Booleans: 1215 / 1917
[SAT presolve] num trivial clauses: 0
[SAT presolve] [0s] clauses:493 literals:1142 vars:383 one_side_vars:154 simple_definition:131 singleton_clauses:0
[SAT presolve] [0.0001301s] clauses:487 literals:1125 vars:383 one_side_vars:154 simple_definition:131 singleton_clauses:0
[SAT presolve] [0.00044299s] clauses:398 literals:921 vars:341 one_side_vars:156 simple_definition:122 singleton_clauses:0
[Probing] implications and bool_or (work_done=57999).
[MaxClique] Merged 358(760 literals) into 319(713 literals) at_most_ones. time=0.00084823s
[DetectDuplicateConstraints] #duplicates=33 #without_enforcements=30 time=0.00213823s
[DetectDominatedLinearConstraints] #relevant_constraints=6 #work_done=2231 #num_inclusions=1 #num_redundant=0 time=5.944e-05s
[ProcessSetPPC] #relevant_constraints=387 #num_inclusions=182 work=25129 time=0.00095384s
[FindBigHorizontalLinearOverlap] #blocks=0 #saved_nz=0 #linears=48 #work_done=23264/1e+09 time=0.00011659s
[FindBigVerticalLinearOverlap] #blocks=0 #nz_reduction=0 #work_done=160803 time=0.000334s
[MergeClauses] #num_collisions=20 #num_merges=20 #num_saved_literals=42 work=221/100000000 time=8.91e-05s
[SAT presolve] num removable Booleans: 1247 / 1917
[SAT presolve] num trivial clauses: 0
[SAT presolve] [0s] clauses:333 literals:765 vars:307 one_side_vars:187 simple_definition:78 singleton_clauses:0
[SAT presolve] [8.447e-05s] clauses:327 literals:753 vars:307 one_side_vars:187 simple_definition:78 singleton_clauses:0
[SAT presolve] [0.00026847s] clauses:327 literals:753 vars:307 one_side_vars:187 simple_definition:78 singleton_clauses:0
[Probing] implications and bool_or (work_done=57420).
[MaxClique] Merged 298(655 literals) into 258(593 literals) at_most_ones. time=0.00055135s
[DetectDuplicateConstraints] #duplicates=0 #without_enforcements=33 time=0.00153481s
[DetectDominatedLinearConstraints] #relevant_constraints=6 #work_done=2231 #num_inclusions=1 #num_redundant=0 time=7.152e-05s
[ProcessSetPPC] #relevant_constraints=389 #num_inclusions=178 work=25105 time=0.00061105s
[FindBigHorizontalLinearOverlap] #blocks=0 #saved_nz=0 #linears=48 #work_done=23264/1e+09 time=0.00011494s
[FindBigVerticalLinearOverlap] #blocks=0 #nz_reduction=0 #work_done=160767 time=0.00032618s
[MergeClauses] #num_collisions=20 #num_merges=20 #num_saved_literals=42 work=219/100000000 time=0.00011822s
[ExpandObjective] #propagations=0 #entries=112 #tight_variables=44 #tight_constraints=13 #expands=0 #issues=0 time=0.00014449s

Presolve summary:
  - 394 affine relations were detected.
  - rule 'TODO dual: add implied bound' was applied 902 times.
  - rule 'TODO dual: only one blocking constraint?' was applied 2752 times.
  - rule 'TODO dual: only one blocking enforced constraint?' was applied 902 times.
  - rule 'TODO dual: tighten at most one' was applied 125 times.
  - rule 'TODO duplicate: identical constraint with different enforcements' was applied 128 times.
  - rule 'TODO lin_max: linear expression above max.' was applied 1580 times.
  - rule 'TODO linear2: contains a Boolean.' was applied 362 times.
  - rule 'affine: new relation' was applied 394 times.
  - rule 'at_most_one: removed literals' was applied 103 times.
  - rule 'at_most_one: size one' was applied 103 times.
  - rule 'at_most_one: transformed into max clique.' was applied 3 times.
  - rule 'bool_and: fixed literals' was applied 1 time.
  - rule 'bool_and: removed duplicate literal' was applied 1 time.
  - rule 'bool_and: x => x' was applied 163 times.
  - rule 'bool_or: always true' was applied 64 times.
  - rule 'bool_or: implications' was applied 62 times.
  - rule 'bool_or: only one literal' was applied 191 times.
  - rule 'bool_or: removed enforcement literal' was applied 86 times.
  - rule 'deductions: 748 stored' was applied 1 time.
  - rule 'dual: add implication' was applied 12 times.
  - rule 'dual: enforced equivalence' was applied 63 times.
  - rule 'dual: fix variable' was applied 1 time.
  - rule 'dual: reduced domain' was applied 1 time.
  - rule 'duplicate: removed constraint' was applied 298 times.
  - rule 'enforcement: false literal' was applied 262 times.
  - rule 'enforcement: true literal' was applied 100 times.
  - rule 'exactly_one: removed literals' was applied 83 times.
  - rule 'exactly_one: size one' was applied 36 times.
  - rule 'exactly_one: size two' was applied 36 times.
  - rule 'exactly_one: x and not(x)' was applied 4 times.
  - rule 'incompatible linear: add implication' was applied 291 times.
  - rule 'int_prod: all Boolean.' was applied 440 times.
  - rule 'int_prod: constant product' was applied 141 times.
  - rule 'int_prod: expanded product with Boolean var' was applied 87 times.
  - rule 'int_prod: removed constant expressions.' was applied 211 times.
  - rule 'lin_max: target domain reduced' was applied 158 times.
  - rule 'linear + amo: added implications' was applied 7 times.
  - rule 'linear + amo: extracted enforcement literal' was applied 12 times.
  - rule 'linear + amo: fixed literal implied by enforcement' was applied 8 times.
  - rule 'linear matrix: common vertical rectangle' was applied 1 time.
  - rule 'linear1: is boolean implication' was applied 109 times.
  - rule 'linear2: implied ax + by = cte has only one solution' was applied 40 times.
  - rule 'linear: always true' was applied 42 times.
  - rule 'linear: empty' was applied 177 times.
  - rule 'linear: fixed or dup variables' was applied 560 times.
  - rule 'linear: infeasible' was applied 4 times.
  - rule 'linear: negative clause' was applied 70 times.
  - rule 'linear: positive at most one' was applied 21 times.
  - rule 'linear: positive clause' was applied 2 times.
  - rule 'linear: positive reified and' was applied 13 times.
  - rule 'linear: reduced variable domains' was applied 177 times.
  - rule 'linear: remapped using affine relations' was applied 218 times.
  - rule 'linear: simplified rhs' was applied 374 times.
  - rule 'linear: small Boolean expression' was applied 17 times.
  - rule 'linear: variable substitution 1' was applied 16 times.
  - rule 'presolve: 834 unused variables removed.' was applied 1 time.
  - rule 'presolve: iteration' was applied 3 times.
  - rule 'probing: bool_or reduced to implication' was applied 20 times.
  - rule 'probing: simplified clauses.' was applied 23 times.
  - rule 'probing: simplified enforcement list.' was applied 1 time.
  - rule 'setppc: bool_or in at_most_one.' was applied 20 times.
  - rule 'variables: detect half reified value encoding' was applied 487 times.

Presolved optimization model '': (model_fingerprint: 0xb4052d02ac0f790c)
#Variables: 673 (#bools: 158 in objective)
  - 358 Booleans in [0,1]
  - 6 in [0][8,70]
  - 43 in [0][22,70]
  - 13 in [0,2]
  - 143 in [0,3]
  - 1 in [0,6]
  - 49 in [0,10][32,70]
  - 23 in [0,20][42,70]
  - 25 in [0,30][52,70]
  - 4 in [0,40][62,70]
  - 6 in [0,50]
  - 2 in [0,60]
#kAtMostOne: 33 (#literals: 127)
#kBoolAnd: 245 (#enforced: 245 #multi: 17) (#literals: 566)
#kBoolOr: 23 (#literals: 104)
#kExactlyOne: 12 (#literals: 42)
#kLinMax: 158 (#expressions: 316)
#kLinear1: 214 (#enforced: 214 #multi: 6)
#kLinear2: 105 (#enforced: 105)
#kLinear3: 75 (#enforced: 74)
#kLinearN: 85 (#enforced: 80) (#terms: 1'134)

Preloading model.
#Bound   0.50s best:inf   next:[0,946250] initial_domain
#Model   0.50s var:673/673 constraints:950/950

Starting search at 0.50s with 8 workers.
6 full problem subsolvers: [core, default_lp, max_lp, no_lp, pseudo_costs, reduced_costs]
1 first solution subsolver: [jump]
8 incomplete subsolvers: [feasibility_pump, graph_arc_lns, graph_cst_lns, graph_dec_lns, graph_var_lns, rins/rens, rnd_cst_lns, rnd_var_lns]
3 helper subsolvers: [neighborhood_helper, synchronization_agent, update_gap_integral]
#Bound   0.97s best:inf   next:[7650,946250] default_lp
#Bound   1.05s best:inf   next:[7700,946250] reduced_costs
#Model  87.57s var:671/673 constraints:950/950
#1      88.93s best:120300 next:[7700,120250] rens_lp_lns(d=0.87 s=230 t=0.10 p=0.56 stall=0)
#2      94.81s best:117000 next:[7700,116950] rnd_var_lns(d=0.50 s=231 t=0.10 p=0.00 stall=0)
#Model  96.42s var:661/673 constraints:938/950
#Model 107.79s var:660/673 constraints:938/950
#Bound 109.86s best:117000 next:[7750,116950] reduced_costs
#3     144.53s best:107100 next:[7750,107050] rnd_cst_lns(d=0.50 s=232 t=0.10 p=0.00 stall=0)
#Bound 151.14s best:107100 next:[7800,107050] max_lp
#Model 151.21s var:655/673 constraints:938/950
#Model 156.21s var:653/673 constraints:938/950
#Model 161.63s var:651/673 constraints:938/950
#Bound 163.81s best:107100 next:[7850,107050] reduced_costs
#Model 170.35s var:650/673 constraints:938/950
#Bound 193.31s best:107100 next:[7900,107050] max_lp
#Model 193.32s var:649/673 constraints:938/950
60 seconds without improvement in objective. 

Task timing                        n [     min,      max]      avg      dev     time         n [     min,      max]      avg      dev    dtime
  'synchronization_agent':         0 [  0.00ns,   0.00ns]   0.00ns   0.00ns   0.00ns         0 [  0.00ns,   0.00ns]   0.00ns   0.00ns   0.00ns
    'neighborhood_helper':         0 [  0.00ns,   0.00ns]   0.00ns   0.00ns   0.00ns         0 [  0.00ns,   0.00ns]   0.00ns   0.00ns   0.00ns
             'default_lp':         1 [   3.40m,    3.40m]    3.40m   0.00ns    3.40m         1 [  12.08s,   12.08s]   12.08s   0.00ns   12.08s
                  'no_lp':         1 [   3.40m,    3.40m]    3.40m   0.00ns    3.40m         1 [  18.48s,   18.48s]   18.48s   0.00ns   18.48s
                 'max_lp':         1 [   3.40m,    3.40m]    3.40m   0.00ns    3.40m         1 [  23.62s,   23.62s]   23.62s   0.00ns   23.62s
                   'core':         1 [   3.40m,    3.40m]    3.40m   0.00ns    3.40m         1 [  16.53s,   16.53s]   16.53s   0.00ns   16.53s
          'reduced_costs':         1 [   3.40m,    3.40m]    3.40m   0.00ns    3.40m         1 [  10.57s,   10.57s]   10.57s   0.00ns   10.57s
           'pseudo_costs':         1 [   3.40m,    3.40m]    3.40m   0.00ns    3.40m         1 [  24.38s,   24.38s]   24.38s   0.00ns   24.38s
       'feasibility_pump':       112 [303.07us,  97.62ms]   1.88ms  10.45ms 211.07ms       111 [183.04us,  10.33ms] 274.45us 958.70us  30.46ms
              'rins/rens':       112 [140.57us,    9.94s] 783.49ms    2.41s    1.46m        11 [277.75us, 100.17ms]  72.92ms  44.29ms 802.15ms
            'rnd_var_lns':         2 [ 18.50ms,    5.88s]    2.95s    2.93s    5.90s         1 [100.10ms, 100.10ms] 100.10ms   0.00ns 100.10ms
            'rnd_cst_lns':         2 [939.85ms,   49.74s]   25.34s   24.40s   50.68s         2 [ 65.90us,  35.22ms]  17.64ms  17.58ms  35.28ms
          'graph_var_lns':         1 [   6.25s,    6.25s]    6.25s   0.00ns    6.25s         1 [100.01ms, 100.01ms] 100.01ms   0.00ns 100.01ms
          'graph_arc_lns':         1 [   6.40s,    6.40s]    6.40s   0.00ns    6.40s         1 [100.01ms, 100.01ms] 100.01ms   0.00ns 100.01ms
          'graph_cst_lns':         1 [  46.31s,   46.31s]   46.31s   0.00ns   46.31s         1 [100.02ms, 100.02ms] 100.02ms   0.00ns 100.02ms
          'graph_dec_lns':         1 [ 80.48ms,  80.48ms]  80.48ms   0.00ns  80.48ms         1 [  4.94us,   4.94us]   4.94us   0.00ns   4.94us
    'update_gap_integral':         0 [  0.00ns,   0.00ns]   0.00ns   0.00ns   0.00ns         0 [  0.00ns,   0.00ns]   0.00ns   0.00ns   0.00ns

Search stats        Bools  Conflicts  Branches  Restarts  BoolPropag  IntegerPropag
     'default_lp':    532     81'090   185'359     1'801   4'919'042      8'848'063
          'no_lp':    532    109'806   272'520     2'238   2'320'415      7'770'476
         'max_lp':    690      1'103     5'199     1'082      32'043         76'398
           'core':    532    114'708   277'308     1'065   2'772'134      7'711'895
  'reduced_costs':    690      4'409    11'024     1'110     652'389      1'235'589
   'pseudo_costs':    692        858     4'881     1'078      34'820         70'700

LNS stats           Improv/Calls  Closed  Difficulty  TimeLimit
      'rins/rens':         17/17     53%        0.83       0.10
    'rnd_var_lns':           1/2     50%        0.46       0.10
    'rnd_cst_lns':           2/2     50%        0.54       0.10
  'graph_var_lns':           0/1      0%        0.29       0.10
  'graph_arc_lns':           0/1      0%        0.29       0.10
  'graph_cst_lns':           0/1      0%        0.29       0.10
  'graph_dec_lns':           0/1    100%        0.71       0.10

Solutions (3)     Num   Rank
  'rens_lp_lns':    1  [1,1]
  'rnd_cst_lns':    1  [3,3]
  'rnd_var_lns':    1  [2,2]

Objective bounds     Num
      'default_lp':    1
  'initial_domain':    1
          'max_lp':    2
   'reduced_costs':    3

Solution repositories    Added  Queried  Ignored  Synchro
  'feasible solutions':      5       16        0        5
        'lp solutions':    176       16        0      172
                'pump':    111       96

Improving bounds shared    Num
                'max_lp':   64
          'pseudo_costs':   41
         'reduced_costs':   83

Clauses shared    Num
   'default_lp':    1

CpSolverResponse summary:
status: FEASIBLE
objective: 107100
best_bound: 7900
integers: 613
booleans: 532
conflicts: 81090
branches: 185359
propagations: 4919042
integer_propagations: 8848063
restarts: 1801
lp_iterations: 74382
walltime: 204.612
usertime: 204.612
deterministic_time: 109.097
gap_integral: 1256.47
solution_fingerprint: 0x8bbf9ed16336bff0

FEASIBLE: A feasible solution has been found. But the search was stopped before we could prove optimality.

Processing time SBC: 204.77 seconds
Total Chemistry: 2
Squad Rating: 86
Total Cost: 107100
Regista6 commented 8 months ago

Hi, Thanks so much for using the repo πŸ™. Just for completeness, for your requirement, set formation, SQUAD_RATING = 86 # Squad Rating: Min XX and
LEAGUE = [["Premier League"]] and NUM_LEAGUE = [1]. Then comment out everything (L530-566) in optimize.py except create_squad_rating_constraint_3 and create_league_constraint. Also, change Chemistry = 0 as there is no requirement on chemistry.

Can you send your club.csv?

status: FEASIBLE objective: 107100 best_bound: 7900 This is pretty bad. Can you try uncommenting df = df[(df["Rating"] >= input.SQUAD_RATING - 3) & (df["Rating"] <= input.SQUAD_RATING + 3)] in main.py?

Edit: I think you have mistakenly set Processing time create_squad_rating_constraint_2: 0.08 seconds!

carterlasalle commented 8 months ago

@Regista6 Thanks so much for the writeback.

I am trying it on Trailblazers Challenge 5:

input.py: https://gist.github.com/RocketNinja15/2a048dcd18ee40484099b343db825cd8

optimize.py: https://gist.github.com/RocketNinja15/fcf3d3d12d8d89b9612d7a68178fedde

Requirements: Min. Leagues in Squad: 4 Min. 3 Players from the same Nation Min. 2 Players from the same Club Min. 9 Players: Rare Min. Team Rating: 80 Min 31 Squad Total Chemistry Points Number of Players in the Squad: 11 4-3-3[5]

Current output:

# This will create the directory 'FIFA-23-Automated-SBC-Solving'.
!git clone https://github.com/Regista6/EA-FC-24-Automated-SBC-Solving

Cloning into 'EA-FC-24-Automated-SBC-Solving'...
remote: Enumerating objects: 190, done.
remote: Counting objects: 100% (169/169), done.
remote: Compressing objects: 100% (119/119), done.
remote: Total 190 (delta 105), reused 95 (delta 48), pack-reused 21
Receiving objects: 100% (190/190), 2.50 MiB | 18.52 MiB/s, done.
Resolving deltas: 100% (109/109), done.

%cd /content/EA-FC-24-Automated-SBC-Solving

/content/EA-FC-24-Automated-SBC-Solving

!pip3 install -r requirements.txt

Requirement already satisfied: pandas>=1.5.2 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 1)) (1.5.3)
Requirement already satisfied: openpyxl>=3.1 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 2)) (3.1.2)
Collecting ortools>=9.7 (from -r requirements.txt (line 3))
  Downloading ortools-9.7.2996-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 21.1/21.1 MB 52.1 MB/s eta 0:00:00
Requirement already satisfied: python-dateutil>=2.8.1 in /usr/local/lib/python3.10/dist-packages (from pandas>=1.5.2->-r requirements.txt (line 1)) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas>=1.5.2->-r requirements.txt (line 1)) (2023.3.post1)
Requirement already satisfied: numpy>=1.21.0 in /usr/local/lib/python3.10/dist-packages (from pandas>=1.5.2->-r requirements.txt (line 1)) (1.23.5)
Requirement already satisfied: et-xmlfile in /usr/local/lib/python3.10/dist-packages (from openpyxl>=3.1->-r requirements.txt (line 2)) (1.1.0)
Requirement already satisfied: absl-py>=0.13 in /usr/local/lib/python3.10/dist-packages (from ortools>=9.7->-r requirements.txt (line 3)) (1.4.0)
Collecting protobuf>=4.23.3 (from ortools>=9.7->-r requirements.txt (line 3))
  Downloading protobuf-4.24.4-cp37-abi3-manylinux2014_x86_64.whl (311 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 311.6/311.6 kB 32.8 MB/s eta 0:00:00
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.1->pandas>=1.5.2->-r requirements.txt (line 1)) (1.16.0)
Installing collected packages: protobuf, ortools
  Attempting uninstall: protobuf
    Found existing installation: protobuf 3.20.3
    Uninstalling protobuf-3.20.3:
      Successfully uninstalled protobuf-3.20.3
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow-metadata 1.14.0 requires protobuf<4.21,>=3.20.3, but you have protobuf 4.24.4 which is incompatible.
Successfully installed ortools-9.7.2996 protobuf-4.24.4

Processing time create_var: 0.03 seconds
Processing time create_basic_constraints: 0.01 seconds
Processing time create_min_club_constraint: 0.01 seconds
Processing time create_min_league_constraint: 0.01 seconds
Processing time create_min_country_constraint: 0.01 seconds
Processing time create_rarity_1_constraint: 0.0 seconds
Processing time create_squad_rating_constraint_3: 0.04 seconds
Processing time create_chemistry_constraint: 0.15 seconds
Processing time set_objective: 0.0 seconds
Solve Started

Starting CP-SAT solver v9.7.2996
Parameters: max_time_in_seconds: 600 log_search_progress: true num_search_workers: 8

Initial optimization model '': (model_fingerprint: 0xeb5cb57c7f66506f)
#Variables: 4'139 (#bools: 264 in objective)
  - 2'655 Booleans in [0,1]
  - 701 in [0,3]
  - 27 in [0,11]
  - 27 in [0,1500]
  - 729 in [0,15000]
#kBoolOr: 3 (#literals: 173)
#kExactlyOne: 173 (#literals: 692)
#kIntProd: 1'917
#kLinMax: 27 (#expressions: 54)
#kLinear0: 1
#kLinear1: 1'752 (#enforced: 1'525)
#kLinear2: 323 (#enforced: 254)
#kLinear3: 462 (#enforced: 432)
#kLinearN: 482 (#enforced: 443) (#terms: 4'051)

Starting presolve at 0.00s
INFEASIBLE: ''

Presolve summary:
  - 0 affine relations were detected.
Problem closed by presolve.
CpSolverResponse summary:
status: INFEASIBLE
objective: NA
best_bound: NA
integers: 0
booleans: 0
conflicts: 0
branches: 0
propagations: 0
integer_propagations: 0
restarts: 0
lp_iterations: 0
walltime: 0.00620084
usertime: 0.00620111
deterministic_time: 0
gap_integral: 0

INFEASIBLE: The problem has been proven infeasible.

Processing time SBC: 0.27 seconds

Here is my club file: DonaldTrumpet.csv

Regista6 commented 8 months ago
# input.py
FORMATION = "4-3-3[5]"

NUM_PLAYERS = 11

FIX_PLAYERS  = 0 # FIX_PLAYERS = 1 => players will be picked based on the formation and 0 otherwise.

# Set only one of the below to True and the other to False. Both can't be False.
USE_PREFERRED_POSITION = False
USE_ALTERNATE_POSITIONS = True

# Set only one of the below to True and the others to False if duplicates are to be prioritized.
USE_ALL_DUPLICATES = False
USE_AT_LEAST_HALF_DUPLICATES = False
USE_AT_LEAST_ONE_DUPLICATE = False

NUM_UNIQUE_LEAGUE = [4, "Min"] # Leagues: Max / Min / Exactly X  (Min. Leagues in Squad: 4)

MIN_NUM_COUNTRY = 3  # Same Nation Count: Min X (Min. 3 Players from the same Nation)

MIN_NUM_CLUB = 2  # Same Club Count: Min X (Min. 2 Players from the same Club)

RARITY_2 = ["Rare"]  # (Min. 9 Players: Rare)
NUM_RARITY_2 = [9]   # Total players from i^th Rarity >= NUM_RARITY_2[i]

SQUAD_RATING = 80 # Squad Rating: Min XX

CHEMISTRY = 31  # Squad Total Chemistry Points: Min X

# optimize.py (These constraints should be enabled) (L530-566)

model = create_min_club_constraint(df, model, player, map_idx, players_grouped, num_cnts)
model = create_unique_league_constraint(df, model, player, league, map_idx, players_grouped, num_cnts)
model = create_min_country_constraint(df, model, player, map_idx, players_grouped, num_cnts)
model = create_rarity_2_constraint(df, model, player, map_idx, players_grouped, num_cnts)
model = create_squad_rating_constraint_3(df, model, player, map_idx, players_grouped, num_cnts)
# This is what I get with default main.py and your club! 
FEASIBLE: A feasible solution has been found. But the search was stopped before we could prove optimality.
Processing time SBC: 139.87 seconds
Total Chemistry: 31
Squad Rating: 80
Total Cost: 7750
# Also best_bound = 6950 (the optimal_cost lies between current_value and best_bound, current_value could also be proven optimal if the solver is given more time)
Name Rating Color Rarity Position Is_Pos Country League Club Untradeable Loans IsDuplicate IsInActive11 Cost Chemistry
Borja Iglesias 83 Gold Rare CF 1 Spain LALIGA EA SPORTS Real Betis TRUE FALSE FALSE FALSE 900 3
Javi GalΓ‘n 82 Gold Rare LB 1 Spain LALIGA EA SPORTS AtlΓ©tico de Madrid TRUE FALSE FALSE FALSE 750 3
Andrich 82 Gold Rare CDM 1 Germany Bundesliga Leverkusen TRUE FALSE FALSE FALSE 750 2
Minge 81 Gold Rare CM 1 Germany GPFBL SC Freiburg TRUE FALSE FALSE FALSE 700 3
Sancet 81 Gold Rare CM 1 Spain LALIGA EA SPORTS Athletic Club TRUE FALSE FALSE FALSE 700 3
Reinildo 81 Gold Rare CB 1 Mozambique LALIGA EA SPORTS AtlΓ©tico de Madrid TRUE FALSE FALSE FALSE 700 3
Karl 80 Gold Rare RB 1 Germany GPFBL SC Freiburg TRUE FALSE FALSE FALSE 1000 3
Anyomi 80 Gold Rare RW 1 Germany GPFBL Frankfurt TRUE FALSE FALSE FALSE 1000 3
RubΓ©n Sobrino 74 Silver Rare LW 1 Spain LALIGA EA SPORTS CΓ‘diz CF TRUE FALSE FALSE FALSE 700 3
Glauder 69 Silver Common CB 1 Spain LALIGA HYPERMOTION Albacete BP TRUE FALSE FALSE FALSE 250 2
von Schrader 68 Silver Common GK 1 Germany GPFBL TSG Hoffenheim TRUE FALSE FALSE FALSE 300 3