To give you some context, I improved the existing homework problems, Excel files, and lecture notes (everything now is in PDFs created with LaTeX; no Powerpoint anymore!). I also created a lot of new content (including a hands-on Lego exercise and a case study I developed from scratch), especially when it comes to decision-making under uncertainty. All in all, I’d say 50% of the course is new material, and the remaining 50% is a much better version of the previous material.

Here are the lecture themes (unless otherwise noted, each lecture is a 2-hour session; there are 2 sessions per week). An asterisk * indicates a brand new lecture:

- Lecture 1: Introduction to Optimization: hands-on Lego exercise, investment, scheduling.
- Lecture 2: Mixing and Carryovers: blending, cash flow, production and inventory planning.
- Lecture 3: Networks: assignment, transshipment, shortest path.
- Lecture 4: Integer and Binary Variables: budget allocation, logical conditions, covering, fixed costs.
- Lecture 5: Sensitivity Analysis: shadow prices and reduced costs.
- MIDTERM EXAM
- Lecture 6*: Optimization Under Uncertainty: two-stage stochastic linear programming.
- Lecture 7*: Decision Analysis and Decision Trees (incl. EVPI, EVSI, risk profiles, Bayes’ Rule).
- Lecture 8*: Sequential Decision Processes: stochastic dynamic programming.
- Lecture 9* (two sessions): Monte Carlo Simulation.
- Lecture 10*: Case Discussion.
- FINAL EXAM

On my final exam, I had a question asking students to name their favorite and least favorite lecture. I wanted to see where the home run was and where the big fail was. I had a total of 76 students, and here is the final tally:

You’ll notice that the columns don’t add up to 76 as they should. Some people provided two favorites, and some people did not indicate a least favorite lecture. Here’s what I infer from the table above. (Let me know if you see something I didn’t!)

- Networks as the clear “home run” lecture: I would never have guessed that in a million years! This was so surprising to me. Some of the comments mentioned the visual aspect of it as an attractiveness. I can see that, but still…
- Stochastic DP as the clear “big fail” lecture: I can actually see that because I wasn’t very fond of the lecture myself after I taught it. It looks OK on paper, but the classroom feeling I got from it was lukewarm. I’m thinking of replacing it with a second case study to take place after the first four lectures.
- Two-stage stochastic LP as pretty much another big fail: This one I attribute to a fail on my part. The material in there is pretty good. It’s just a matter of my doing a better job motivating and explaining it (the written feedback points to its being hard to follow). I’ll keep it for sure and refine the delivery. (Two people actually loved it! :-)
- Simulation as a bit of a polarizing topic: I honestly thought the simulation class was going to be a big home run. The 11 votes in the right column are likely my fault again (based on feedback). I fully believe in the quality of the content, but I need to do a better job connecting it with the statistics course that precedes mine (I assumed too much of the students).
- Beloved decision trees: I had a lot of fun putting together and delivering the decision tree lecture, but I didn’t expect it would get so many “fave” votes. Being a new lecture, there were some hiccups that I can easily fix (the same being true for lectures 6, 8, and 9), and seeing how successful it already was gives me even more motivation.
- Case study: I had never written a full-length case study before, but got excited about doing so after an instructional session organized for the faculty at our school. Despite liking the case on paper (it combines marketing and optimization aspects), I was a bit anxious before the actual discussion took place. My students did an amazing job and performed way beyond my expectations. After seeing where they went and what issues they brought up, I feel like I can polish the case to make it even better.
- Lego exercise: Another pleasant surprise. I was worried the Lego exercise might be seen as too simple or silly. I was wrong! The feedback indicated it worked well as a motivational tool, a visual aid, and a good ice breaker (it’s the very first thing I do in Lecture 1).

I’m pretty happy overall and really enjoyed what I learned from this fave/least fave question. It can be pretty informative. Do you have any other creative ways to elicit student feedback that you find particularly helpful? If so, please share them in the comments below.

]]>The Management Science Department at the Miami Business School invites applications for an open-rank, tenure-track faculty position to begin in the fall of 2019. Applicants with research interests in all areas of Operations Research and Analytics will be considered.

Applicants should possess, or be close to completing, a Ph.D. in Operations Research, Operations Management, Industrial Engineering, or a related discipline by the start date of employment. The Management Science Department consists of a diverse group of faculty with expertise in Statistics and Operations Research. We seek candidates whose research and teaching interests complement and strengthen our existing departmental strengths. Responsibilities include research, which is expected to lead to top-tier publications, teaching at both the undergraduate and graduate levels, and service.

Applications should be submitted by e-mail to MASrecruiting@bus.miami.edu, and should include the following: a curriculum vitae, up to three representative publications, brief research and teaching statements, an official graduate transcript, information about teaching experience and evaluations (if available), and three letters of recommendation. All applications completed by December 1, 2018 will receive full consideration, but candidates are urged to submit all required material as soon as possible. Applications will be accepted until the position is filled. Candidates who are presenting at the INFORMS Annual Meeting in Phoenix are encouraged to include the details of their session in their cover letter. Our faculty attending the meeting will try to attend these presentations and may arrange for interviews whenever possible.

Salary is competitive and commensurate with qualifications and experience. This is a nine-month appointment and summer research support is anticipated from the Business School.

The University of Miami offers a comprehensive benefits package including medical and dental benefits, tuition remission, and much more. For additional information, visit https://www.hr.miami.edu/working-at-the-u/new-employee-total-rewards/index.html. The University is an equal opportunity employer and encourages candidates regardless of gender, race, color, ethnicity, age, disability status or sexual orientation to apply.

]]>Without further ado…

You’re interested in gaining a better understanding of the likelihood, or probability , that certain **agents** will perform a given **action** that benefits you. So you hire a group of business analytics consultants who create a statistical learning model **M** that predicts the value of with high accuracy given an agent (and their attributes/characteristics) as input.

Those agents with high-enough probability of performing the action, say (a subjective choice), don’t concern you too much because they’re already on your side. Your focus is on those whose value of is less than 50%. One of the outcomes of model **M** is a number for each agent (or group of similar agents) indicating how much of an effect giving that agent a **financial incentive** would have on the value of their action probability . For example, this number could be 0.1 for a given agent, indicating that they’d be 10% more likely to perform the action for each $1000 of incentive they receive. So, assuming a linear model, if their originally predicted were 35%, giving them $2000 would be enough to push them beyond your target 50% threshold. (Considering incentives are given in multiples of $1000.)

Before we go any further, let me make this more concrete with a few examples.

**Example 1:** You are the seller of a product. Agents are customers. The action is purchasing your product. The financial incentive is a discount. You have a budget for the overall discount you can give and you want to optimally allocate different discount amounts to different customers to bring as many of them as possible to the brink of buying your product (say, a 50% chance).

**Example 2:** You are a politician. Agents are voters. The action is voting for you. The financial incentive is a bribe. This happens in Brazil and likely in other countries as well. *(Disclaimer: I’m not advocating that this is an ethical or moral thing to do. Like any superpower, however, mathematics can be used by the dark side as well.)*

**Example 3:** You are a university. Agents are admitted students. The action is picking you to attend. The financial incentive is a scholarship.

I’m sure you can come up with other examples. Let me know in the comments!

So the big question is: **How do we optimally allocate the limited pool of financial incentives?** Optimization to the rescue! I’ll provide a link to an Excel spreadsheet below, but first let’s understand the math behind it.

Given agents, for each agent , let be how much the agent’s action probability (before the incentive) is below my target threshold, and let be how much agent ‘s action probability increases for each dollars of financial incentive. In my example above, (50% minus 35%), , and .

Let’s create two variables for each agent . Variable is an integer number indicating how many -dollar incentives we decide to give to that agent. And variable is a binary (yes/no) variable indicating whether or not we manage to bring agent to our side (i.e. whether we raised his/her action probability beyond the threshold).

To indicate that our goal is to push as many agents beyond the action threshold as possible, we write

If our total budget for financial incentives is , we respect the budget with the following constraint (note that the sum of all equals the total number of-dollar financial incentive packages given away):

Then, if we want to be equal to 1 (meaning “yes”), we need to be high enough for the increase in the agent’s action probability to exceed the threshold value. This can be accomplished with these constraints

In my earlier example, the above constraint would read

Therefore, unless is at least 2, the value of cannot be equal to 1.

That’s it! We are done with the math. Wasn’t that beautiful?

Here’s an Excel spreadsheet that implements this model for a random instance of this problem with 20 agents. It’s already set up with all you need to run the Solver add-in. Feel free to play with it and let me know if you have any questions.

]]>**Theory versus Practice: A Challenge**

It was a rainy Saturday afternoon…

“Ready? Go!”

As she reached for her pencil and began scribbling, I opened an empty Excel spreadsheet and started typing in the data and thinking out loud.

“Eight integer variables, three constraints, plus lower and upper bounds. How is it going over there?”

“I’m doing OK. Let me think.”

A minute later, I click “Solve” and declare victory.

“There you go: $2.80. Can’t beat that!”

“Five buns? Do you expect people to eat a burger with five buns?”

“Hmm…you’re right. One more constraint… voilà $2.62. The best burger on the market! What did you get?”

“Mine costs $2.61.”

“I win! Ha, ha!”

“But look at your burger! Nobody would ever want to eat this crap. Mine is much more appetizing.”

As I reluctantly examined the two solutions, there was no denying the obvious.

That was me and my wife solving the Good Burger puzzle. The challenge is to create the most expensive burger out of a given set of ingredients such as beef patties, cheese, lettuce, tomato, etc., while keeping sodium, fat, and calorie counts in check. Her hand-calculated solution was suboptimal by one cent. It was technically worse than mine, but what does optimality really mean in practice?

**Optimality or Bust?**

Once upon a time, at the board meeting of a for-profit company…

“Today, I’m excited to report the results from the cost-cutting initiative that my team of analytics experts developed over the last six months. We managed to produce a solution to our problem that improves profits by 6%.”

“But is this solution optimal?”

Said no one ever after hearing “improves profits by 6%.”

**Intangibles and Intuition**

The two anecdotes above illustrate an important idea that I emphatically stress to my students every spring semester: models aren’t perfect, and that’s perfectly OK. There’s a reason why business analytics is known as “the science of better” rather than “the science of provably optimal.” More often than not, it is impossible to capture all nuances of a real-life problem into a mathematical model. Therefore, solutions produced by such a model are to be taken with a grain of salt and cautious optimism. Do these numbers still make sense after the omitted intangibles are brought back into the picture? If so, great. If not, can we slightly modify the solution? Do we need to revise the model? When building my burger, I ignored flavor considerations and overall gastronomic appeal, whereas my wife didn’t.

Another matter with which non-experts struggle is keeping their intuition from negatively affecting their modeling choices. Or, as I like to say in class, “don’t try to *solve* the problem; focus on *representing* the problem.” A mathematical model is a translation, say, from English to formulas, of the story that warrants investigation. Letting your understanding of the story bias you into thinking the solution should/shouldn’t look a certain way, and adding that assumption into your model, can be detrimental. As humans, we tend to think intuitively, which in turn limits the universe of possibilities we look at. Good solutions to complex problems can be, at least at first sight, counterintuitive. Make sure your model has the freedom to consider “weird” courses of action as well.

**The Usefulness of Imperfection**

Imperfect models create imperfect solutions that can still be useful. Having a solution in the ballpark of good answers is better than looking at a blank slate and not knowing where to begin. Solving a model many times with a range of input values improves your understanding of how certain numbers relate to others. As your understanding of the problem improves, that (initially) counterintuitive solution starts to make sense. Improved understanding leads to revising your initial assumptions and even realizing that what you thought mattered is secondary. What really matters is this other number to which you didn’t pay much attention to begin with. In extreme cases, this first model may lead you to conclude that you need to create a completely different model to solve a completely different problem, and that’s OK too! You are *learning* about your problem in the process of trying to solve your problem. Finally, it may very well be that your problem, as originally stated, has no solution. This would have been difficult to detect by hand because complex problems have several moving parts with intricate relationships of cause and effect. Having a model whose output says “infeasible” can be a valuable tool in a meeting. It is concrete proof that the original question and/or assumptions are inconsistent in some way. (Assuming there’s no mistake in the model, of course.) From there, it will be a much shorter path to convincing people to revise the question/assumptions than it would have been otherwise. Who would have thought? Modeling also makes your meetings more efficient!

Instead of a subway system, Miami has surface trains like the one depicted below. This is known as our Metrorail system. The Metrorail connects to the Tri-Rail system (which takes you north as far as West Palm Beach) and also to the free-to-ride, fully-automated, electrically-powered Metromover.

If you are a (reasonably) frequent Metrorail rider, you may consider buying a rechargeable card at one of the ticket vending machines. There is a 1-day pass ($5.65), a 7-day pass ($29.25), and a monthly pass ($112.50) that offer unlimited rides, but let’s focus on the case when you don’t ride often enough to justify the cost of such passes.

The current cost of a one-way trip is $2.25, regardless of distance traveled. The vending machines at the entrance of each Metrorail station allow you to load the following pre-specified amounts onto your card: $1, $2.25, $3, $4.50, $5, $10, $20, and $40.

No one likes to waste time having to stop by the vending machine to reload the Metrorail card. Besides, by Murphy’s Law, the next train will arrive and depart exactly when you’re stuck in line at the machine trying to reload your card. Therefore, we’ll consider that our objective is to minimize the number of visits to the vending machine to load our card with enough money for one-way trips. If we were free to load any amount on the card, we could simply load times $2.25 and be done. The absence of this flexibility is what makes this situation both interesting and a reason for us to hate the Metrorail. So let’s write an optimization model to solve this problem.

Let variable be the number of times we go to the vending machine to load $1 on the card. Let be the number of times we load $2.25 on the card, and so on all the way to (how many times we load $40). To minimize the number of visits to the vending machine, we write the objective function

To make sure we load enough money on the card for trips, we write the constraint

If we are not careful, we may end up with unnecessarily too much money left on the card. So it’s wise to limit that excess with the constraint

where is a limit on what we’d be willing to have left on the card after the trips are completed. Conceivably, this leftover amount could be applied toward your next batch of trips. Hold that thought; we’ll return to it later.

I put together an Excel Solver spreadsheet model for this problem, which you can download from here (sheet named “standard” in the Excel file).

If you change the second constraint above to an equality and solve this problem for different values of and , you can create the following heat map. The numbers in the colored squares indicate the minimum number of required visits to the vending machine.

Interestingly, some values of , such as 10, 18, and 20, are more friendly in the sense that they allow you to visit the machine at most twice while incurring a small leftover amount (no more than $0.50). On the other hand, to avoid visiting the machine more than twice when paying for 12, 14, or 16 trips, you must be willing to accept a much higher ending balance: $3, $8.50, and $4, respectively. In addition, some of the reload amounts that might at first seem useless, such as $5 and $10, actually do get used in the optimal solutions for some values of and .

**Ending Balances As Multiples of $2.25**

As we saw above, allowing for larger ending balances on the card can help reduce the number of visits to the vending machine. One way to make these balances useful is to apply them toward future trips. If the balance is a multiple of the cost of a one-way trip, even better. To do that, we can replace the second constraint above with

where is a new, non-negative integer variable. The sheet called “leftover is multiple” in this Excel file implements this version of the optimization model. The conclusion is that you pretty much only need 2 visits to the vending machine for , and the value of seems to decrease as increases. (See Excel file for detailed results.)

Now, if only I could get someone from Miami-Dade Transit to read this post…

]]>**Tenure-Track Position in Business Analytics**

The Department of Management Science in the School of Business at the University of Miami invites applications for a tenure-track Assistant Professor position in Business Analytics to start in the fall of 2018.

Applicants with research and teaching interests in all areas of business analytics or data science will be considered. The Management Science Department is home to a diverse group of faculty with expertise in data analytics and operations research, and offers a Master of Science program in Business Analytics, in addition to participating in the undergraduate, MBA, and Ph.D. programs of the School. The position affords the successful candidate the opportunity to have an immediate impact in a dynamic department that is rapidly growing in the area of business analytics. Duties will include research and teaching at both the graduate and undergraduate levels. Salary is competitive and commensurate with background and experience.

Applicants should possess, or be close to completing, a Ph.D. in a discipline related to business analytics or data science by the start date of employment. Applications should be submitted by e-mail to MASrecruiting@bus.miami.edu, and should include the following: a curriculum vitae, up to three representative publications, brief research and teaching statements, an official graduate transcript, information about teaching experience and performance evaluations (if available), and three letters of recommendation. All applications completed by December 1, 2017 will receive full consideration, but candidates are urged to submit all required material as soon as possible. Applications will be accepted until the position is filled.

The University of Miami offers a comprehensive benefits package including medical and dental benefits, tuition remission, and much more.

*The University is an equal opportunity employer and encourages candidates regardless of gender, race, color, ethnicity, age, disability status or sexual orientation to apply.*

Every now and then, I come across a paper that fits the bill perfectly: it addresses an important problem, produces impactful results, and (here comes the rare part), accomplishes the previous two goals by using math that my MBA students can follow 100%, while being confident that they themselves could replicate it given what they learned in my course (the optimization models).

The paper to which I’m referring has recently appeared in *Operations Research* (Articles in Advance, January 2017): The Impact of Linear Optimization on Promotion Planning, by Maxime C. Cohen, Ngai-Hang Zachary Leung, Kiran Panchamgam, Georgia Perakis, and Anthony Smith (http://dx.doi.org/10.1287/opre.2016.1573).

If I had to pick one word to describe this paper, it would be **BEAUTIFUL**.

I immediately proceeded to put together a 5-minute summary presentation (8 slides) to cover the problem, approach, and results. I’ll be showing this to 100 of my MBA students on this coming Tuesday (Valentine’s Day!). I hope they love it as much as I did. Feel free to show this presentation to your own students if you wish, and let me know how it went down in the comments.

A recent Poets & Quants article explains how business schools with the highest quality teaching strive to bring their faculty’s research into the classroom so that students get to learn the latest and greatest ideas. The O.R. paper above is a perfect example of when this can be done effectively.

]]>I’d like my students to be able to pronounce some of the main sounds in Portuguese correctly because I know Brazilians pay attention and really enjoy when foreigners make an effort to say things properly. Therefore, I created a video in which I go over what I consider to be some of the most important things to know when speaking Portuguese (there are others, but I didn’t want the video to be too long).

You can access it on my YouTube channel here: https://www.youtube.com/watch?v=LzgoYFokBPk

Moreover, the 2016 Olympic Games are coming, so I figured these tips could be useful for a larger audience as well. I wish American sports casters would watch this video because they murdered the pronunciation of everything during the World Cup in 2014.

**Bonus material:** My daughter, Lavinia Lilith, a.k.a. #LLCoolBaby, makes a short appearance at around the halfway mark.

Enjoy!

]]>**UPDATE on 10/8/2015: Explained how to model a different objective function (Requirement 5).**

Yesterday, I wrote a post describing an optimization model for picking a set of players for a fantasy football team that maximizes the teams’ point projection, while respecting a given budget and team composition constraints. In this post I’ll assume you’re familiar with that model. (If you are not, please spend a few minutes reading this first.)

Fellow O.R. blogger and Analytics expert Matthew Galati pointed out that my model did not include all of the team-building constraints that appear on popular fantasy football web sites. Therefore, I’m writing this follow-up post to address this issue. (Thanks, Matthew!) My MBA student Kevin Bustillo was kind enough to compile a list of rules from three sites for me. (Thanks, Kevin!) After looking at them, it seems my previous model fails to deal with three kinds of requirements:

- Rosters must include players from at least different NFL teams ( for Draft Kings and for both Fan Duel and Yahoo!).
- Rosters cannot have more than players from the same team ( for Fan Duel and for Yahoo! Draft Kings does not seem to have this requirement).
- Players in the roster must represent at least different football games (Only Draft Kings seems to have this requirement, with ).

Let’s see what the math would look like for each of the three requirements above. (Converting this math into Excel formulas shouldn’t be a problem if you follow the methodology I used in my previous post.) I’ll be using the same variables I had before (recall that binary variable indicates whether or not player is on the team).

**Requirement 1**

Last time I checked, the NFL had 32 teams, so let’s index them with the letter and create 32 new binary variables called , each of which is equal to 1 when at least one player from team is on our team, and equal to zero otherwise. The requirement that our team must include players from at least teams can be written as this constraint:

The above constraint alone, however, won’t do anything unless the variables are connected with the variables via additional constraints. The behavior that we want to enforce is that a given can only be allowed to equal 1, if at least one of the players from team has its corresponding variable equal to 1. To make this happen, we add the constraint below for each team :

For example, if the Miami Dolphins are team number 1 and their players are numbered from 1 to 20, this constraint would look like this:

**Requirement 2**

Repeat the following constraint for every team :

Assuming again that the first 2o players represent all the players from the Miami Dolphins, this constraint on Fan Duel would look like this:

**Requirement 3**

My understanding of this requirement is that it applies to short-term leagues that get decided after a given collection of games takes place (it could even be a single-day league). This could be implemented in a way that’s very similar to what I did for requirement 1. Create one binary variable for each game . It will be equal to 1 if your team includes at least one player who’s participating in game , and equal to zero otherwise. Then, you need this constraint

as well as the constraint below repeated for each game :

**Additional Requirements Submitted by Readers**

I earlier claimed that this model can be adapted to fit fantasy leagues other than football. So here’s a question I received from one of my readers:

For fantasy baseball, some players can play multiple positions. E.g. Miguel Cabrera can play 1B or 3B. I currently use OpenSolver for DFS and haven’t found a good way to incorporate this into my model. Any ideas?

Let’s call this…

**Requirement 4: What if some players can be added to the team at one of several positions?**

Here’s how to take care of this. Given a player , let the index represent the different positions he/she can play. Instead of having a binary variable representing whether or not is on the team, we have binary variables (as many as there are possible values for ) representing whether or not player is on the team at position . Because a player can either not be picked or picked to play one position, we need the following constraint for each of these multi-position players:

Because we have replaced with a collection of ‘s, we need to replace all occurrences of in our model with .

In the Miguel Cabrera example above, let’s say Cabrera’s player ID (the index ) is 3, and that represents the first-base position, and represents the third-base position. The constraint above would become

And we would replace all occurrences of in our model with .

That’s it!

Reader rs181602 asked me the following question:

I was wondering, is there a way to add an additional constraint that maximizes the minimum rating of the chosen players, if each player has some rating score. I tried to think that out, but can’t seem to get it to be linear.

Let’s call this…

**Requirement 5: What if I want to maximize the point projection of the worst player on the team? (In other words, how do I make my worst player as good as possible?)**

It’s possible to write a linear model to accomplish this. Technically speaking, we would be changing the objective function from maximizing the total point projection of all players on the team to maximizing the point projection of the worst player on the team. (There’s a way to do both together (sort of). I’ll say a few words about that later on.)

Here we go. Because we don’t know what the projection of the worst player is, let’s create a variable to represent it and call it . The objective then becomes:

You might have imagined, however, that this isn’t enough. We defined in words what we want to be, but we still need formulas to make behave the way we want. Let be the largest point projection among all players that could potentially be on our team. It should be clear to you that the constraint is a valid ceiling on the value of . In fact, the value of will be limited above by 9 values/ceilings: the 9 point projections of the players on the team. We want the lowest of these ceilings to be as high as possible.

When a player is **not** on the team (), his point projection should not interfere with the value of . When player **is** on the team (), we would like to become a ceiling for , by enforcing . The way to make this happen is to write a constraint that changes its behavior depending on the value of , as follows:

We need one of these for each player. To see why the constraint above works, consider the two possibilities for . When (player not on the team), the constraint reduces to (the obvious ceiling), and when (player on the team), the constraint reduces to (the ceiling we want to push up).

**BONUS:** What if I want, among all possible teams that have the maximum total point projection, the one team whose worst player is as good as possible? To do this, you solve two optimization problems. First solve the original model maximizing the total point projection. Then switch to this model and include a constraint saying that the total point projection of your team (the objective formula of the first model) should equal the total maximum value you found earlier.

That’s it!

And that does it, folks!

Does your league have other requirements I have not addressed here? If so, let me know in the comments. I’m sure most (if not all) of them can be incorporated.

]]>*Note 2: Although the title says “Fantasy Football”, the model I describe below can, in principle, be modified to fit any fantasy league for any sport.*

I’ve been recently approached by several people (some students, some friends) regarding the creation of optimal teams for fantasy football leagues. With the recent surge of betting sites like Fan Duel and Draft Kings, this has become a multi-million (or should I say, billion?) dollar industry. So I figured I’d write down a simple recipe to help everybody out. We’re about to use **Prescriptive Analytics** to bet on sports. Are you ready? Let’s do this! I’ll start with the math model and then show you how to make it all work using a spreadsheet.

**The Rules**

The fantasy football team rules state that a team must consist of:

- 1 quarterback (QB)
- 2 running backs (RB)
- 3 wide receivers (WR)
- 1 tight end (TE)
- 1 kicker
- 1 defense

Some leagues also have what’s called a “flex player”, which could be either a RB, WR, or TE. I’ll explain how to handle the flex player below. In addition, players have a cost and the person creating the team has a budget, call it , to abide by (usually is $50,000 or $60,000).

**The Data**

For each player , we are given the cost mentioned above, call it , and a point projection . The latter is an estimate of how many points we expect that player to score in a given week or game. When it comes to the defense, although it doesn’t always score, there’s also a way to calculate points for it (e.g. points prevented). How do these point projections get calculated, you may ask? This is where **Predictive Analytics** come into play. It’s essentially forecasting. You look at past/recent performance, you look at the upcoming opponent, you look at players’ health, etc. There are web sites that provide you with these projections, or you can calculate your own. The more accurate you are at these predictions, the more likely you are to cash in on the bets. Here, we’ll take these numbers as given.

**The Optimization Model**

The main decisions to be made are simple: which players should be on our team? This can be modeled as a yes/no decision variable for each player. So let’s create a binary variable called which can only take two values: it’s equal to the value 1 when player is on our team, and it’s equal to the value zero when player is not on our team. The value of (the player ID) ranges from 1 to the total number of players available to us.

Our objective is to create a team with the largest possible aggregate value of projected points. That is, we want to maximize the sum of point projections of all players we include on the team. This formula looks like this:

The formula above works because when a player is on the team (), its gets multiplied by one and is added to the sum, and when a player isn’t on the team () its gets multiplied by zero and doesn’t get added to the final sum. The mechanism I just described is the main idea behind what makes all formulas in this model work. For example, if the point predictions for the first 3 players are 12, 20, and 10, the maximization function start as:

The budget constraint can be written by saying that the sum of the costs of all players on our team has to be less than or equal to our budget , like this:

For example, if the first 3 players cost 9000, 8500, and 11000, and our budget is 60,000, the above formula would look like this: .

To enforce that the team has the right number of players in each position, we do it position by position. For example, to require that the team have one quarterback, we write:

To require that the team have two running backs and three wide receivers, we write:

The constraints for the remaining positions would be:

**The Curious Case of the Flex Player**

The flex player adds an interesting twist to this model. It’s a player that, if I understand correctly, takes the place of the kicker (meaning we would not have the kicker constraint above) and can be either a RB, WR, or TE. Therefore, right away, we have a new decision to make: what kind of player should the flex be? Let’s create three new yes/no variables to represent this decision: , , and . These variables mean, respectively: is the flex RB?, is the flex WR?, and is the flex TE? To indicate that only one of these things can be true, we write the constraint below:

In addition, having a flex player is equivalent to increasing the right-hand side of the constraints that count the number of RB, WR, and TE by one, but only for a single one of those constraints. We achieve this by changing these constraints from the format they had above to the following:

Note that because only one of the variables can be equal to 1, only one of the three constraints above will have its right-hand side increased from its original value of 2, 3, or 1.

**Other Potential Requirements**

Due to personal preference, inside information, or other esoteric considerations, one might want to include other requirements in this model. For example, if I want the best team that includes player number 8 and excludes player number 22, I simply have to force the x variable of player 8 to be 1, and the x variable of player 22 to be zero. Another constraint that may come in handy is to say that if player 9 is on the team, then player 10 also has to be on the team. This is achieved by:

If you wanted the opposite, that is if player 9 is on the team then player 10 is NOT on the team, you’d write:

Other conditions along these lines are also possible.

**Putting It All Together**

If you were patient enough to stick with me all the way through here, you’re eager to put this math to work. Let’s do it using Microsoft Excel. Start by downloading this spreadsheet and opening it on your computer. Here’s what it contains:

- Column A: list of player names.
- Column B: yes/no decisions for whether a player is on the team (these are the x variables that Excel Solver will compute for us).
- Columns C through H: flags indicating whether or not a player is of a given type (0 = no, 1 = yes).
- Columns I and J: the cost and point projections for each player.

Now scroll down so that you can see rows 144 through 150. The cells in column B are currently empty because we haven’t chosen which players to add to the team yet. But if those choices had been made (that is, if we had filled column B with 0’s and 1’s), multiplying column B with column C in a cell-wise fashion and adding it all up would tell you how many quarterbacks you have. I have included this multiplication in cell C144 using the SUMPRODUCT formula. In a similar fashion, cells D144:H144 calculate how many players of each kind we’d have once the cells in column B receive values. The calculations of total team cost and total projected points for the team are analogous to the previous calculations and also use the SUMPRODUCT formula (see cells I144 and J144). You can try picking some players by hand (putting 1’s in some cells of column B) to see how the values of the cells in row 144 will change.

If you now open the Excel Solver window (under the Data tab, if your Solver add-in is active), you’ll see that I already have the entire model set up for you. If you’ve never used Excel Solver before, the following two-part video will get you started with it: part 1 and part 2.

The objective cell is J144, and that’s what we want to maximize. The variables (a.k.a. changing cells) are the player selections in column B, plus the flex-player type decisions (cells D147:F147). The constraints say that: (1) the actual number of players of each type (C144:H144) are equal to the desired number of each type (C146:H146), (2) the total cost of the team (I144) doesn’t exceed the budget (I146), (3) the three flex-player binary variables add up to 1 (D150 = F150), and, (4) all variables in the problem are binary. (I set the required number of kickers in cell G146 to zero because we are using the flex-player option. If you can have both a flex player and a kicker, just type a 1 in cell G146.) If you click on the “Solve” button, you’ll see that the best answer is a team that costs exactly $50,000 and has a total projected point value of 78.3. Its flex player ended up being an RB.

This model is small enough that I can solve it with the free student version of Excel Solver (which comes by default with any Office installation). If you happen to have more players and your total variable count exceeds 200, the free solver won’t work. But don’t despair! There exists a great Solver add-in for Excel that is also free and has no size limit. It’s called OpenSolver, and it will work with the exact same setup I have here.

That’s it! If you have any questions or remarks, feel free to leave me a note in the comments below.

**UPDATE:** In a follow-up post, I explain how to model a few additional fantasy-league requirements that are not included in the model above.