An application of combinatorial optimization to statistical physics and circuit layout design