Heuristic for optimizer.