Pergunta

As I understand, the assignment problem is in P as the Hungarian algorithm can solve it in polynomial time - O(n3). I also understand that the assignment problem is an integer linear programming problem, but the Wikipedia page states that this is NP-Hard. To me, this implies the assignment problem is in NP-Hard.

But surely the assignment problem can't be in both P and NP-Hard, otherwise P would equal NP? Does the Wikipedia page simply mean that the general algorithm for solving all ILP problems is NP-Hard? A few other sources state that ILP is NP-Hard so this is really confusing my understanding of complexity classes in general.

Foi útil?

Solução

If a problem is NP-Hard it means that there exists a class of instances of that problem whose are NP-Hard. It is perfectly possible for other specific classes of instances to be solvable in polynomial time.

Consider for example the problem of finding a 3-coloration of a graph. It is a well-known NP-Hard problem. Now imagine that its instances are restricted to graphs that are, for example, trees. Clearly you can easily find a 3-coloration of a tree in polynomial time (indeed you can also find a 2-coloration).

Consider decision problems for a second. A method of proving the hardness of a decision problem $P$ is devising a polynomial (Karp) reduction from another problem $Q$ that is known to be NP-Hard. In this reduction you show that there exists a function $f$ that maps each instance $q$ of the problem $Q$ to an instance of the problem $P$ such that: $q$ is a yes instance for $Q \iff f(q)$ is a yes instance for $P$. This implies that solving $f(q)$ must be "at least as difficult" as solving $q$ itself.

Notice how it's not required for the image of $f$ to be equal to the set of the instances of $P$ . Therefore it's perfectly possibile for problem $P$ restricted to some subset of instances to not be hard.

To return to your original question:

  • The assignment problem can be solved in polynomial time, i.e., a solution to each instance of the assignment problem can be computed in polynomial time.
  • ILP is NP-Hard: in general it might be hard to compute a solution to an ILP problem, i.e. there are instances of ILP that are hard.
  • Some specific instances of ILP can be solved in polynomial time.

Outras dicas

No, special cases can be easier.

Consider this IP, for example, given $a_i \geq 0$ for $i \in [1..n]$:

$\qquad\displaystyle \min \sum_{i=1}^n x_ia_i$

s.t. $\quad\displaystyle\sum_{i=1}^n x_i \geq 1$
and $\ \displaystyle x_i \in \mathbb{N}$ for $i \in [1..n]$.

It finds the minimum among $a_1, \dots, a_n$ (that for which, inevitably, $x_i=1$ in an optimal solution). Finding the minium of $n$ numbers is clearly a polynomial problem.

You can model a polynomially solvable problem as an IP. This does not mean the problem is NP-hard. It simply means that there is no known polynomial algorithm for solving the IP model of your problem (unless P=NP).

So as you suggested, the assignment problem is in P but your IP model of it is NP-hard.

No, there are a special kind of integer program, if the constraint matrix is TUM (totally unimodular matrix), then it can be relaxed into the linear program, which can be solved in polynomial time.

The assignment problem is not a ILP, but an LP problem and therefore not NP-hard.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a cs.stackexchange
scroll top