The cavity method has proved useful in solving optimization problems such as k-satisfiability and graph coloring. It has yielded not only ground states energy predictions in the average case but has also inspired algorithmic methods.