0
$\begingroup$

I have this problem which is described as follows:

Input: You are given a multi-set $M$ (a set that can contain duplicates), and two numbers $P$ and $T$. $M = {(x_1,y_1), (x_2,y_2), ..., (x_n,y_n)}$. Each $x$ and $y$ is an integer $>= 0$. $P$ in an integer $>= 0$. $T$ is an integer $> 0$.

Question: Is there a subset $G$ of $M$, such that the sum of every $x$ value of $G$ is $> P$ and the sum of every $y$ value of $G$ is $< T$? (Note: You are basically taking from $M$. For example: if $M$ has two $(1,1)$'s then $G$ can contain at most two $(1, 1)$'s)

I want to reduce it to from the subset sum problem, but I am not sure how because there's two conditions to solve for...

Can anyone help with this problem?

$\endgroup$
2
$\begingroup$

Suppose that you have an instance of SUBSET SUM:

$0 \leq x_1, x_2, ..., x_n$ and an integer $0 \leq t$

You must find $b_i \in \{0,1\}$ such that $b_1*x_1+b_2*x_2+...+b_n*x_n = t$

Which is equivalent to:
$b_1*x_1+b_2*x_2+...+b_n*x_n \geq t$ AND $b_1*x_1+b_2*x_2+...+b_n*x_n \leq t$

$b_1*x_1+b_2*x_2+...+b_n*x_n > t-1$ AND $b_1*x_1+b_2*x_2+...+b_n*x_n < t+1$

pick $P=t-1$, $T=t+1$, $M = \{ (x1,x1),....,(x_n,x_n)\}$

$\endgroup$
  • $\begingroup$ I don't think I follow, can you explain more please? $\endgroup$ – omega Mar 24 '13 at 18:38
  • $\begingroup$ but what if an instance of the original problem has $P=5$ and $T=10$, then how can you pick a $t$ in your version? $\endgroup$ – omega Mar 24 '13 at 18:54
  • 1
    $\begingroup$ @omega: but you ask to reduce FROM subset sum problem, so you should start from an instance of subset sum and then build an instance of your problem from it. And this is a (correct) way to prove that your problem is NP-complete. If you start from an instance of your problem and want to build an equivalent subset sum instance, then you are asking to reduce TO subset sum. $\endgroup$ – Vor Mar 24 '13 at 18:57
  • $\begingroup$ ok I see how your version starts from a subset sum problem, then makes an instance of my problem from it, but to show polynomial equivalence, I believe you also need to start with my problem and then make an instance of the subset sum problem. This will show a proof of my problems NP-hardness. $\endgroup$ – omega Mar 24 '13 at 19:01
  • $\begingroup$ No, my algorithm is trivially polynomial time: it just builds the list of pairs $(x_i,x_i)$ (and this can be done in linear time $O(n)$). With a polynomial time reduction you prove that your problem is NP-hard (you should spend a few words proving that the instance of your problem built using the reduction has a solution if and only if the original subset sum problem has a solution). In order to show that it is NP-complete you must also show that it is in NP, but it easy to see that given a solution to your problem, it can be verified in polynomial time. $\endgroup$ – Vor Mar 24 '13 at 19:10
1
$\begingroup$

I think to be the same problem as with the sum of the series.
So, for example, if there is a set $G_1$, such that the sum of all x > P ($G_1=\{(x,y): \sum{x} > P\}$) and then a set of $G_2$ such that the sum of all y < T ($G_2=\{(x,y): \sum{y} < T\}$), then i think the set of G is the intersection of these two sets ($G = {G_1\bigcap{G_2}}$). These sets can be more, depending on the sum of the many ways to create.
And if it depends on which element is to be taken, it should be a set of sets such that if $ G = {G_1\bigcap{G_2}} = {(x_1, y_1),(x_2, y_2),...: (x_1, y_1)\space contained\space k_1 times, (x_1, y_1)\space contained\space k_2\space times,...}$, then you can create $k_1k_2k_3...$ sets.
I think this depends on the specific need for the processing of the result(s).
If $M=\{(1, 1), (1,1)\}$, and $P=1$, $T=3$ then $G_1=\{(x,y): \sum{x} > 1\} = M$, $G_2=\{(x,y): \sum{y} < 3\} = M$ and $G = G_1\bigcap{G_2} = M$.
If $M=\{(1, 1), (1,1)\}$, and $P=1$, $T=2$ then $G_1=\{(x,y): \sum{x} > 1\} = M$, $G_2=\{(x,y): \sum{y} < 2\} = {(1,1)}$ and $G = G_1\bigcap{G_2} = {(1,1)}$ and is irrelevant if $G$ contains first or second pair.

$\endgroup$
  • $\begingroup$ For your $G_1$ and $G_2$, can't each of them be potentially different sizes? Because what if $M={(1,2), (1,3), (2,3)}$ and $P=1$, then $G_1$ can have different combinations. $\endgroup$ – omega Mar 24 '13 at 19:07
  • $\begingroup$ They can be different sizes. The sum can be created in several ways. Each way is different $G_1$ set. Maybe is better write $G_i^1$ and $G_j^2$ $\endgroup$ – Stefan Babos Mar 24 '13 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.