evaluate_branching_tree#
- hybrid_aif.planning.evaluate_branching_tree(
- actions,
- horizon,
- gamma,
- init_qs,
- transition_fn,
- step_terms,
- terminal_terms=None,
- branch_fn=None,
- use_bound='midpoint',
- legal=None,
- split_depth=1,
- batch_size=None,
The root’s per-action G under sophisticated (closed-loop) planning.
Each child is scored by the
use_boundpoint of its step tree (zero when empty) and, short of the horizon, branched bybranch_fnover itsmoutcomes (m = 1without a branch closure); the last depth adds the terminal terms. The fold runs bottom-up:G(node, a) = g_step(child) + Σ_o p(child, o) · V(child, o) V(node) = Σ_a softmax(−γ · G(node, ·))_a · G(node, a)
with
V = 0below the deepest children. ReturnsGat the root,(b,). The deepest level holds(b·m)^(H−1)·bbeliefs.legalis a bool(horizon, b):legal[t, a]false gives actionaat deptht ≥ 1the value+∞in that node’s softmax, so it carries no weight inV; the tree still expands it. Row 0 is not read: the root’sGis returned unmasked. A mask with no true entry in a row has no action to weigh at that depth, and givesNaN. Withbatch_sizeset, the(b·m)^split_depthnodes at depthsplit_depth(1 ≤split_depth≤horizon − 1) have their subtrees evaluated that many at a time withjax.lax.map()instead of all at once; the result is the same up to float rounding, and the deepest level held at once shrinks tobatch_sizesubtrees.