Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ brute-force reference or a closed-form value and has a regression test.
offers the polished solution as a candidate. `lower` and `certified` are unchanged. At
`(p, q) = (0.836, 0.788)` in the binary two-state family the bound at `k = 3` is 0.15563 (11 s), and the
polished solution is a generator of entropy 0.15571, 0.43 bits below `C_mu`.
- `generator_global_bound(..., weight_box=(lo0, hi0, lo1, hi1))` confines the two heaviest (sorted) weights to
a box, for covers of their region by boxes solved one at a time. On two 3-state processes the solve at `k = 5`
over the whole region stopped after three hours with its dual bound at 95% and 98% of the objective limit.

### Belief-free generator search

Expand Down
5 changes: 4 additions & 1 deletion docs/generators/generative_models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,10 @@ Restricted global bound
spatial branch and bound :cite:`Achterberg2009,Vigerske2018` through PySCIPOpt :cite:`Maher2016`.
With the bidirectional edge chain it adds two-step path flows and the two-step edge law. The
weights are sorted, so caps on the heaviest states enter as linear cuts, and an objective limit
(the entropy of a verified generator) lets SCIP prune. The result bounds the state entropy of every
(the entropy of a verified generator) lets SCIP prune. ``weight_box`` confines the two heaviest
weights to a box, so boxes covering the region those weights can take, each solved alone, bound
every generator with at most ``k`` states where one solve over the whole region does not finish
in time. The result bounds the state entropy of every
generator with at most ``k`` states and says nothing about larger ones. It is therefore a lower
bound on :math:`C_g` only once the number of states of a minimal generator is bounded. No general
bound is known, and :math:`\min(|S^+|, |S^-|) + 1` is not one: the skip-one chain (under
Expand Down
14 changes: 14 additions & 0 deletions sofic/generators/global_bound.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ def generator_global_bound(
objective_limit: float | None = None,
two_step: bool = True,
caps: Sequence[float] = (),
weight_box: Sequence[float] | None = None,
time_limit: float | None = None,
data_tol: float = 1e-7,
pi_min: float = 1e-7,
Expand All @@ -283,6 +284,12 @@ def generator_global_bound(
linear cuts. Each entropy term is evaluated at :math:`\max(\pi_w, \text{pi\_min})`, which overestimates it by
at most :math:`\text{pi\_min} \log_2(1/\text{pi\_min})`; ``slack`` (``k`` times that) is subtracted.

``weight_box`` ``(lo0, hi0, lo1, hi1)`` confines the two heaviest weights to
:math:`\text{lo0} \le \pi_0 \le \text{hi0}` and :math:`\text{lo1} \le \pi_1 \le \text{hi1}`. The result then
speaks only for generators whose two heaviest weights lie in the box, and boxes covering the region those
weights can take, each solved alone, bound every generator with at most ``k`` states where one solve over
the whole region may not finish.

``objective_limit`` (e.g. the entropy of a verified generator) lets SCIP prune everything above it; when it
then reports ``"infeasible"``, no generator with at most ``k`` states has entropy below
``objective_limit - slack``. ``time_limit`` (seconds) stops SCIP early; the dual bound reached is still valid.
Expand Down Expand Up @@ -369,6 +376,13 @@ def data_eq(lhs: Any, rhs: float) -> None:
m.addCons(Z[w, b] == quicksum(F[w, x, v] * R[v, c] for x, c in tgt for v in W))
for j, cap in enumerate(list(caps)[:k]):
m.addCons(quicksum(pi[w] for w in range(j + 1)) <= float(cap))
if weight_box is not None:
lo0, hi0, lo1, hi1 = (float(t) for t in weight_box)
m.addCons(pi[0] >= lo0)
m.addCons(pi[0] <= hi0)
if k > 1:
m.addCons(pi[1] >= lo1)
m.addCons(pi[1] <= hi1)
if Pe2 is not None:
V = {(w, x, v, y, u): m.addVar(lb=0, ub=1) for w in W for x in X for v in W for y in X for u in W}
VQ = {(*key, a): m.addVar(lb=0, ub=1) for key in V for a in A}
Expand Down
11 changes: 11 additions & 0 deletions tests/test_global_bound.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ def test_objective_limit_semantics(scip) -> None:
assert above.primal == pytest.approx(C_MU_GOLDEN, abs=1e-4)


def test_weight_box_confines_the_two_heaviest_weights(scip) -> None:
"""The golden mean's 2-state optimum has weights (2/3, 1/3)."""
bidir = _bidir(_two_state(*GOLDEN_MEAN))
inside = gb.generator_global_bound(bidir, 2, objective_limit=C_MU_GOLDEN + 0.03, weight_box=(0.6, 0.7, 0.3, 0.4))
assert inside.status == "optimal"
assert C_MU_GOLDEN - 1e-4 <= inside.lower <= C_MU_GOLDEN + 1e-9
assert inside.seed[0][0] == pytest.approx(2 / 3, abs=1e-4)
outside = gb.generator_global_bound(bidir, 2, objective_limit=C_MU_GOLDEN + 0.03, weight_box=(0.8, 0.9, 0.1, 0.2))
assert outside.status == "infeasible" and outside.seed is None


def test_pattern_c_point_bound_and_polish(scip) -> None:
"""At (p, q) = (0.836, 0.788) a 3-state generator of entropy H(1 - 2y, y, y) beats C_mu by 0.43 bits."""
from sofic.generators.coupled_generators import CoupledSearchResult, _GeneratorProblem, _model_from_kernel
Expand Down
Loading