"""Illustration only: sizes of the fixed-partition balanced families for moderate n
(r = 1), compared with C(n,t) (all t-sets) and the lower bound kappa = C(n,t)/C(k,t).
Balance of these families is guaranteed by Theorem 9.6 of the paper; for n = 16 it is
also verified here by LP on a random sample of k-sets.
Run: python size_demo.py"""
import math, random, itertools
from balanced import product_family, restrict, lp_balance

rng = random.Random(5)
for n, ell, k, t in [(16, 4, 8, 4), (16, 4, 8, 2), (18, 6, 9, 3), (20, 5, 10, 3)]:
    fam, nt = product_family(n, ell, (k,), (t,))
    kappa = math.comb(n, t) / math.comb(k, t)
    line = f'n={n} ell={ell} k={k} t={t}: distinct |F|={len(fam)}, tuples={nt}, C(n,t)={math.comb(n,t)}, kappa={kappa:.1f}'
    if n == 16:
        worst = min(lp_balance(restrict(fam, [set(S)], (t,)), [set(S)], (t,))
                    for S in (rng.sample(range(n), k) for _ in range(300)))
        line += f'; LP ratio on 300 random k-sets >= {worst:.6f}'
    print(line, flush=True)
