Formula for How many combinations we can have from two sets with restrictions

combinatoricsextremal-combinatorics

Find the formula:

Let $A=\{1,2,…,27\}$ and $B=\{28,29, …,50\}$.

How many combinations we can have from two sets: A and B; such that to obtain subsets of 7 elements, where 5 elements belongs to A and 2 to B, with restrictions that $2$ elements (pair) in one resulted subset should not repeat in other resulted subset.

How to find the formula such way that I can use restrictions variables as parameters for this formula. By restriction variables I mean those $5$ elements from $A$ and $2$ from $B$, and limit of $2$ elements that should not repeat in subsets results.

I suppose that the first thing I should do is to find all the possible combinations without restrictions, which will represent the biggest set. Then I should find subsets from biggest set which matches separate restriction. And finally, exclude subsets from biggest set. So that we can find the total amount of combinations we look for.

If this is true, then I should calculate Combinations from $N$ elements = $A$ Length, grouped by $5$.

For example:

{1,2,3,4,5,6,28} and {1,2,3,4,5,7,28} violates the restriction because the pair {1,2} repeats. Other example is {1,2,3,4,5,6,28} and {1,2,6,7,8,9,29} also violates the restriction because {1,2} repeats.

Please help, to find how to achieve this, as I'm not sure.

Best Answer

If I understand correctly, you can solve this as a set packing problem. For $S\subset \{1,\dots,50\}$ with $|S \cap A|=5$ and $|S \cap B|=2$, let binary variable $x_S$ indicate whether set $S$ is selected. The problem is to maximize $\sum_S x_S$ subject to: $$\sum_{S: \{i,j\} \subset S} x_S \le 1 \quad \text{for $1\le i<j\le 50$}$$

Related Question