PlannerContext#
- class hybrid_aif.planning.PlannerContext[source]#
Bases:
NamedTupleEverything a System offers a planner for a single
infer_policiescall.The posterior is
q_pi ∝ softmax(-gamma * G + policy_prior). Anactionis an int32(K,)vector, one level per control node in node order, unlesscontinuous_controlsis set: then every node is continuous, the step is the float(action_dim,)flat vector, its boxcontinuous_controls.bounds, and every level count is1. A space mixing discrete and continuous nodes has no flat form: the planner"mixed"searches it and the other built-in planners refuse it (refuse_mixed()). The propertiesnum_controlsandcontrolledread the same space in the formenumerate_policies()takes, soenumerate_policies(ctx.num_controls, ctx.policy_len, ctx.controlled)is the grid.- transition_fn: Callable[[Any, Array], Any]#
transition_fn(qs, action) -> qs: pushes beliefs through one control step.
- step_terms_fn: Callable[[Any, Array, Array], dict[str, dict[str, Interval]]]#
step_terms_fn(qs, action, t) -> TermTree: scores post-transition beliefs.
- terminal_terms_fn: Callable[[Any], dict[str, dict[str, Interval]]] | None#
terminal_terms_fn(qs_final) -> TermTree, orNone: scores the horizon end.
- controls: ControlTable#
The System’s
ControlTable.
- levels: tuple[int, ...]#
Each control node’s level count (
1for every node undercontinuous_controls).
- policy_prior: Array | Categorical | object | None#
The prior over policies (
SystemParams.policy_prior).
- continuous_controls: ControlLayout | None#
The flat layout of an all-continuous control space, or
None.
- habit_fn: Callable[[Any, Array], Array] | None#
habit_fn(beliefs, key) -> control step: set exactly whenpolicy_prioris a policy module.
- branch_fn: Callable[[Any], tuple[Array, Any]] | None#
branch_fn(beliefs) -> (p, beliefs_after): set exactly when the System declaresbranch_on;phas shape(n,)over the joint outcomes andbeliefs_aftera leading(n,)axis.
- sizes: tuple[int, ...]#
Each control node’s level count (a discrete node) or width (a continuous one).
- legal_steps: Array | None#
Set when the caller passed a per-step
legal=to a planner registered withlegal_depth=True: a bool(L, A)over theAfirst-step actions (enumerate_policies(num_controls, 1, controlled)[:, 0]), true where that action is legal at that depth;Lispolicy_lenfor a mask given per step and 1 for a mask on the first step alone.
- property num_controls: tuple[int, ...]#
Each policy column’s level count (one column per control node).
- static __new__(
- _cls,
- transition_fn,
- step_terms_fn,
- terminal_terms_fn,
- controls,
- levels,
- policy_len,
- gamma,
- policy_prior,
- init_beliefs,
- continuous_controls=None,
- key=None,
- habit_fn=None,
- branch_fn=None,
- kinds=(),
- sizes=(),
- boxes=(),
- legal_steps=None,
Create new instance of PlannerContext(transition_fn, step_terms_fn, terminal_terms_fn, controls, levels, policy_len, gamma, policy_prior, init_beliefs, continuous_controls, key, habit_fn, branch_fn, kinds, sizes, boxes, legal_steps)