I'm preparing for my exam and I got stuck on the following problem:
The gardening problem:
We have access to a set of different types of seeds and a number of plant pots.For each plant pot, there is a limit to how many seeds can be planted in that particular pot.
In addition, there are seeds that cannot be planted in the same pot. These requirements are described by a list of pairs of seeds that do not want to be planted in the same pot. Each seed is featured in at least one pair in the list.
The goal is to plant as many different types of seeds as possible, given the number of seeds that can be planted in each pot and a list of pairs of seeds that can't grow in the same pot.
I am supposed to formulate the gardening problem as a decision problem by introducing a goal K, and then show that this decision problem is NP-complete. I must show that it is included in NP and by designing a polynomial Karp reduction between the NP-complete problem Independent set and the gardening problem.
In order to show that a problem is included in NP I know that I must show that a given solution can be verified in polynomial time (this doesn't seem too difficult). It's the Karp reduction I'm a bit unsure how to do and need help with. I get confused by the different capacities of the pots.
My solution so far:
The gardening problem as a decision problem:
Input: List including the seed limit of each pot M=[m1,m2,...,mn], a list of pairs of seeds P={{fi, fj}} that cannot be planted together, positive integer K (goal).
Question: Is it possible to plant at least K different types of seeds?
(Should I exclude the "at least"?)
In order to show that the problem is NP-hard I need to reduce the NP-complete problem Independent set to the gardening problem.
IndependentSet(G=(V,E), K')= M ← [K'] // Only one pot with capacity of K' P ← E K ← K' return GardeningProblem(M, P, K)
The reduction is polynomial. I want to show that it is correct, i.e. there exists an independent set I with K nodes iff there exists seedbed S with K seeds that can be planted together.
If there is a solution to the IS problem of size K, we can put the K corresponding seeds into our pot - therefor if we can't put K seeds in our pot, there is no independent subset of size K.
Assume that I is an independent set in G with K nodes. Let S be the corresponding seeds I. Take two arbitrary seeds fi and fj in S and show that they can be planted together. The fact that I is an independent set means that:
vi,vj ∈ I → (vi, vj) ∉ E → {fi, fj} ∉ P → fi and fj can be planted together.
The other implication, assume there exists a seedbed S where |S| = K and seeds that can be planted together. Then:
fi,fj ∈ S → {fi, fj} ∉ P → (vi, vj) ∉ E → vi and vj are independent.
Thus, the proof is complete.
I get a bit confused by the fact that the pots can have different capacities, and I don't really know how to work with that. It feels like I am missing something and that I should take the different capacities of the pots into consideration in the proof. It is supposed to be an easy problem. Is there a better way to solve this?
And when I formulate the gardening problem as a decision problem, I'm not sure if the "Question" should be "...at least K different types of seeds" or just "...K different types of seeds" ? How do I know which one is correct?
If someone could tell me if something is missing it would be greatly appreciated!