merge

Contents

merge#

hybrid_aif.composition.merge(subsystems, params, bindings=())[source]#

Merge components into one composite (System, SystemParams); see the module docstring.

subsystems and params are keyed alike; the insertion order of subsystems fixes the composite’s node order: every component’s state factors in turn, then every component’s control nodes in turn (each followed by its action node), hence the action keys’ and policy set’s layout. bindings are applied in the order given. The composite always carries explicit state_names/control_names/modality_names/action_names: a component’s generated names are namespaced.

  • Planner fields (policy_len, planner, gamma, num_iters, decomposition, planning_belief, feedback) are the leaves’ value where every leaf has one and UNSET where they differ; mixture_schedule and a non-None mixture_k are shared by one belief carry and must agree. Each leaf’s own are Subsystem.config.

  • A leaf’s policy_prior, precision, durations and scoring parameters are SystemParams.parts[<leaf>] (present when it holds any); the composite states none of them, and joint_planner() composes them.

  • epistemic is resolved and unioned (resolved_epistemic()); dims moves with its state factors, under the namespaced names (a key pose:b1 becomes arm.pose:b1).

  • A modality observing an action node keeps it: the node’s index at or above the component’s node count becomes the composite’s, len(B_deps) + position among the control nodes that stay (one a relay or Clamp removed, or an action node a driven node lost, raises).

  • Designations keep each component’s preferences under namespaced keys; C_deps namespaces its keys and parents as H_deps does.

  • System.terms selectors carry under the component prefix, on their variable segment (namespaced_term(): uncertainty:x becomes uncertainty:arm.x); the union is the composite’s, less a term a leaf’s scoring owns (that leaf’s config carries it).

  • recognition namespaces both halves, the parent addresses included (Recognition("stoch", ("deter", "recognition:embed")) → Recognition("mc.stoch", ("mc.deter", "recognition:mc.embed")); obs: and external: operands keep their prefix and are renamed on their name). external_inputs carries under the component prefix, so two components’ inputs of one name stay distinct.

  • A continuous control node’s box (params.control) and an action node’s kernel (params.actuator) move with their nodes, under the namespaced names; a driven node refuses a kernel on its own action node.

  • readings (a table’s pooled reading, System.readings and params.readings) carries under the component’s prefix; a node a relay or Clamp removed raises. A view carries the entries of its own tables and raises where the node is another component’s.

  • observes (a slot’s variable: a modality that observes an emission or an action node of its component, which is how a component reads its own belief or its previous action) carries under the component’s prefix, slot and variable alike; a Link with a realise adds an emission to the source’s component and a modality’s entry, whose variable is in another component. A component whose every binding across its boundary is such a belief read or a link from an action node into a control node is nested (nested()). An action node an entry names must stay one its component chooses. Design: nesting-and-coupling.md N2, N3.

  • emissions (a component’s outputs drawn from its state factors, with their kernels in params.emission or declared static) carry under the component’s prefix; a parent a relay or a Clamp removed raises.

  • A target on a node a binding removed raises, naming what the node became.

The composite is validated (System._validate) before it is returned.