GenerativeEnv#

class hybrid_aif.envs.GenerativeEnv[source]#

Bases: Env

A positional process inner with name-keyed faces; names is static.

params given as GenerativeEnvParams must key their containers by name (as System.as_env() returns them; a tuple container raises, naming system.from_positional("params", ...)); any other params (an outside environment’s own) pass to inner untouched.

inner: Env#

The positional process the faces wrap.

names: FaceNames#

The System’s names (static), used to key the containers.

factor_actions: bool = False#

Whether inner takes the action one level per state factor (an outside, pymdp-style environment) rather than one per control node (the System’s own process).

classmethod wrap(env, system, params=None)[source]#

An outside positional environment, keyed by system’s names.

env speaks the positional convention (hybrid_aif.envs.base): observations and states as tuples, the action as one level per state factor (or the flat continuous vector). Its state factor and modality counts are checked against the System’s; their order must match the System’s node order too, which cannot be checked. params (the System’s, keyed) are needed when a control node is continuous: its box lives in params.control. Wrapping an already keyed env raises.

property num_states: int#

Number of state factors (the inner process’s).

null_action()[source]#

The process’s no-op action, keyed by action node (levels or blocks).

reset(key, params, state=None)[source]#

Sample (or, with state, set) an initial state and an observation of it.

step(key, state, action, params, states=None)[source]#

Sample the next state under action and an observation of it (the intended action, realised through params.actuator; see step_actuated()). states names the state factors to step; the others keep their values (see step_actuated()).

step_actuated(key, state, action, params, states=None)[source]#

step(), also returning the realised action, keyed by action node.

action is the intended action. An action node with a kernel in params.actuator is realised as a draw from its column at the intended level, with a key folded from key; any other is realised as given (and key is used as step() always uses it). The world moves on the realised action.

states names the state factors to step, by state factor name; the others keep their values and the observation is of the state so made. It is the System’s own process that steps in parts (the driver’s sequential and async orders step each component’s state factors at that component’s turn); an outside environment wrapped by wrap() has no parts to name, and is refused.

__init__(inner, names, factor_actions=False)#