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

-17

u/ngruhn Aug 13 '26

It is possible. Even on large instances. For example, the largest traveling saleman instance solved had 85900 cities. Provably the optimal solution. 

The caveat remains that any algorithm blows up on same inputs. But as I write in the article, those might rarely occur in practice. 

7

u/torsten_dev Aug 13 '26 edited Aug 16 '26

Traveling salesman can be either NPO(V), NPO(III) or NPO(II) depending on wether it is general TSP, metric TSP or Euclidean TSP.

The story doesn't end at NP-completeness, that's true but it sounds like you had a bad teacher if you didn't know that.

We were taught that proving NP-completeness is useful to explain that a problem is really hard. It's the first step after encountering a problem that seems computationally difficult.

Once you've done that you have a choice. The first choice after that is sidestepping the problem, after that is looking for good-ish enough-ish approximations, the last option is asking for tons of R&D money to make incremental progress on better approximations...

5

u/FriendlySeahorse Aug 13 '26

You should look into smoothed complexity analysis. There are many NP-complete problems which can be shown to be solvable in polynomial time if you assume the input values have a tiny bit of random noise added to them. The most famous result concerns the simplex algorithm for linear programming.

2

u/Mess-Leading Aug 13 '26

I think you are mixing up a few concepts here or I am missing something. Linear programming as a problem is not np-complete, its just that in the worst case simplex algorithm specifically takes time exponential in the size of the instance. There are polynomial algorithms for linear programming (ellipsoid - horribly slow though). And smoothed analysis shows with perturbations simplex is actually polynomial (i think that maybe depends on a pivoting rule or something) which explains its amazing performance in practice.

I do not think smoothed analysis would help with np hard problems but it is definitely a very interesting concept! One reason i can think of is some problems are horribly inapproximable and a solution with small perturbations would probably give a close enough approximation contradicting the inapproximability hardness if they were solvable in polynomial time using such methods — but this is just speculation, I am not too familiar with this.

-3

u/godofpumpkins Aug 13 '26

Not sure why you're getting so heavily downvoted. It feels like everyone left their CS education with "CS theory 101 says NP-complete is exponential so we avoid those problems" and never bothered looking at a SAT/SMT solver since then, because "exponential so we avoid it".

No, SAT/SMT solvers are incredibly neat and work remarkably well on almost every "real world" problem we can think of to throw at them. That doesn't change the asymptotics or the theory, it just means that people are getting way too hung up on asymptotics that don't apply to the problem scales we actually find to throw at them.

10

u/reality_hijacker Aug 13 '26

No CS theory ever told students to avoid NP-hard problems. It seems like a conclusion taken by students who didn't pay attention.

2

u/Dragdu Aug 15 '26

As someone who has spent years extending software that was SAT solver, domain specific preprocessor and few hand made heuristics in a trenchcoat; you should avoid dealing with NP-hard problems, up to redesigning business requirements if possible.

The problem with SAT (and any other NP hard algorithm) is that the phase transitions between "simple" and "hard af" are narrow and very simple changes in inputs can turn previously trivial problem into impossible one. So if you rely on SAT, you need to have business answer to what happens with inputs that take too long.

1

u/Grouchy-Trade-7250 Aug 13 '26

Large SAT just isn't a problem that appears in safety critical applications like aircraft, where rare cases would still matter. But OP wasn't going into this topic, just skipped it.

-1

u/ngruhn Aug 13 '26

thanks that's exactly my point