<jupyter_start><jupyter_text>Importing Paganini<jupyter_code>import paganini
from paganini import *<jupyter_output><empty_output><jupyter_text>`Paganini` is a package for tuning multiparametric combinatorial systems$$\begin{align*}T_1(z_1, \ldots, z_d) &= \Phi_1(T_1, \ldots, T_n, z_1, \ldots, z_d)\\T_2(z_1, \ldots, z_d) &= \Phi_2(T_1, \ldots, T_n, z_1, \ldots, z_d)\\& \cdots \\T_n(z_1, \ldots, z_d) &= \Phi_n(T_1, \ldots, T_n, z_1, \ldots, z_d)\\\end{align*}$$$$    z_1 \dfrac{\partial T_1}{\partial z_1} = \mathbb E \pi_1,    \quad    z_2 \dfrac{\partial T_1}{\partial z_2} = \mathbb E \pi_2,    \quad    \ldots,    \quad    z_d \dfrac{\partial T_1}{\partial z_d} = \mathbb E \pi_d.$$  First example: Catalan trees $T = z\dfrac{1}{1 - T}$<jupyter_code>Catalan  = Specification()
z, T     = Variable(), Variable()
Catalan.add(T, z * Seq(T))<jupyter_output><empty_output><jupyter_text>Detecting the singular values of `z` and `T`:$$    T^2 - T + z = 0,    \quad    T = \dfrac{1 \pm \sqrt{1 - 4z}}{2}$$<jupyter_code>Catalan.run_singular_tuner(z)
z.value
T.value
del(z, T, Catalan)<jupyter_output><empty_output><jupyter_text>Second example: multiparametric case $$M = z + uzM + z M^2$$<jupyter_code>Motzkin = Specification()
z, u, M = Variable(1000), Variable(200), Variable()
Motzkin.add(M, z + u * z * M + z * M ** 2)
Motzkin.run_tuner(M)
print(z.value, u.value, M.value)
del(z,u,M, Motzkin)<jupyter_output><empty_output><jupyter_text>Third example: MSet trees with degree constraints$$\newcommand{\pu}[1]{\color{blue}{1}}\begin{align*}M_1 &= \pu{u_1}  z   \operatorname{MSet}(\pu{u_4} M_2) , \\M_2 &= \pu{u_2}  z^2 \operatorname{MSet}(M_3) , \\M_3 &= z^3  \operatorname{MSet}(\pu{u_3} M_2) . \\\end{align*}$$<jupyter_code>spec             = Specification()
sizes            = [200, 200, 200, 100]
z                = Variable(1000)
[u1, u2, u3, u4] = [Variable(size) for size in sizes]
[M1, M2, M3]     = [Variable() for i in range(3)]
spec.add(M1, u1 * z      * MSet(u4 * M2))
spec.add(M2, u2 * z ** 2 * MSet(M3))
spec.add(M3,      z ** 3 * MSet( u3 * M1))
spec.run_tuner(z)
z.value
[u1.value, u2.value, u3.value, u4.value]
[M1.value, M2.value, M3.value]
del(z, u1, u2, u3, u4, M1, M2, M3, spec)<jupyter_output><empty_output><jupyter_text>Impossible tuning problem :: Binary treesBinary trees with a given number of leaves$$    T = z  + z u T^2$$<jupyter_code>Binary = Specification()
z, T   = [Variable() for i in range(2)]
u      = Variable(0.501)
Binary.add(T, z + z * u * T ** 2)
Binary.run_singular_tuner(z)
z.value
T.value<jupyter_output><empty_output><jupyter_text>Impossible tuning problem :: mixture of intervals? $$    F = Seq(Z^3) \times Seq(U Z^3) + Seq(U^2 Z^3) \times Seq(U^3 Z^3)$$ >**Tip.** The tuning is in ***expectation***<jupyter_code>Impossible = Specification()
params     = Params(Type.RATIONAL)

z, u, F    = Variable(3), Variable(2), Variable()
Impossible.add(F, Seq(z**3) * Seq(u * z**3) + Seq(u**2 * z**3) * Seq(u**3 * z**3))
Impossible.run_tuner(F, params)
print([z.value, u.value])
z.set_expectation(30)
u.set_expectation(20)
Impossible.run_tuner(F, params)
print([z.value, u.value])
Impossible = Specification()

z, u, F = Variable(), Variable(1/6), Variable()
Impossible.add(F, Seq(       z**3) * Seq(u    * z**3) +
                  Seq(u**2 * z**3) * Seq(u**3 * z**3))
Impossible.run_singular_tuner(z)<jupyter_output><empty_output><jupyter_text>Tutorials and manuals<jupyter_code>import paganini
help(paganini)
help(paganini.tutorial)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18885714285714286, 'fraction_numerical': 0.038857142857142854, 'mean_word_length': 4.386153846153846, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '137415', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1586, 'n_tokens_neox': 1498, 'n_words': 316, 'path': 'demo/Tutorial.ipynb', 'repo_name': 'maciej-bendkowski/paganini', 'size': '3500'}