You have just proved your problem
This page is the map of that choice. Every exact algorithm for an NP-hard problem
secretly relies on all four of these being true at once: it is optimal, it works on
every input, it runs in polynomial time, and it is deterministic. If
Think of intractability as a locked box with four hinges. You cannot open it head-on, but loosen any one hinge and the lid swings free. Each hinge is a whole sub-field of algorithms.
| Give up… | …and you get | Idea in one line | Follow it up |
|---|---|---|---|
| Optimality | Approximation algorithms | Provably within a factor |
|
| Guarantees | Heuristics & metaheuristics | Local search, simulated annealing, genetic algorithms — usually great, no promise. | see below |
| Generality | Special-case & parameterised algorithms | Fast whenever some parameter |
|
| Speed | Exact exponential algorithms | Still exponential, but |
|
| Determinism | Randomised algorithms | Flip coins; be right with high probability, or right in expected poly time. | |
| Worst case | Average-case tractability | The hard instances are vanishingly rare; typical inputs solve fast. |
No single hinge is the "right" one — the choice is engineering, not mathematics. A compiler's register allocator quietly restricts to structured (chordal) interference graphs; a chip-placement tool runs simulated annealing overnight and takes what it gets; a SAT solver combines branch-and-bound with randomised restarts and routinely dispatches instances with millions of variables that are, in the worst case, hopeless.
The most disciplined surrender is optimality. An
A heuristic or metaheuristic — hill-climbing, tabu search, simulated annealing, genetic algorithms, ant-colony optimisation — also runs fast and is often stunningly good in practice, but offers no worst-case promise at all. You trade the certificate for flexibility: heuristics apply to messy real objectives that have no clean approximation theory. Rule of thumb: reach for an approximation algorithm when you need a guarantee to put in a contract; reach for a metaheuristic when you just need a good answer and the objective is ugly.
"NP-complete" is a claim about the general problem. Your instances are almost never general. Two of the most powerful coping strategies both live here:
Sometimes you truly need the exact optimum — a provably minimum-cost chip layout, an exact model count.
Then keep optimality and generality, and surrender polynomial time as gracefully as possible.
Two subtler trades round out the toolbox. Randomisation gives up determinism: a coin-flipping algorithm can be simpler and faster, correct with probability you can drive as close to 1 as you like. And average-case tractability gives up the worst case: if the hard instances are astronomically rare, an algorithm that is exponential in theory can be effectively instant on the inputs you will ever actually see. This is why SAT and integer-programming solvers feel magical despite the grim theory.
Wonderfully, no — and this is one of the deepest surprises in the whole field. NP-completeness is
about finding the exact optimum; approximation is a genuinely different, and often much
easier, question. Some problems admit an approximation ratio as tight as you please
(a
The single most expensive misconception a working engineer can hold is that "NP-complete" means "give up." It does not. It means the general problem has no known algorithm that is simultaneously optimal, universal, fast and deterministic — a worst-case statement about an adversarially chosen input. Your input is not adversarial. TSP instances with tens of thousands of cities are solved to proven optimality daily; industrial SAT instances with millions of variables fall in seconds. Conversely, do not swing to the opposite error and assume a heuristic's good behaviour on your test set is a guarantee — only an approximation algorithm's proof, or an exact solver's certificate, gives you that. Know which one you have.
The pages ahead take the trades one at a time.