i want to create a fantasy football lineup that maximizes the number of weeks it scores over a threshold.

i have every score for every player for every week.

i currently use a solver to maximize my current objective function which is the total sum of the scores per week per chosen lineup. (this is not the true variable that i want to maximize but its highly correlated)

the current objective function maximizes the total sum of the scores per week, but im looking for the highest number of wins (scores over threshold).

i want to create a new objective function that maximizes the number of wins (weeks over threshold).

is it possible to do this with linear programming? if not, which nlp flavor should i migrate my model to?

**************WARNING, WALL OF TEXT*************

so i have this model running on a spreadsheet that gives me reasonable results but the thing is that it maximizes the TOTAL VALUE of the function whereas what i actually want is to only maximize the TOTAL NUMBER of results of the function over a certain amount.

i don't care about the value once it reaches said amount, so i need some way to discard results under a certain threshold and find the maximum number of results over that threshold. this needs needs to be done within the algo itself so the results below threshold don't add up to the total.

the current function gives me reasonably good results but depending on data distribution i might get results with max objective function value but with a lower number of results over the threshold, whereas another result with lower objective value gives me more results over the threshold.

without getting into too many details there's this fantasy football game where i know the scores of all players for the past 2 seasons, each week a random game week is selected and scores are given to teams according to that weeks performance; teams above a certain threshold get a reward. so the idea is to find the lineup that gives you the higher number of weeks over the threshold, if you are below the threshold it doesn't matter the score, you lose.

my current model maximizes overall total score for all weeks and that is a reasonable approximation, but depending on how players synergize (or randomness) a team with a lower total weekly score might give you more wins.

is there any way to twist this models arm so it does what i want it to do? is this possible with other dedicated solvers? do i need to look into non linear programming to solve this?


  • 2
    $\begingroup$ It takes pains to see what exactly you want from this wall of text. Could you reorganize the problem and highlight your need? See How to ask a good question. $\endgroup$ Jun 6, 2020 at 14:38

1 Answer 1


If your total value objective function to be maximized is $\sum_i v_i$, introduce a binary variable $z_i$ that will indicate whether $v_i \ge T$, where $T$ is your fixed threshold. Let $L_i$ (possibly $0$) be a lower bound on $v_i$. Now maximize $\sum_i z_i$ subject to additional "big-M" constraints $$T - v_i \le (T-L_i)(1-z_i)$$ that enforce the implication $z_i=1 \implies v_i \ge T$.

  • $\begingroup$ solution could not be found. sorry if i sound thick but i havent touched linear programming in 2 decades. for my model i=[week number], does L(i) need to change for every week or should it be assumed to be 0? do i have to make L(i)>T? do i generate z(i) from v(i), if v(i)>T then z(i)=1 else 0? i tried a similar, less elegant approach yesterday and i got the same result. im thinking using a binary variable in the objective function breaks linearity or something. $\endgroup$
    – gataladro
    Jun 7, 2020 at 12:04
  • $\begingroup$ If you know that the value for each week will always be nonnegative, then you can take $L_i=0$ for all $i$. You do not need any explicit if-then-else expression. The objective and big-M constraints are all linear. You should be using a mixed integer linear programming solver. $\endgroup$
    – RobPratt
    Jun 7, 2020 at 14:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .