How can I enumerate the number of ways of distributing distinct groups of identical objects (but various cardinality) into $k$ boxes such that at most one box is empty $(1)$ and no combination of objects is repeated between boxes ?
The order of objects inside their box or the order of boxes do not matter : $\begin{array}{|l|l|} \hline \circ\bullet & \bullet \\ \hline \end{array} = \begin{array}{|l|l|} \hline \bullet & \circ\bullet \\ \hline \end{array}$
The only way I found to solve this was to generate all partitions, filter them and finally count the elements. This is impracticable when $n$ or $p$ increase. Is there a way to count the possibilities without enumerating them ?
Example: There are 7 ways in which $\{\circ,\circ,\circ,\circ,\bullet,\bullet\}$ can be distributed in 4 boxes.
$ \begin{array}{|l|l|l|l|} \hline \varnothing & \circ & \circ\circ & \circ\bullet\bullet \\ \hline \varnothing & \circ & \circ\circ\circ & \bullet\bullet \\ \hline \varnothing & \circ & \bullet & \circ\circ\circ\bullet \\ \hline \varnothing & \circ & \circ\bullet & \circ\circ\bullet \\ \hline \varnothing & \bullet & \circ\circ & \circ\circ\bullet \\ \hline \varnothing & \bullet & \circ\bullet & \circ\circ\circ \\ \hline \circ & \bullet & \circ\circ & \circ\bullet \\ \hline \end{array} $
Edit: Ignoring the "one box can be empty"-condition and if all objects are distinct, this is solved with the Stirling number of 2nd kind $\lbrace{n\atop k}\rbrace$. But since some objects are distinguishable ($\circ,\bullet$) and some are not ($\circ,\circ$) I do not know if this is a real lead.
Edit: Users on the chat indicated me that this problem is similar to counting orbits of a group of actions, counting partitions of a multiset and prime factorization.
Edit: This answer provides a working result using the Polya Enumeration Theorem although it is far from computable for high values $(2)$. Let $n=\prod_{i=1}^r p_i^{a_i}$, $r$ being the number of type of balls (colors), $p_i$ some unique prime (different for each type) and $a_i$ the number of balls of this type. Then the given function $G(n,k)$ is my answer.
Edit: Following the idea that this is similar to a factorization problem, this paper may be of use. This function gives the number of unordered factorizations with distinct parts and largest part at most $m$ : $$g(m,n)=\sum_{\substack{d|n \\ d\leq m}} g(d,n/d)$$ with $g(m,1)=1$ and $g(1,n)=0$ for $n\neq 1$. And then $f(n)=g(n,n)$ gives the total number of unordered factorizations with distinct parts. For $\{\circ,\circ,\circ,\circ,\bullet,\bullet\}$, it gives us $f(2^4 \times 3^2)=14$ factorizations. It might be possible to adapt the previous formula to keep only the factorizations of $k$ or $k-1$ integers.
Edit: The desired function is called $P_d(k,n)$ in this paper. Although they don't have a formula for it, they state that $H_d(n)=\sum_k k! P_d(k,n)$ where $H_d(n)=\sum_{k=1}^{\lfloor\log_2 n \rfloor} H_d'(k,n)$ is the total number of distinct ordered factorizations and $$H_d'(k+1,n) = k! \sum_{j=0}^k \frac{(-1)^j}{(k-1-j)!} \sum H_d \left(k-j,\frac{n}{d}\right)$$ where the inside sum is taken over all $d$ such that $d|n$ and for $d\geq 2$, $d$ is a $(j+1)$-st power is the number of ordered factorizations of $n$ into $k$ distinct parts.
$(1)$ This condition could be ignored since we can sum the number of combinations for $k$ and $k-1$.
$(2)$ I am working with $k\approx50$, $r\approx1000$ and $a\in[1;10000]$.