| # Formulation and implementation |
|
|
| Let a finite rooted DAG encode executable paths within a resource budget. Each canonical outcome has one terminal node. The prescribed endpoint law is `pi(y) = r(y) / sum(r)`. Among path distributions with that endpoint law, minimize expected execution cost minus route temperature times conditional path entropy. |
|
|
| The optimal conditional route probability is proportional to `exp(-C(path)/tau)` among paths to the same outcome. Its normalization is a prefix partition evaluated at the terminal node. The exact prefix recursion is |
|
|
| $$v(s_0)=0,\qquad v(s)=\log\sum_{e:u\to s}\exp\{v(u)-c(e)/\tau\}.$$ |
|
|
| The backward edge law is the softmax of predecessor values minus edge costs divided by temperature. Products of these probabilities telescope to the conditional route law. Terminal demand starts at `pi`, propagates backward through this law, and is reversed to obtain an exact forward policy. |
|
|
| The neural implementation uses separate two-layer SiLU networks for prefix values and forward edge logits. Prefix fitting uses detached log-sum-exp targets over every incoming edge. The root value is fixed to zero. Forward training minimizes squared trajectory-balance residuals with the backward probabilities detached. A mixture of current and uniform policies collects paths. Every training run uses a fixed graph, reward vector, and temperature. |
|
|
| The normalizer is initialized to the log of the outcome count plus the mean log reward and remains trainable. This initialization improves the scalar warmup on the small reaction graph. The implementation records the resulting training history. `--initialize` reuses network parameters for another reward vector on the same graph. `--resume` restores network and optimizer state for the same run. |
|
|
| ## Error statements |
|
|
| The manuscript proves the unique conditional optimum and a decomposition of endpoint and route error. If the absolute trajectory residual is at most eta over every feasible path, the endpoint TV is at most `tanh(eta)`. If every prefix-recursion residual is also at most epsilon and path length is at most H edges, joint KL is at most `2 eta + 2 H epsilon`. At exact trajectory balance, the conditional objective excess is at most `2 tau H epsilon`. |
|
|
| These are full-support deterministic statements. Minibatch loss measurements are recorded training diagnostics. The code tests the identities on exactly enumerable graphs and compares dynamic programming against explicit path sums. |
|
|
| For a learned sampler whose endpoint law differs from pi, the reported conditional gap is |
|
|
| $$\tau\sum_y P_Y(y)\,\mathrm{KL}\bigl(P(\cdot\mid y)\Vert Q^*(\cdot\mid y)\bigr).$$ |
| |
| It equals temperature times joint KL minus endpoint KL. This metric separates route quality from endpoint distribution error. At exact endpoint alignment, it equals the difference in the constrained objective. |
| |
| ## Computational scope |
| |
| The algorithms use complete incoming and outgoing edge sets on the stored graph. Graph materialization and oracle scoring precede learning in the reference workflow. Dynamic-programming passes are linear in stored nodes and edges. Molecular expansion can grow rapidly with the parent inventory, reagent count, and reaction budget. |
| |
| The executable graph is the declared support of a run. Full-catalog coverage requires a complete expansion or another complete predecessor construction. The current repository implements materialized graphs and records the selected inventory. Distributed catalog expansion, sampled predecessor estimation, and a single model jointly conditioned on multiple graph budgets remain extensions. |
| |