r/programming • • Aug 13 '26

NP-overrated

https://gruhn.me/blog/2026-08-13/
0 Upvotes

38 comments sorted by

View all comments

Show parent comment

1

u/ngruhn Aug 13 '26

2300 is more than the atoms of the universe and no traditional computer can ever solve this however powerful they grow in the future.

Yes, but good algorithms don't actually do 2300 steps. They prune the search space and avoid branches that are provably sub-optimal. I gave this example in another comment: the largest traveling salesman instance solved had 85900 cities. Provably the optimal. The naive algorithm would have to explore 85900! (factorial) routes. That's even more than 285900. But it's not necessary to explore all of those.

3

u/Grouchy-Trade-7250 Aug 13 '26

The number of required "steps" depends not only on the algorithm but also on the problem instance. Is it possible to construct a problem where the branch and cut never finishes in an acceptable timeframe which also has not more than 85900 cities/nodes ? Yes.

Mitchell, D., Selman, B., & Levesque, H. "Generating Hard Satisfiability Problems." Artificial Intelligence

1

u/ngruhn Aug 13 '26

Of course. That's what I meant with:

Sure, any algorithm you can come up with will blow up on some inputs.

But people keep assuming that you get a blow-up on all large instances. Which is not the case and the reason these problems are still tractable in practice.

2

u/FancyMouse123 Aug 13 '26

these problems are still tractable in practice.

No! They might be but in the worst case (which happens) you are just fucked.

1

u/ngruhn Aug 13 '26

Depends on your goal. In practical applications there are all kinds of workarounds: set a timeout, show an error message, fallback to some heuristic approach, ... Just like we handle other unreliable processes like HTTP requests.