Tinto#
How long does a self-stabilizing graph coloring take to settle? Tinto measures it with a Numba-compiled Monte Carlo over pluggable graphs, guards, schedulers and recoloring rules, down to the variance and skewness of the stabilization time. For the conflict-guard rule under the random central daemon, it also provides exact results.
Free software: MIT
Documentation: https://balouf.github.io/tinto/.
Github: balouf/tinto
Features#
Numba-compiled dynamics: CSR graphs (line, ring, uniform labeled tree, Erdős-Rényi
G(n, p), bipartiteG(n1, n2, p)), pluggable guards, four schedulers (shuffled, ordered, Bernoulli, independent) and five colorers (lowest, next or uniform free color, plus two blind variants that may leave clashes behind).Monte-Carlo driver aggregating mean, variance and third central moment of both the number of steps and the number of activations before stabilization, on a fixed graph or on a fresh random graph per replica.
Experimenthigh-level API with cartesian-product sweeps, campaign addition, light matplotlib plotting, CSV export, and fits of the results (weighted least squares, test for a hidden term, recovery of exact fractions).Exact stabilization time of the conflict-guard rule under the random central daemon, from three independent sources: the peak oracle, which samples it without running the dynamics (
tinto.oracle), exact enumeration on small graphs (tinto.exact) and closed forms (tinto.theory).Companion notebooks that check the numerical statements of the papers.
100% branch-covered by doctest-based examples.
Quickstart#
Install Tinto:
$ pip install tinto
Low-level API#
Drive one trajectory on a line graph:
>>> from tinto import graphs, configs, schedulers, solvers, runners
>>> from tinto.io import set_seed
>>> set_seed(0)
>>> Config = configs.make()
>>> c = Config(graphs.line(20))
>>> sched = schedulers.shuffled()(c)
>>> solver = solvers.make()
>>> steps, activations = runners.simple(c, sched, solver)
>>> steps > 0
True
>>> c.total
0
Or Monte-Carlo the moments of both metrics over many replicas:
>>> from tinto import starters
>>> set_seed(0)
>>> starter = starters.from_graph(Config)(graphs.line(20))
>>> res = runners.mc(starter, schedulers.shuffled(), solver, n_trials=20)
>>> mean, var, m3 = res["steps"]
>>> mean > 0
True
High-level API#
The Experiment class bundles a sweep + the Monte-Carlo runner + plot
and export helpers. Define an Iterator over one parameter, wrap it in
an Experiment, run:
>>> from tinto import Experiment, Iterator
>>> def build_starter(n):
... return starters.from_graph(Config)(graphs.line(n))
>>> n_iter = Iterator("starter", [10, 20, 50], name="n", process=build_starter)
>>> exp = Experiment(
... "line-sweep",
... iterator=n_iter,
... scheduler=schedulers.shuffled(),
... solver=solver,
... n_trials=50,
... )
>>> _ = exp.run(progress=False)
>>> exp.results["line-sweep"]["axes"]
('starter',)
Compose cartesian products with * and combine multiple campaigns with
+:
>>> kind_iter = Iterator("starter", ["random", "mono"], name="kind")
>>> # plot or export via exp.plot(x="n", hue="kind") / exp.to_csv(...)
Credits#
This package was created with Cookiecutter and the Package Helper 3 project template.