def evalTeamFitness(individual, BT, stats, p, time): i = team.calcTeamStats(individual,stats,p,time) BT = team.calcTeamStats(BT,stats,p,time) i[stats.index(31)]=i[stats.index(31)]+800 i[stats.index(32)]=i[stats.index(32)]+800 i[stats.index(4)]=i[stats.index(4)]+100 i[stats.index(1)]=i[stats.index(1)]+5 BT[stats.index(31)]=BT[stats.index(31)]+800 BT[stats.index(32)]=BT[stats.index(32)]+800 BT[stats.index(4)]=BT[stats.index(4)]+100 BT[stats.index(1)]=BT[stats.index(1)]+5 x= tuple( [a/b for a,b in zip(i,BT)] ) if 0.0 in x: print(x) input() #return tuple( [a/b for a,b in zip(i,BT)] ) return sum([a/b for a,b in zip(i,BT)])-len(stats),
def test(stat,time): mystats = team.calcTeamStats(mystarters, stat, players, time) head = team.statidHeader(stat) t1,f1=genetic.run(mystarters,TeamsToInclude=[0,MYTEAMID],StatsToMaximize=stat, TimeFrame=time, Population=1000, Generations=60) print('\n\n\n\n\n\n\n') [print(head[i],mystats[i]) for i in range(len(head))] print() gastats = team.calcTeamStats(t1, stat, players, time) [print(head[i],gastats[i]) for i in range(len(head))] m = set(mystarters) g = set(t1) k = m&g d = m-g u = g-m print('\nKeep:') for x in k: p = players[x] print(p['stats_percentown'],p['stats_percentowndelta'],p['player_name'],p['position_eligible']) print('\nDrop:') for x in d: p = players[x] print(p['stats_percentown'],p['stats_percentowndelta'],p['player_name'],p['position_eligible']) print('\nPickup:') for x in u: p = players[x] print(p['stats_percentown'],p['stats_percentowndelta'],p['player_name'],p['position_eligible']) mystats = team.calcTeamStats(mystarters, st, players, time) gastats = team.calcTeamStats(t1, st, players, time) print (gastats) print (mystats) print (len(mystats)) print ( sum( [a/b for a,b in zip(gastats,mystats)] ) )