Statistical mechanics of optimization problems