Planning your trail food is one of those tasks that sounds simple until you’re standing in a gas station snack aisle in some small town, staring at a wall of Fritos and Honey Buns, trying to do mental math on calories in your basket because your phone is hanging out of a wall socket, charging.

The question “what should I eat on trail?” has a lot of right answers. What really started this project is when I was being forced to optimize an 8-day food carry across the Grand Canyon, resupplying out of Grand Canyon Village during a blackout. I ended up concluding: buy all the nuts, and was surprised by how well that ended up working!

But if you want to be systematic about it, it helps to start with real data!

The Data Behind This

Every year, the USDA runs a large-scale dietary survey called the National Health and Nutrition Examination Survey (NHANES). Surveyors ask tens of thousands of Americans to recall everything they ate over the past 24 hours, down to portion sizes. The “What We Eat in America” (WWEIA) component covers the types and amounts of food people reported in those interviews.

The latest published dataset covers 2021 through 2023 and includes over 90,000 individual food datapoints. The USDA processes all of that into a food composition database: 4,400 foods, each with per-100g nutrient values calculated from actual consumption data across thousands of reported portions. That database is the backbone of this tool.

Trail resupply food including Fritos and crackers packed in a dry bag
The kind of food choices that inspired this project. CDT, 2021.

What the Optimizer Does

The tool contains all 4,400 foods categorized by no-cook and shelf-stable indicators, with full nutitional data and calorie densities! I’ve also grouped them by what may be available at a rural gas station vs. a grocery store.

Since my graduate-level econ course days, I’ve been kinda obsessed with the beauty of using linear programming to solve problems. As such, the optimizer itself uses linear programming to find the combination of foods that hits your calorie target with the lowest total weight, subject to constraints.

That’s the goal of ultralight backpacking, right? More calories per ounce. You can even optimize for lowest cost or a more diverse food basket.

Set your body weight, daily calorie target, and store type, then run it. Standard LP mode returns results pretty quickly (although if this becomes too popular my poor server might die). The diversity constraint allows for broader food selection, so you’re not just getting corn oil 😉

Nutrition constraints are based on Dietary Reference Intakes (DRI) scaled to your body weight and the number of days you’re planning for. The “Optimal Nutrition” profile tries to meet meaningful minimums for protein, fiber, calcium, iron, and several vitamins. You can dial those back or turn them off entirely if you just want a calorie-dense list with no other restrictions. You’ll make that nutrition lapse up in town, right?

A Few Notes on Using It

Prices, store availability, and a few other odds and ends come from the USDA’s Food Acquisition and Purchase Survey (FoodAPS), which tracked real household food purchases. Where actual purchase data exists, those prices are used. Where they don’t, category-average estimates fill in. A green dollar sign in the food table means a real price; an estimated price is noted otherwise. I’ve updated the values to be inflation adjusted, so hopefully they’re ballpark right.

Dietary restriction filters (vegan, gluten-free, nut-free, and others) are based on USDA food category codes and description matching. The tagging is solid for the clear-cut cases. I would not rely on it for severe allergies without checking the actual product label.

Pile of hiker food including Fritos, Little Bites, and Nature's Bakery bars before a resupply
A pre-trip food haul. No optimizer needed to pick these.

The optimizer is a planning tool, not a shopping list generator. Left unconstrained, it will tell you that 800 grams of sunflower oil plus some macadamia nuts is the most calorie-dense feasible basket. That’s technically correct and practically useless. Use the diversity slider and the grocery store filter to push results toward something you’d actually eat. You can even ban specific foods from appearing.

I’ve found this sort of thing most useful for sanity-checking calorie density and for poking around to see how I should structure my resupplies, and to better identify what sort of nutrient deficiencies I might be experiencing.

Not all resupply towns are created equal, and that gap matters. Grocery store resupplies give you real choices, while gas station resupplies can sometimes feel restrictive. The store type filter in the optimizer is built based on purchase location data in the foodAPS and NHANES datasets, so hopefully lets you model a somewhat more constrained food basket based on what you’ll actually find on the shelf!

Give it a try and let me know if it’s useful!