Ways of distributing passengers in ships

239 Views Asked by At

I need help with the following combinatorial problem. There are $ K $ passengers and $ K $ ships. The passengers are denoted by $ U_1, U_2, \dots, U_K $. The objective is to find in how many ways the $ K $ persons can board the ships, with the following conditions:
1) The ships have a maximum capacity of $ N $ passengers
2) There exists at least one ship with exactly $ N $ persons
3) The rest of ships can have an arbitrary number of persons that is less or equal to $ N $ (thus, other ships can have $ 0, 1, 2, \dots, N $ passengers).
4) Not all the ships need to be used.

What matters here is the number of ways in which the persons can be grouped with the constraints above (which ships are used is not relevant). For instance, one case is $ N = K $, when all the persons board one single ship. The remaining $ K-1 $ ships are left empty. Another case is when $ N = 1 $. Thus, each person exclusively boards a different ship (all ships have exactly one person because all the passengers are required to board).

I have one example with $ K = 4 $, where I will denote the passengers by U1, U2, U3 and U4.

Example 1: When $ K = 4 $, $ N = 1 $,

Combination 1: [U1] [U2] [U3] [U4] (the order does not matter).

Example 2: When $ K = 4 $, $ N = 2 $, we have

Combination 1: [U1 U2] [U3] [U4] [empty]

Combination 2: [U1 U3] [U2] [U4] [empty]

Combination 3: [U1 U4] [U2] [U3] [empty]

Combination 4: [U2 U3] [U1] [U4] [empty]

Combination 5: [U2 U4] [U1] [U3] [empty]

Combination 6: [U3 U4] [U1] [U2] [empty]

Combination 7: [U1 U2] [U3 U4] [empty] [empty]

Combination 8: [U1 U3] [U2 U4] [empty] [empty]

Combination 9: [U1 U4] [U2 U3] [empty] [empty]

Example 3: When $ K = 4 $, $ N = 3 $, we have

Combination 1: [U1 U2 U3] [U4] [empty] [empty]

Combination 2: [U1 U2 U4] [U3] [empty] [empty]

Combination 3: [U1 U3 U4] [U2] [empty] [empty]

Combination 4: [U2 U3 U4] [U1] [empty] [empty]

Example 4: When $ K = 4 $, $ N = 4 $, the only way is to put all the passengers in the same ship. Thus, we have

Combination 1: [U1 U2 U3 U4] [empty] [empty] [empty]

Update: Based on Paulo's answer, thus far I have this. In some cases this work but in others do not...

$$ \sum_{\substack{0 < n_1\leq\ldots\leq n_k\leq N\\[2pt]n_1+\ldots+n_k=K}} \frac{1}{(k-1)!} \frac{K!}{n_1!n_2!\cdots n_k!} $$

Useful results:
When $ K = 4 $, $ N = 1 $, the number of combinations is 1
When $ K = 4 $, $ N = 2 $, the number of combinations is 9
When $ K = 4 $, $ N = 3 $, the number of combinations is 4
When $ K = 4 $, $ N = 4 $, the number of combinations is 1

When $ K = 5 $, $ N = 1 $, the number of combinations is 1
When $ K = 5 $, $ N = 2 $, the number of combinations is 25
When $ K = 5 $, $ N = 3 $, the number of combinations is 20
When $ K = 5 $, $ N = 4 $, the number of combinations is 5
When $ K = 5 $, $ N = 5 $, the number of combinations is 1

2

There are 2 best solutions below

11
On

One ship must have $N$ people, which is also the maximum number of people per ship (there are $K\choose N$ ways of doing this). After that, this problem reduces to distributing $K-N$ people by $K-1$ ships, where the maximum number of people per ship is $N$.

The number of ways of dividing $n$ people in one group of $n_1$ people, one group of $n_2$, one of $n_3,\ldots,$ and one of $n_k$ can be shown to be

$$\frac{n!}{n_1!n_2!\cdots n_k!}$$

And now you consider every possible way of choosing how many elements are in each group and you sum all of them, and multiply by the number of ways you can choose the $N$ people for the "fixed" ship: $${K\choose N} \left(\sum_{k=1}^{K-1}\sum_{\substack{0< n_1\leq\ldots\leq n_k\leq N\\[2pt]n_1+\ldots+n_k=K-N}}\frac{\left(K-N\right)!}{n_1!n_2!\cdots n_k!}\right)$$

which I believe to be the answer, but I don't know whether it can be simplified.

I hope this helps.

2
On

The numbers you give for $K = 5$ are correct. You have enough numbers to look up the relevant sequence in the OEIS (On-Line Encyclopedia of Integer Sequences): search for "1,25,20,5,1" and you find a unique sequence A080510. The title of this sequence is "Triangle read by rows: T(n,k) gives the number of set partitions of {1,...,n} with maximum block length k.", which is exactly the problem you're asking for, where the parameter n equals your parameter K, and the parameter k equals your parameter N.

The entry gives you the number of partitions for any (K, N) with K up to 11. You can also see from the entry that there is no simple formula from well-known functions to compute this number, though the text does give you a formula that is fast enough to compute even for large values of N.