Skip to content

Restricted global bound: SCIP lower bound for generators with at most k states - #72

Merged
Autoplectic merged 2 commits into
mainfrom
scip-global-bound
Nov 21, 2026
Merged

Autoplectic merged 2 commits into
mainfrom
scip-global-bound

Conversation

@Autoplectic

Copy link
Copy Markdown
Member

Summary

  • New module sofic.generators.global_bound:
    • generator_global_bound(bidir | problem, k, *, objective_limit=None, two_step=True, caps=(), time_limit=None, data_tol=1e-7, pi_min=1e-7) minimizes the state entropy over the coupled generator equations for k states, written in the flows F(w, x, v) = pi_w K(x, v | w), with SCIP's spatial branch and bound through PySCIPOpt (Achterberg 2009; Vigerske & Gleixner 2018; Maher et al. 2016).
    • The model has the one-step equations, with the data equalities relaxed by data_tol, an entropy epigraph, sorted weights (so the caps become linear cuts) and an optional objective limit. With the bidirectional edge chain it adds two-step path flows and the two-step edge law. This is ported from the cpfci prototype, minus the three-step flows (no gain) and the term cuts (a false infeasibility on n3-t035-d0).
    • Each entropy term is evaluated at s_w = max(pi_w, pi_min) (pi <= s <= pi + pi_min), so states of tiny weight still pay. The overestimate k pi_min log2(1/pi_min) is reported as slack and subtracted.
    • GlobalBoundResult.lower bounds the state entropy of every generator with at most k states, and only those. It is limit - slack when SCIP proves infeasibility under an objective limit, inf when no point exists at all, and otherwise the dual bound minus slack. The docstrings say it is numerical, not a certificate, and a lower bound on C_g only once the number of states of a minimal generator is bounded (open).
    • PySCIPOpt is a new optional extra, sofic[global], imported lazily; a missing install raises an ImportError that names the extra.
  • hmm_generator_search(..., initial=[T]) adds starts from given k-state HMMs. Their rounds keep the entropy term off, so they move to a nearby generator: from a SCIP solution the entropy descent stalls at an infeasible point (residual 6e-4 at every floor), while the feasibility rounds reach the generator exactly.
  • generative_model / generative_model_from_bidirectional get global_bound=False and global_bound_states=None (default min(|S+|, |S-|) + 1). The new stage runs after the belief-free search with half the remaining budget (120 s without a budget). It uses the best candidate's entropy as the objective limit and is skipped above 2,000 SCIP variables, for the Wyner objective, and when PySCIPOpt is missing. It records restricted_lower and restricted_states (also in the reliability summary) and offers the polished SCIP solution as a candidate. lower and certified are unchanged.

Why

Every certified minimal generator in the binary 2-/3-state dataset has at most |S+| + 1 states, but no bound on the number of states of a minimal generator is proved. Until one is, a global bound over k-state generators is the strongest numerical evidence available about C_g beyond the certified lower bounds, and its solution is a good upper-bound seed. In the pipeline smoke run at (p, q) = (0.836, 0.788) in the two-state family (C_mu = 0.5866):

quantity value
certified lower (excess entropy, coverage off) 0.0017
restricted_lower, k = 3, two-step (SCIP optimal, 12 s) 0.155627
new verified upper (polished SCIP solution, reproduction error 9e-11) 0.155712
closed-form 3-state generator H(1 - 2y, y, y) 0.155708

So no generator with at most 3 states does 1e-4 bits better than the polished one, which beats C_mu by 0.43 bits.

Tests

  • New tests/test_global_bound.py (SCIP tests skip via pytest.importorskip("pyscipopt")):
    • golden mean: k = 1 is infeasible (lower = inf), k = 2 gives C_mu to within the slack;
    • objective-limit semantics: below C_mu it is infeasible with lower = limit - slack; above, it is optimal;
    • (0.836, 0.788) at k = 3: H_C - 2e-4 <= lower <= H_C, and the polished solution is within 1e-5 of H_C and passes the exact difference-automaton check (about 12 s);
    • pipeline: restricted_* are recorded, lower, lower_source and certified match the run without the stage;
    • missing PySCIPOpt (monkeypatched): the ImportError names sofic[global], and the pipeline logs the skip.
  • tests/test_hmm_search.py: initial= recovers the ε-machine from a 5% multiplicative perturbation (entries within 1e-6), and a wrong shape raises ValueError.
  • Full default suite locally: 2871 passed, 9 skipped (6 min, -n 10). ruff check, ruff format --check and ty check pass; sphinx-build -W builds clean.

CI: the main test job now installs --extra global (pyscipopt 6.3.0 has wheels for CPython 3.11–3.14 on Linux, macOS and Windows). The job without the symbolic extra still runs without it, so the skips are exercised there.

Docs: a "Restricted global bound" subsection under Lower bounds in docs/generators/generative_models.rst, plus API entries. It states that the two-step flows and the restricted use are not from the literature. Achterberg2009, Vigerske2018 and Maher2016 are added to docs/references.bib, with their DOIs checked against Crossref. The CHANGELOG is updated.

Ryan James and others added 2 commits November 21, 2026 11:18
…polished into a candidate by the belief-free search

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@Autoplectic
Autoplectic merged commit 7a1f298 into main Nov 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant