plan

Contents

plan#

hybrid_aif.composition.plan(
planner=None,
learn=None,
trace=False,
replace=None,
warm_start=False,
**act_kwargs,
)[source]#

The step of a planning mind: infer, learn, act, push the prior, emit.

Built once, compiled per view (equal views share one program, params being an argument). Each round, on its view: infer the posterior from the carried prior (a modality whose value is None is absent that round; a modality that observes an emission or action node of the view takes the datum of that variable); learn when learn is set and a previous round exists (System.learn with the previous posterior and action); choose an action (System.act(key, params, beliefs, planner=planner, **act_kwargs)); push the posterior through the transition under the action as the next prior; realise every emission of the view from the posterior (the step’s key folded with EMIT_TAG). It returns the action nodes and the emissions, and the params it was given, or the learned ones. The carry is a MindCarry, None meaning a fresh one; the step’s first call (obs is None) returns nothing and leaves the declared initial priors as the first round’s prior.

learn is None (nothing is learned), True (every learnable slot), a mapping of System.learn keywords, or a sequence of slot keys (those slots learn at rate 1, the rest at 0). trace=True keeps each round’s Trace in carry.trace: the policy posterior, the term tree, the planner’s policy set, the inference detail and the parameter variables the round planned with. warm_start=True makes the plan receding-horizon: the carry keeps the continuous controls of the plan each round acted on (MindCarry.plan), and the next round’s planner starts from that plan shifted one step on (its steps after the first, the last step repeated), passed as its init; the first round starts from zeros. The shift is by one of the node’s own steps, so a node on a clock or holding an option shifts once per decision. It needs a planner that takes an init (the gradient and mixed planners, planner_takes_init()) and refuses any other. replace sets fields of the view ({"policy_len": 2}) before it plans; on a non-leaf node it is also where the joint view’s configuration is given (as joint_planner takes it). act_kwargs pass to System.act (selection=, legal=, …); a legal is checked on the first call. A view with a driven continuous control node is refused, since a planner holds a driven input at one level: use a custom step.