The non-rigorous cavity method of statistical mechanics, originally developed in the study of spin glasses and other disordered systems, has led to a number of purely mathematical predictions. Several of them can be found in the remarkable book  by Marc Mézard, Giorgio Parisi and Miguel Angel Virasoro. Establishing these predictions rigorously remains a challenge to probability theory. Important achievements in this direction are David Aldous’ proof of the ζ(2) limit in the assignment problem , Michel Talagrand’s proof of the correctness of the Parisi solution of the Sherrington-Kirkpatrick model [9, 24], and the algorithmic and theoretical results on phase transitions in constraint satisfaction problems [1, 2, 18]. One of the areas where the statistical mechanics view has produced a number of challenging conjectures is optimization in mean field models of distance. In the simplest of these models there are n vertices labeled 1, . . . , n. Each pair of vertices is connected by an edge, and the edges (i, j) are assigned i. i. d. random costs Xi,j (sometimes thought of as representing distance) from a given distribution μ on the nonnegative real numbers. In general one is interested in the large n (“thermodynamical”) limit of the cost of a solution to a combinatorial optimization problem. I will describe a mathematically rigorous method whose underlying idea resembles the cavity method. Several new results have been established with this method, some of which were anticipated by the cavity approach. For instance we have established the “mean field limit” for the traveling salesman problem, conjectured in [11, 14, 15].