Is there a formula for calculating partitions with restrictions?

  • Context: Graduate 
  • Thread starter Thread starter oleg-mary
  • Start date Start date
  • Tags Tags
    partitions
Click For Summary

Discussion Overview

The discussion centers around the problem of calculating the number of partitions of an integer N into no more than K parts, each not exceeding L, denoted as p(N,K,L). Participants explore the existence of a formula for this calculation, considering both theoretical and algorithmic approaches.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses difficulty in finding a formula for p(N,K,L) and provides an example calculation for p(7,4,5) which yields 9 partitions.
  • Another participant suggests that it seems unlikely a formula exists for this problem.
  • A different participant mentions that a generating function might be easier to find, although they do not provide a specific formula.
  • One participant clarifies that the original question seeks a formula rather than an algorithm, noting that while algorithms can be created, they may not be efficient for larger parameters.
  • Another participant argues that algorithms can lead to deep recursion issues, particularly with larger parameters, and shares their experience with a custom algorithm that performs adequately for certain large inputs.
  • One participant posits that the problem is a polynomial complexity issue in information theory, suggesting that without a formula, calculations for very large values of N, K, and L will be time-consuming.

Areas of Agreement / Disagreement

Participants generally agree that a straightforward formula for p(N,K,L) has not been discovered and may not exist, while there is contention regarding the feasibility and efficiency of algorithmic approaches to calculate the partitions.

Contextual Notes

Participants note limitations related to the efficiency of algorithms, particularly as parameters increase, and express uncertainty about the existence of a simple formula for the problem.

oleg-mary
Messages
3
Reaction score
0
After long and careful search on the web and in literature,
I could not find the solution of the following problem.

I need calculate p(N,K,L) - the number of partitions of N into
no more than K parts not exceeding L.

Example: N = 7, K = 4, L = 5

1) 2+5
2) 3+4
3) 1+1+5
4) 1+2+4
5) 1+3+3
6) 2+2+3
7) 1+1+1+4
8) 1+1+2+3
9) 1+2+2+2

So, here is p(7,4,5)=9

I found the different formulas for the partitions with different restrictions,
but not both for quantity and size of parts.
May be I was bad looking, but might be the solution has not yet been found?

Of course, it is not a problem to write search algorithms, to solve this problem,
as in Pascal:

*********************************************************************

var K,L,M,i,i1,i2,itog:longint; b:real;
Code:integer;

procedure Box(pr:longint;ostatok:longint;nbox:longint);
var j1,j2,j:longint;
a: real;
begin
a:=ostatok/nbox;
if frac(a)>0
then j1:=trunc(a)+1
else j1:=trunc(a);
if pr>ostatok then j2:=ostatok else j2:= pr;
for j:=j1 to j2 do
if nbox>1 then Box(j,ostatok-j,nbox-1) else itog:=itog+1
end;

begin

val(ParamStr(1),K,Code);
val(ParamStr(2),L,Code);
val(ParamStr(3),M,Code);
{
writeln(K);
writeln(L);
writeln(M);
}
itog:=0;
If L*M<K Then writeln('It is impossible')
Else
begin
If M>K Then i2:=K Else i2:=M;
b:=K/L;
If frac(b)>0 Then i1:=trunc(b)+1 Else i1:=trunc(b);

For i:=i1 to i2 do Box(i,K-i,L-1)

end;
writeln (Itog)
end.

**********************************************************

but it bogged down with a slight increase of parameters.
Roughly speaking, if the value of parameters begins to run into the hundreds,
then modern computer begins to squeak.

Is there some "nice" formula to calculate p(N,K,L) ?
 
Last edited:
Physics news on Phys.org
Nobody knows, but it seems unlikely that a formula exists.
 
Not really answering your question, but a generating function should not be very hard to find.

Also, check out http://www.btinternet.com/~se16/js/partitionstest.htm if you haven't done that already.
 
Last edited by a moderator:
The question was if there is a "nice" formula, not a "nice" algorithm. The formula, for now, isn't discovered, maybe it doesn't exists, but the algorithm to calculate p(n,l,k) is easy to make.
 
Easy-to-make algorithms will go into deep-deep recursion, so it is not easy to make really fast one.
For example, shown code in Pascal will fall even on low parameters like p(200,20,20).
After some thinking I wrote algorithm which gives result in suitable time for p(125000,500,500).
It uses arbitrary length integer arithmetics and gives result of near thousand bits.
But I need about p(millions,thousands,thousands) job.
 
In this case the problem is a P problem in information theory, in other words the time to calculate p(n,l,k) is Polynomial, so it will spend more time to calculate p(millions,thousands,thousands). Only a formula will give you a gift, but it is not discovered yet, and maybe it's likely that it doesn't exist.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
941
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 0 ·
Replies
0
Views
1K