In [[computer science]], the '''subset sum problem''' is an important
problem in [[computational complexity theory|complexity theory]] and
[[cryptography]]. The problem is this: given a set of integers, does
the sum of some non-empty subset equal exactly zero? For example,
given the set { −7, −3, −2, 5, 8}, the answer is
''yes'' because the subset { −3, −2, 5} sums to zero. The
problem is [[NP-Complete]].
An equivalent problem is this: given a set of integers and an integer
''s'', does any non-empty subset sum to ''s''? Subset sum can also be
thought of as a special case of the [[knapsack problem]]. One
interesting special case of subset sum is the [[partition problem]],
in which ''s'' is half of the sum of all elements in the set.
== Problem Solution ==
Win a million dollars, solve one of seven Millennium Problems. Seven
great currently unsolved math problems. Favorite Millennium problem
question ‘P vs. NP’. Challenge short, proof problem “hard” (i.e. NP)
true hard or “easy” (i.e. P). Problem express ‘P = NP’ or ‘P != NP’.
For detail describe ‘P vs. NP’, see Wikipedia article.
Hear NP problems. Famous Sales Travel problem, sales find short path
connect cities. Sudoku puzzle Japan. Tetris minesweeper NP problem.
Example class ‘NP-complete’, “easy” solve class result easy solve all
problem. Converse, proof hard, all hard.
Simple NP-complete problem describe ‘subset sum problem’: Give set
integer (both positive and negative), subset sum zero (omit empty).
Simple example:
Set integer (-8, -5, 2, 3, 14) sum zero.
Answer: (-5, 2, 3). Easy? 5 number set! Difficult quick rise start add
number set. If set 100 number, computer year solve. Set 1000 number >
energy universe solution, best algorithm. Best algorithm solution
subset sum problem O(N2^(N/2)) operate (Big-O). Give set 1000 number
solution require 10002^500 operate number hard.
Catch best algorithm solve subset sum problem O(N*2^(N/2)). Proof:
million dollar solution solve NP-complete problem, circuit optimize.
Proof NP-complete problem hard. Cryptograph algorithm base NP-complete
problem. Solve algorithm worth< cryptography.
Describe solution subset sum problem.
Simple algorithm solve subset sum problem. Integer problem set (<2^N),
record possible solution array, zero solution. Create array, compute
possible sum include exclude integer. Trick number operate grow
between large positive sum and large negative sum.
Describe discrete convolute. Integer, create graph 1 both zero (x-
axis) integer. Value zero (y-axis). Two possible integer; add, or do
not include integer add zero. Result convolute intege graph. Result
graph show number solution sum give value.
Example, 3 integer: (2, 3, 5). Convolve value, get solution:
Graph example express array start zero. Simple, positive integer.
Start array [1], solution zero (sum NULL set).
• Add 2: [1] * [101] = [101]
• Add 3: [101] * [1001] = [101101]
• Add 5: [101101] * [100001] = [10110201101]
Result set sum: (0, 2, 3, 5, 7, 8, 10), two get 5. (compute MATLAB’s
convolution operator).
Trick: quick compute convolute Fourier analyze. State different,
possible solution subset sum problem wave. Convolute two function same
product frequency present.
Solve problem involve Fourier transform.
Perform optical Fourier transform shine light small hole measure light
hit wall. Angle diffract depend wavelength light. End result sinc
function (sin(x)/x), Fourier transform square function, present slit.
Present integer beam light frequency correspond integer value,
possible modulate multiple beam light, fourier transform (i.e. shine
diffract grate) combine beam determine possible solution. Physics
solves math problem.
Quantum computer perform Fourier transform, quantum computer quick
solve subset-sum problem. Learn more about quantum computers, stop.
Base physics solve math problem, compute device capable quick solve NP-
complete problem details.
== General discussion ==
The subset sum problem is a good introduction to the NP-complete class
of problems. There are two reasons for this
* It is a [[decision problem|decision]] and not an [[optimization
problem]]
* It has a very simple formal definition and problem statement.
Although the subset sum problem is a decision problem, the cases when
an approximate solution is sufficient have also been studied, in the
field of [[approximation algorithm|approximations algorithms]]; one
algorithm for the approximate version of the subset sum problem is
given below.
A solution that has a ±1% precision is good enough for many physical
problems. However, the number of place values in the problem is
essentially equivalent to the number of simultaneous constraints that
need to be solved. A numerical precision of 1% is approximately
0.00001<sub>2</sub>%, or 7 binary places (any numerical error after
that is less than {{frac|1|128}} of the first digit). However, if
there are 100 binary place values in the problem, solving just 7 of
them amounts to solving only 7% of the constraints. Moreover, given
that the volume of the solution space in this case would be 2<sup>100</
sup>, and you have only covered a volume of 2<sup>7</sup>, then there
is still a solution space of 2<sup>99.999999999999999999999999999854</
sup> (= 1267650600228229401496703205376 - 128) left uncovered. In this
way, a solution with a 1% numerical precision has covered essentially
none of the real problem. The only way that a solution to the subset
sum problem can be used as a solution to other NP problems is to solve
all of the problem (and all of the constraints) exactly.
In cryptography, it is actually important to solve real subset sum
problems exactly. The subset sum problem comes up when a codebreaker
attempts, given a message and [[ciphertext]], to deduce the secret
[[key (cryptography)|key]]. A key that is not equal to but within ±1%
of the real key is essentially useless for the codebreaker due to the
[[avalanche effect]], which causes very similar keys to produce very
different results.
== The complexity of subset sum ==
The complexity (difficulty of solution) of subset sum can be viewed as
depending on two parameters, ''N'', the number of decision variables,
and ''P'', the precision of the problem (stated as the number of
binary place values that it takes to state the problem). (Note: here
the letters ''N'' and ''P'' mean something different than what they
mean in the ''NP'' class of problems.)
The complexity of the best known algorithms is exponential in the
smaller of the two parameters ''N'' and ''P''. Thus, the problem is
most difficult if ''N'' and ''P'' are of the same order. It only
becomes easy if either ''N'' or ''P'' becomes very small.
If ''N'' (the number of variables) is small, then an exhaustive search
for the solution is practical. If ''P'' (the number of place values)
is a small fixed number, then there are dynamic programming algorithms
that can solve it exactly.
What is happening is that the problem becomes seemingly non-
exponential when it is practical to count the entire solution space.
There are two ways to count the solution space in the subset sum
problem. One is to count the number of ways the variables can be
combined. There are 2<sup>N</sup> possible ways to combine the
variables. However, with N = 10, there are only 1024 possible
combinations to check. These can be counted easily with a branching
search. The other way is to count all possible numerical values that
the combinations can take. There are 2<sup>P</sup> possible numerical
sums. However, with P = 5 there are only 32 possible numerical values
that the combinations can take. These can be counted easily with a
dynamic programming algorithm. When N = P and both are large, then
there is no aspect of the solution space that can be counted easily.
Efficient algorithms for both small ''N'' and small ''P'' cases are
given below.
== Exponential time algorithm ==
'There are several ways to solve subset sum in time exponential in N.
The most naïve algorithm would be to cycle through all subsets of N
numbers and, for every one of them, check if the subset sums to the
right number. The running time is of order ''O(2<sup>N</sup>N)'',
since there are ''2<sup>N</sup>'' subsets and, to check each subset,
we need to sum at most ''N'' elements.
A better exponential time algorithm is known, which runs in time
''O(2<sup>N/2</sup>N)''. The algorithm splits arbitrarily the ''N''
elements into two sets of ''N/2'' each. For each of these two sets, it
calculates sums of all ''2<sup>N/2</sup>'' possible subsets of its
elements and stores them in an array of length ''2<sup>N/2</sup>''. It
then sorts each of these two arrays, which can be done in time
''O(2<sup>N/2</sup>N)''. When arrays are sorted, the algorithm can
check if an element of the first array and an element of the second
array sum up to ''s'' in time ''O(2<sup>N/2</sup>)''. To do that, the
algorithm passes through the first array in decreasing order (starting
at the largest element) and the second array in increasing order
(starting at the smallest element). Whenever the sum of the current
element in the first array and the current element in the second array
is more than ''s'', the algorithm moves to the next element in the
first array. If it is less than ''s'', the algorithm moves to the next
element in the second array. If two elements with sum ''s'' are found,
it stops. No better algorithm has been found since Horowitz and Sahni
first published this algorithm in 1974<ref>Ellis Horowitz and Sartaj
Sahni (1974). "Computing Partitions with Applications to the Knapsack
Problem". ''JACM'', Volume 21, Issue 2, 277-292, April 1974</ref>.
== Pseudo-polynomial time dynamic programming solution ==
The problem can be solved as follows using [[dynamic programming]].
Suppose the sequence is
:''x''<sub>1</sub>, ..., ''x<sub>n</sub>''
and we wish to determine if there is a nonempty subset which sums to
0. Let ''N'' be the sum of the negative values and ''P'' the sum of
the positive values. Define the boolean valued function
''Q''(''i'',''s'') to be the value ('''true''' or
'''false''') of
:"there is a nonempty subset of ''x''<sub>1</sub>, ..., ''x<sub>i</
sub>'' which sums to ''s''".
Thus, the solution to the problem is the value of ''Q''(''n'',0).
Clearly, ''Q''(''i'',''s'') = '''false''' if ''s'' < ''N'' or ''s'' >
''P'' so these values do not need to be stored or computed. Create an
array to hold the values ''Q(i,s)'' for ''1 ≤ i ≤ n'' and ''N
≤ s ≤ P''.
The array can now be filled in using a simple recursion. Initially,
for ''N ≤ s ≤ P'', set
:''Q''(1,''s'') := (''x''<sub>1</sub> = ''s'').
Then, for ''i'' = 2, …, ''n'', set
:''Q''(''i'',''s'') := ''Q''(''i''-1,''s'') '''or''' (''x<sub>i</
sub>'' = ''s'') '''or''' ''Q''(''i''-1,''s''-''x<sub>i</sub>'')
for ''N ≤ s ≤ P''.
For each assignment, the values of ''Q'' on the right side are already
known, either because they were stored in the table for the previous
value of ''i'' or because ''Q''(''i''-1,''s''-''x<sub>i</sub>'') =
'''false''' if ''s''-''x<sub>i</sub>'' < ''N'' or ''s''-''x<sub>i</
sub>'' > ''P''. Therefore, the total number of arithmetic operations
is ''O''(''n''(''P'' − ''N'')). For example, if all the values
are ''O''(''n<sup>k</sup>'') for some ''k'', then the time required is
''O''(''n''<sup>''k''+2</sup>'').
This algorithm is easily modified to return the subset with sum 0 if
there is one.
This solution does not count as polynomial time in complexity theory
because ''P-N'' is not polynomial in the ''size'' of the problem,
which is the number of bits used to represent it. This algorithm is
polynomial in the value of N and P, which are exponential in their
numbers of bits.
A more general problem asks for a subset summing to a specified value
(not necessarily 0). It can be solved by a simple modification of the
algorithm above. For the case that each ''x<sub>i</sub>'' is positive
and bounded by the same constant, Pisinger found a linear time
algorithm.<ref name=Pisinger09>Pisinger D (1999). "Linear Time
Algorithms for Knapsack Problems with Bounded Weights". ''Journal of
Algorithms'', Volume 33, Number 1, October 1999, pp. 1-14</ref>
== Polynomial time approximate algorithm ==
An [[approximation algorithm|approximate]] version of the subset sum
would be: given a set of ''N'' numbers ''x<sub>1</sub>'', ''x<sub>2</
sub>'', ..., ''x<sub>N</sub>'' and a number ''s'', output
* yes, if there is a subset that sums up to ''s'';
* no, if there is no subset summing up to a number between ''(1-c)s''
and ''s'' for some small ''c>0'';
* any answer, if there is a subset summing up to a number between ''(1-
c)s'' and ''s'' but no subset summing up to ''s''.
If all numbers are non-negative, the approximate subset sum is
solvable in time polynomial in ''N'' and ''1/c''.
The solution for subset sum also provides the solution for the
original subset sum problem in the case where the numbers are small
(again, for nonnegative numbers). If any sum of the numbers can be
specified with at most ''P'' bits, then solving the problem
approximately with ''c=2<sup>-P</sup>'' is equivalent to solving it
exactly. Then, the polynomial time algorithm for approximate subset
sum becomes an exact algorithm with running time polynomial in ''N''
and ''2<sup>P</sup>'' (i.e., exponential in ''P'').
The algorithm for the approximate subset sum problem is as follows:
initialize a list ''S'' to contain one element 0.
for each ''i'' from 1 to ''N'' do
let ''T'' be a list consisting of ''x<sub>i</sub>+y'', for all
''y'' in ''S''
let ''U'' be the union of ''T'' and ''S''
sort ''U''
make ''S'' empty
let ''y'' be the smallest element of ''U''
add ''y'' to ''S''
for each element ''z'' of ''U'' in increasing order do //trim the
list by eliminating numbers close one to another
if ''y<(1-c/N)z'', set ''y=z'' and add ''z'' to ''S''
if ''S'' contains a number between ''(1-c)s'' and ''s'', output
''yes'', otherwise ''no''
The algorithm is polynomial time because the lists ''S'', ''T'' and
''U'' always remain of size polynomial in ''N'' and ''1/c'' and, as
long as they are of polynomial size, all operations on them can be
done in polynomial time. The size of lists is kept polynomial by the
trimming step, in which we only include a number ''z'' into ''S'' if
the previous ''y'' is at most
:(1 − ''c''/''N'')''z''.
This step ensures that each element in ''S'' is smaller than the next
one by at least a factor of (1 − ''c''/''N'') and any list with
that property is of at most polynomial size.
The algorithm is correct because each step introduces a multiplicative
error of at most (1 −''c''/''N'') and ''N'' steps together
introduce the error of at most
:(1 − ''c''/''N'')<sup>''N''</sup> < 1 − ''c''.
==Further reading==
* {{Introduction to Algorithms|2|chapter=35.5: The subset-sum
problem}}
* {{cite book|author = [[Michael R. Garey]] and [[David S. Johnson]] |
year = 1979 | title = Computers and Intractability: A Guide to the
Theory of NP-Completeness | publisher = W.H. Freeman | isbn =
0-7167-1045-5}} A3.2: SP13, pg.223.
== References ==
{{reflist}}
[[Category:Weakly NP-complete problems]]
[[Category:Dynamic programming]]
[http://www.bandacity.com/gyan/algorithm.html C implementation of
Subset Sum problem]
[[ar:مسألة مجموع المجموعات الجزئية]]
[[de:Untermengensumme]]
[[es:Problema de la suma de subconjuntos]]
[[fa:مسئله جمع زیرمجموعهها]]
[[fr:Problème de la somme de sous-ensembles]]
[[ko:부분집합 합 문제]]
[[ja:部分和問題]]
[[pl:Problem sumy podzbioru]]
[[tr:Alt küme toplamı problemi]]
[[zh:子集合加總問題]]
[ .. snip garbage .. ]
So our troll Musatov has even managed to screw up a Wikipedia page:
http://en.wikipedia.org/wiki/Subset_sum_problem
Han de Bruijn
Well Han you know what they say, one man's trash is another man's
treasure.
Fuck you, worthless troll.
And (guffaw) what happenned to the hard copy you
submitted to (guffaw) the Clay Institute.?. Are they
done laughing yet.?
"Martin 'Musatov' Mersenne" <marty....@gmail.com> wrote in message
news:199df697-8484-44ce...@r21g2000prr.googlegroups.com...
I, Martin 'Musatov' the Moran, I has learned to arrange to arrange
letters and symbols into lines of text, and post those aformentioned
lines of text consisting of letters and symbols to a newsfroup. I
can has glee?
Dear Jamie,
Fine Sir or Miss I am not sure because of testicle factor, you
understand I am sure. :)
This is for you:
Results 1 - 10 for You, OTOH, have a reverse Midas touch: you take-
in .... (0.26 seconds)
Musatov Solves Subset-Sum Wikipedia Acknowledges Solution - sci ...6
posts - 4 authors - Last post: 9 hours ago
Asshole: You, OTOH, have a reverse Midas touch: you take-in treasure,
and output garbage. Fuck you, worthless troll. ...
groups.google.com/group/sci.math/.../6a84e14d5f696c8d?... - 9 hours
ago
You Won't Believe How Much The Nissan Leaf Will Save You | The ...Apr
6, 2010 ... I don't know what world you have been living in, but OIL
certainly does .... OTOH the Japanese are simply more efficient doing
things. ..... How many years does it take to pay off the additional
charge of that upgrade? ..... you have Randians who think that the
government is a kind of reverse-Midas. ...
www.thetruthaboutcars.com/you-won’t-believe-how-much-the-nissan-leaf-will-save-you/
Damn Interesting • Eugenics and YouMy take is that everyone has a lot
of potential and if you use that potential ...... OTOH said: “Here's
an idea for population control and positive eugenics: ...... I often
pondered what he would make of the “reverse-selection” (my own made
up ...... The Midas touch holds great power but no comfort. Pace
yourself! ...
www.damninteresting.com/eugenics-and-you
Slashdot Mobile Story | Microsoft Quickly Revises "Sexting" Ad
For ...Apr 17, 2010 ... from the anti-midas-touch dept. ..... OTOH,
this is changing. There was a time not so long ago when we could ....
Have you ever heard the saying "all publicity is good publicity? ...
Reverse Streisand effect? (Score:3, Interesting) .... What you take
pictures of and how easy it is to take them are ...
mobile.slashdot.org/.../Microsoft-Quickly-Revises-Sexting-Ad-For-Kin-
Phone?...
ExhaustIf you have to change the gasket be prepared to get new bolts/
studs and keep a stud .... OTOH, if you break one stud in the process,
might as well replace them all. ... If you can't then I suggest taking
it to Midas or somewhere that .... It will take a gentle touch and
some time. Once the muffler pipe is off, ...
www.swedishbricks.net/700900FAQ/Exhaust1.html
Michelle Malkin » Out: Commie Truther green jobs czar. In:
Union ...Sep 8, 2009 ... They have a personal relationship with him.
But if you go to the laid off ... my observation is that government
has a “reverse midas touch”. .... We have to keep up the pressure on
these traitors and continue to take them out. .... Gold, otoh, is over
$1000/ounce again. So what does Chauncey do? ...
michellemalkin.com/.../out-commie-truther-green-jobs-czar-in-union-
hack-manufacturing-czar/
Inflation Prospects In An Emerging Market, Like The U.S. « The ...Apr
6, 2009 ... OTOH, the credit bubble was so big that it appears to my
untrained eye to ... Notably, there may be reverse causation – that
is, inflation is a _response_ ... Simple time series models do not
account for this; you need an .... We have the Midas touch. Lobster
for everyone- breakfast, lunch & dinner. ...
baselinescenario.com/.../inflation-prospects-in-an-emerging-market-
like-the-us/
Are you on this list? : PharyngulaThey have the reverse Midas touch.
Everything they touch turns to shit. ..... If you decide to take up
the challenge, you'd be the first of her fans to do ...... OTOH, you
aren't very good at listening, so I wouldn't expect to rise too ...
scienceblogs.com/pharyngula/2008/06/are_you_on_this_list.php
Overcoming Bias : Porn vs Romance NovelsOct 31, 2008 ... Read hers and
feel like the reverse of a woman reading Tom Clancy. ... Men, get in
touch with your feminine side and choose a woman who prefers detective
novels to ... OTOH there's an old guard of feminists who despise
romance novels as ... Hey, have you people read Erin McCarthy's
Romance novel, ...
www.overcomingbias.com/2008/10/porn-vs-romance.html
CaulerpaFAQ3Try to take care when extracting the Caulerpa, as ripping
the fronds can leach ... Check w/your LFS and see if they'll order it
for you. OTOH, if you have a tang ..... Keep the mud, run the lights
on a reverse period, don't use Caulerpa, .... You might also want to
try a blenny, like the "Midas Blenny" (Ecsenius ...
www.wetwebmedia.com/caulerpafaq3.htm
1 2 3 4 5 6 7 8 9 10 Next
> then he hangs himself, and we all live happily after.
If you think I don't know who you are and what you are doing, you are deluding
yourself.
Your time has come, at last.
Run and hide, because what's coming out for you will cause you to beg for mercy
little insignificant man.
Sure I am.
>
> Your time has come, at last.
Sure.
>
> Run and hide, because what's coming out for you will
> cause you to beg for mercy
> little insignificant man.
>
I'll be waiting for you stupid bitch.
>> Run and hide, because what's coming out for you will
>> cause you to beg for mercy
>> little insignificant man.
>>
> I'll be waiting for you stupid bitch.
Next time when you wake up your testicles will be swollen from the kicks you'll
receive, little, insignificant, and boring man.
Make sure you count the kicks you'll receive.
I loved you in cool runningks you'll receive.
Night I spent with your mom.
kicks you'll
> > receive, little, insignificant, and boring man.
Not as interesting as you.?. I'll get over it, LOSER.
> >
> > Make sure you count the kic
<yawn> Shut the fuck up, LOSER.<yawn>
>
>
>
> I loved you in cool runningks you'll receive.
<yawn> Give it up. Aren't two failed movies enough.?
Who else will you sleep with to get a new movie done.?
>
I don't know I never sent it. I am too busy learning to want to quite say here is the result.
Thanks for asking. I hope you learn to speak like a human.
Why would I be afraid of what has no name?
Wow, what a worthless hypocrit: you trash this site,
make it hard-to-use for many, and you feel you have
the authority to chide others.
I hope you learn to think about anyone but yourself,
you worthless , criminally-insane fuckwit. And that
you stop your cowardly defacing.
Go drink some poison, you worthless FUCK.
Learning at everyone else's expense, worthless motherfucker. That is why many tried to do a new site
to avoid you. You are a pushover, a pest, a parasite.
Stop pretending you are doing this to help
anyone but yourself, and go catch testicle cancer,
you worthless fuck.
because you have no conscience (not to mention
talent,nor intelligence but that is another story.)
I am waiting for you, smart man.
I own you.
agtProve or give example: three space dimensions time initial velocity
field vector velocity scalar pressure field smooth global define solve
Navier–Stokes equations.
Try owning a single neuron first, fuckwit.
> agtProve
Learn how to speak English, you fucking imbecile..
I don't go advancing my career by shitting on others
like you do. Unlike you, I have a conscience. Unlike
you, I face up to what I do.
youre nobody to.org
You're nobody. Period.
How embarrassing: dumping your unwanted garbage here:
why.?. Because no one has _any_ interest in _anything_
you say or do. Because you are completely worthless.
Go shoot yourself, you amoral loser.