Refining the graph
The graph influences how good the certificate can be and how much it costs, and a generic graph pays for nodes everywhere: the De Bruijn graph of order $k$ has $M^k$ nodes whatever the system, and on the running example, orders 3 and 4 double the nodes for no better bound (see Choosing a graph). Comparing graphs tells whether a graph is at least as good as another, not which graph suits the system at hand. Refinement builds the graph for the system, from its own certificate (Athanasopoulos and Jungers, 2019; Ninite and Jungers, 2026). It runs on stability only.
The code on this page uses the running example of Systems and problems: system, and problem = StabilityProblem(system), solved with Clarabel.
The loop
Refinement lifts the graph at the tight edges of its certificate, those whose edge inequality is active (see Reading a certificate). From a path-complete graph $G_0$, by default the common graph, step $t$:
- computes the best rate $\gamma_t$ on $G_t$, with the template.
- stops if $\gamma_t$ is proved optimal, or no longer improves.
- reads the tight edges of the certificate on $G_t$.
- lifts $G_t$ where the strategy chooses from them, into $G_{t+1}$, and stops if the strategy finds nowhere to lift.
With the two strategies of the package, every step is a split or a product, valid for every template (see Lifts), so the rate never increases, up to the bisection tolerance. A lifted graph is path-complete without a new check: path-completeness is checked on the first graph only.
In one call
refine(template, problem; optimizer) runs the loop from the common graph, and refine(template, graph, problem; optimizer) from your graph:
trace = refine(QuadraticTemplate(), problem; optimizer = Clarabel.Optimizer)
rates(trace), n_nodes.(graphs(trace)), n_edges.(graphs(trace))([0.9586944580078125, 0.871798038482666, 0.8688297271728516], [1, 2, 3], [2, 4, 6])In two steps, the rate drops from about $0.959$ to $0.869$ with 3 nodes and 6 edges. The De Bruijn hierarchy needs order 2, with 4 nodes and 8 edges, for the same bound:
order_2 = de_bruijn(2, 2)
rate = certify(QuadraticTemplate(), order_2, problem; optimizer = Clarabel.Optimizer).rate
rate, n_nodes(order_2), n_edges(order_2)(0.8688297271728516, 4, 8)The strategies
The keyword strategy chooses where to lift.
Tightest node splitting, the default
TightestNodeSplitting follows Algorithm 1 of Ninite and Jungers (2026), whose results say where to lift:
- Only the tight edges matter. The tight edges alone give the same rate (Ninite and Jungers, 2026; Prop. 1), so the graph is lifted where they are.
- A node with a single tight outgoing edge is not worth splitting. Splitting it cannot lower the rate (Ninite and Jungers, 2026; Prop. 3), and a node with two or more may.
So the strategy splits the node with the most tight outgoing edges, among those with at least two, into one copy per outgoing edge, with OutSplitLift. Among nodes with the same number of tight outgoing edges, it splits the one with the fewest outgoing edges, which adds the fewest nodes. This split, one copy per outgoing edge, is finer than the paper's, and Prop. 3 still holds for it. From the common graph, the first step gives the dual De Bruijn graph of order 1. When no node has two tight outgoing edges, the rate is the joint spectral radius (Ninite and Jungers, 2026; Thm. 4), and the run stops.
Best of tight-edge lifts
BestOfTightEdgeLifts follows (Athanasopoulos and Jungers, 2019; Ex. 2). It applies the four local lifts of Lifts, the splits and the products, at every tight edge, one edge at a time, solves every candidate graph, and keeps the one with the lowest rate. A step costs one bisection per candidate, so up to four per tight edge.
Your own strategy
A new strategy subtypes AbstractRefinementStrategy and implements next_graph. From the current certificate, it returns the next graph, or nothing when it finds nowhere to lift, which stops the run:
import PathCompleteCertificates: next_graph
struct MyStrategy <: AbstractRefinementStrategy end
function next_graph(::MyStrategy, certificate; atol, solve)
tight = tight_subgraph(certificate; atol)
L = ... # a lift, such as OutSplitLift()
node = ... # where to apply it, such as a node of `tight`
return lift(L, get_graph(certificate), node), nothing
endEdges with slack at most atol are tight. The next graph comes as a pair. The first element is the Lifted graph. The second is its certificate, if the strategy already solved it with solve, as BestOfTightEdgeLifts does, or nothing, in which case refine solves it. A strategy starts from the common graph, unless it defines initial_graph(strategy, system). Extending the package says where the file goes.
When it stops
status(trace) says why the run stopped:
| Status | The run stopped because |
|---|---|
OPTIMAL | the rate is proved to be the joint spectral radius, within gap_tol |
STALLED | stall_max steps in a row did not lower the rate by a fraction rtol |
DEPTH_REACHED | depth_max graphs were visited |
STOPPED | the stop predicate held, for example c -> c.rate < 1 |
EXHAUSTED | the strategy found no next graph |
status(trace)OPTIMAL::RefinementStatus = 0On the running example, the run stops with OPTIMAL. On its three nodes, every node has one tight outgoing edge, so the rate $0.869$ is the joint spectral radius of the system, reached and proved in two steps.
The trace
The RefinementTrace keeps every step: certificates, graphs, rates, and steps, each step a Lifted graph with the origins of its nodes.
Three tolerances drive the run: rtol and atol, as for a single certificate (see Reading a certificate), and gap_tol, the gap between the rate and its lower bound at which the run stops. refine throws unless atol is at least ten times rtol.