The famous Traveling Salesman math puzzle is much more than just a fun game. It’s a dramatically illustrated way to understand the efficiencies involved in product distribution models. The problem works like this: Take a map and draw dozens of dots on it. The salesman’s task is to define a driving route that visits each dot, with the minimum driving distance connecting them all. He has to visit so many locations, and he wants to burn as little gas as possible. Obviously this is something that people are looking at harder than ever today.

There’s a very cool piece of freeware software that uses a genetic algorithm to solve the Traveling Salesman problem. It’s by Michael Lalena and is found at http://www.lalena.com/AI/Tsp/. Draw dozens (or hundreds) of dots, and the software will start with a random route and then refine it iteratively until it’s super efficient. It’s fun trying to stump it with a zillion dots in a pattern that appears to be hard to traverse, and then to see what a surprisingly simple curve it finds to visit them all.

Many years ago I did some consulting for a company that was then called Henry’s Marketplace, a produce retailer built on the founding principles of locally grown food. They had grown from a single family fruit stand into a chain of stores throughout southern California and Arizona that stuck to its guns and sold produce from small, local farmers. It’s a business beloved by its customers for its image of wholesome family goodness, community, and healthful products. (Henry’s has since gone through several acquisitions and is now called Henry’s Farmers Markets.)

Part of what I helped them with was the management of product at distribution centers. This sparked a question: I had assumed that their “locally grown produce” model meant that they used no distribution centers. What followed was a fascinating conversation where I learned part of the economics of locally grown produce. It was an eye-opening experience.

In their early days, they did indeed follow a true farmers’ market model. Farmers would either deliver their product directly to the store, or they would send a truck out to each farmer. As they added store locations, they continued practicing direct delivery between farmer and store. Adding a store in a new town meant finding a new local farmer for each type of produce in that town. Usually this was impossible: Customers don’t live in the same places where farms are found. Farms are usually located between towns. So Henry’s ended up sending a number of trucks from different stores to the same farm. Soon, Henry’s found that the model of minimal driving distance between each farm and each store resulted in a rat’s nest of redundant driving routes crisscrossing everywhere. What was intended to be efficient, local, and friendly, turned out to be not just inefficient, but grossly inefficient. Henry’s was burning huge amounts of diesel that they didn’t need to burn.

You can guess what happened. They began combining routes. This meant fewer, larger trucks, and less diesel burned. They experimented with a distribution center to serve some of their closely clustered stores. The distribution center added a certain amount of time and labor to the process, but it (a) still accomplished same-day morning delivery from farm to store, and (b) cut down on mileage tremendously. Henry’s added larger distribution centers, and realized even better efficiency. Today their model of distributing locally grown produce, on the same day it comes from the farm, is hardly distinguishable from the models of Wal-Mart or any other large retailer.

Here’s where it seems counterintuitive: If you look at the path traveled by any one given box of produce, it’s much longer than it used to be. It no longer travels in a single straight line from farm to store; it now travels the two long sides of the triangle in its path from farm to distribution center to store. But quite obviously, this narrow view omits the overall picture, where the stores are all stocked with produce that got there much more efficiently.

Locally grown produce is rarely efficient. Apply a little mathematics to the problem, and you’ll find that the ugly alternative of giant suburban distribution centers accomplishes the same thing – fresh produce into stores on the same day it’s picked – but with much less fuel burned.

This even extends to local farmers’ markets like you may have in your town, where all the family farmers personally bring their produce to the market to sell. Imagine a map with the market in the center, and the round-trip routes driven by all ~20 vendors radiating out from the market, like the arms of a starfish. Applying our Traveling Salesman model to this map, it’s clear that the farmers’ market is the least efficient model possible, if you are measuring efficiency in terms of delivery miles driven and gallons of diesel burned. To properly restructure this model to be as efficient as its proponents believe it to be, you’d drive a single truck in a calculated route to visit each farm in the morning, sell all the goods in a single store, and then discard or donate the leftover food (why double the driving miles to return perishable goods to the farmers?).

Don’t get me wrong, I love farmers’ markets. We go to our local one sometimes and it’s a fun family event for us. We love the giant, wonderful tomatoes and strawberries that you can’t get at the supermarket. I’d hate to see the experience replaced by the efficient alternative I just described, but then, I understand that farmers’ markets are more of a premium boutique community experience than an efficient (or “green”) way to buy food. The real reasons to enjoy your farmers’ market have nothing to do with it being somehow magically environmentally friendly. It’s the opposite.

Too often, environmentalists are satisfied with the mere appearance and accoutrements of environmentalism, without regard for the underlying facts. Apply some mathematics and some economics, and you’ll find that a smaller environmental footprint is the natural result of improved efficiency.