evaluate_branching_tree

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,
)[source]#

The root’s per-action G under sophisticated (closed-loop) planning.

Each child is scored by the use_bound point of its step tree (zero when empty) and, short of the horizon, branched by branch_fn over its m outcomes (m = 1 without 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 = 0 below the deepest children. Returns G at the root, (b,). The deepest level holds (b·m)^(H−1)·b beliefs.

legal is a bool (horizon, b): legal[t, a] false gives action a at depth t ≥ 1 the value +∞ in that node’s softmax, so it carries no weight in V; the tree still expands it. Row 0 is not read: the root’s G is returned unmasked. A mask with no true entry in a row has no action to weigh at that depth, and gives NaN. With batch_size set, the (b·m)^split_depth nodes at depth split_depth (1 ≤ split_depth ≤ horizon − 1) have their subtrees evaluated that many at a time with jax.lax.map() instead of all at once; the result is the same up to float rounding, and the deepest level held at once shrinks to batch_size subtrees.