If I Were GM #1: Knapsack Problems

We are now posting all of our articles on Substack! Check out this article there now.

This is the first article in a series called “If I Were GM”. If you were the GM of a professional sports team and had a full analytics department at your disposal, how would you direct them? What questions would you ask? And most importantly, because we’re The Data Jocks, how would we lean on the huge body of mathematical knowledge to improve our team?

If I were GM, I would direct my analytics department to see what we can learn about roster construction by studying the Knapsack Problem from combinatorial optimization.

To receive email updates when new articles are posted, use the subscription form below!

The Problem

The most important job a GM has is constructing the best team possible. At first glance, it seems easy: add good players and dump bad ones. But inevitably on your first day, a 34 year old veteran on the last year of their deal walks into your office and says they won’t play without an extension. They’re an aging veteran. One of the best players on your team. But…they’re probably just past their prime and are asking for a top-of-market deal. Is it worth it?

Whether or not to sign a player is a comparison between the wins they bring in and the cost of their contract. A $5 million dollar player that adds 2 wins to your team is clearly better than a $10 million dollar player that adds just 1.

But comparisons are not always that cut and dry. Here is a more explicit example. In the 2010s, the NBA was dominated by the concept of ‘The Big Three’. The guiding principal in building a team was to snag three stars and fill out the rest of the team however you can. The problem is that the NBA’s collective bargaining agreement allows vets to command 25-35% of the salary cap. Do the math and after you pay your big three you’re left with scraps to pay the rest.

Is it better to pay 3 stars but have negative value players everywhere else? Is it better to pay 2 stars and keep some money back to round out the roster?

Building a competitive team is a balancing act between quality and cost. Every player has a cost and every play provides some amount of value to your team. The goal is to maximize the value of your team within the constraints of the salary cop and roster size limits. For example, if it’s the NFL in 2025, your goal is to build the best team while spending up to $279 million dollars on at most 53 players. If it’s the NBA, you get to spend about $155 million on at most 15 players. Roster construction, through this lens, is a constrained optimization problem.

The Math

Do you remember the old game show Supermarket Sweep? The idea was you had a limited time, a few minutes, to run around a grocery store and grab items to fill your cart. The goal was to ring up the highest possible bill at the checkout counter. The strategy most people went for was to target expensive items like frozen turkeys or medicines. The problem with this, though, is that you spend more time running and less time filling your cart. The better strategy was to just grab as much as you can get your hands on, fill and return your cart, and go back out again. Quantity over quality. It turns out this problem has a very similar mathematical structure as designing an NFL roster.

Every mathematical analysis starts by abstracting away the extra details and retaining only the core structure. In supermarket sweep, every item has a value and a cost. The value is how much it rings up at the register. The cost is how long it takes to add the item to your cart. You only have so much you can ‘spend’ maximizing your value – in this case, a time limit to spend filling your cart.

In this abstracted setting, it’s much easier to see the similarities to sports roster building. In the sporting world, every player has a value and a cost. The value is how many wins they bring in. The cost is both their contract salary and, subtly, the fact that you have to spend one of your limited roster spots on the player. Both roster building and Supermarket Sweep are constrained optimization problems.

We can get even more specific. Building a roster in sports is a very specific constrained optimization problem. It is an example of a Knapsack Problem. The typical description of a Knapsack Problem – and the reason for its name – is this. You have a Knapsack and can carry only so much weight. You have a set of items to pick from to fill the backpack, each with a known weight and value. How do you pick which items to go in the bag?

This problem has applications everywhere. If you have a limited amount of capital and want to pick from a set of investment opportunities, each with a required investment amount and expected return, you have a knapsack problem. If you have a supercomputer you’re selling access to and a set of jobs with predicted run times and sales costs, you have a Knapsack Problem. Any time you’re picking from a discrete set of options among which to allocate resources while trying to maximize value, you have a Knapsack Problem.

The theory of Knapsack Problems is deep, old, and quite well understood by the mathematical community. We have algorithms to solve them. Those algorithms aren’t interesting to the sports example. What is interesting is some of the heuristics used to approximate solutions to the Knapsack Problem. (For those not as mathematical, heuristic is a word often used in mathematics for an idea or approach that is ‘good, defensible, perhaps intuitive, but not necessarily totally optimal).

Learning From The Knapsack Problem

One of the main heuristics to solve the knapsack problem is to consider all the options in terms of value per cost. By dividing each item’s value by its cost, we come up with a way to compare various items. For example, Nikola Jokic was worth about 13.3 points relative to a replacement level player in 2025. That means it costs only $4.1 million to improve your team by one point . The MVP SGA was even more valuable, costing only about $3.3 million for each point of team improvement.

If we go further down to the 75th best player the value gets worse. If you sign Aaron Wiggins, you’re paying about $10 million per point of improvement. Even a very promising young guy on a rookie-scale controlled contract like Brandon Podziemski costs about 5.3 million per point added. No wonder team building in the NBA favors adding as many stars as possible and filling in the rest however you can. The stars are such great value per dollar that every good strategy starts by maximizing top tier talent.

Another heuristic for Knapsack Problems is the concept of dominance relations. Very clearly: if something costs less but adds more value, the lesser item can be discarded and never considered. In sports, if player A costs less and adds more wins than player B, then player B should never be considered unless player A is unavailable.

Applying the idea of dominance relations can be used to explain the value of rookie picks. The contracts of rookies and other young players are usually very cheap. Especially in the NBA and NFL, rookies can become meaningful contributors while on their rookie deals, providing insane value. For example, you could improve your team by 1 point for only about $2 million per point if Wembanyama is on your team – more valuable even than Jokic and SGA’s contracts.

Its even more dramatic in the NFL. How often does a young QB make a deep run before they’re seemingly ready? Joe Burrow, Jayden Daniels, Brock Purdy have all made deep playoff runs on their rookie deals. Not only do these star players propel their team by their own skills, but because they were on rookie deals the value was simply incomparable.

You can even use this idea to talk about the Luka Doncic trade. In the NBA, a max contract after year 7 can be worth up to 30% of the cap. But, in some circumstances, a player may sign a supermax worth 35% of the cap. When Luka Doncic was traded to the Los Angeles Lakers, he became ineligible for the supermax. Thus, not only do the Lakers get one of the best players in the league, they get him on a discount! This means that the value per cost ratio of Luka Doncic is guaranteed to be elite for the next few years. The Lakers won this trade in many more ways than it even initially seemed.

If I Were GM

If I were GM, I would ask my analytics department to construct optimal teams using the knapsack problem formulation. While we can’t just go out and sign whoever we want, the output of these algorithms will teach us something nonetheless. Is it better to have an elite QB and figure out the rest? Is it better to surround a middle-of-the-pack QB with offensive talent using the money saved on the cheaper QB? Is it better to go all in on defense? In the NBA, is it better to go with a big 2 or a big 3? Should we prioritize our top 5? Our top 7?

Even if the knapsack problem formulation doesn’t actually tell us which team to build, it will tell us things about team building philosophies, paradigms, and strategies to build the most competitive teams possible.