modeling-examples icon indicating copy to clipboard operation
modeling-examples copied to clipboard

Multiple Lineups from Pool fantasy_basketball_1_2

Open Owen-Slater opened this issue 3 years ago • 1 comments

Hello, This is a really great and detailed example of how to use gurobi to solve fantasy sports problems. I actually play draftkings , and have been trying to teach myself how to optimize using gurobi opti... Anyway, I have been attempting to use PoolSolutions to return the other solutions... example:

m.setObjective(obj, sense= GRB.MAXIMIZE)
m.setParam(GRB.Param.PoolSolutions, 500) ## finds 500 best lineups
m.setParam(GRB.Param.PoolSearchMode, 2) ## makes sure these are the best solutions (2)
m.update()

m.optimize()
nSolutions = m.SolCount
print('Number of solutions found: ' + str(nSolutions))
for e in range(nSolutions):
    m.setParam(GRB.Param.SolutionNumber, e)

    for v in m.getVars():
        if v.xN ==1:   ### Help I'm stuck

..... How would I modify your colab notebook to print and save all 500 lineups. I have tried for hours, but just don't have a deep enough understanding of the syntax with gurobi and also creating the correct df calls for this. This isn't an issue, as much as a question . Thanks so much in advance, as I know there's no benefit to you helping me. Again, great work and thank you for sharing on github.

Owen-Slater avatar Oct 02 '22 17:10 Owen-Slater

Thanks for the positive feedback. The Xn attribute is for the model, try m.Xn instead of v.Xn

yurchisin avatar Oct 24 '22 16:10 yurchisin