Implement a goal-conditioned world model whose predictions are pulled toward a goal with increasing strength along the horizon, plus its training loss.
goal_conditioned_rollout(initial_state, actions, goal_state, transition_matrix, action_matrix, goal_matrix, anchor_strength=0.5, anchor_power=2.0)
Shapes: initial_state and goal_state (D,), actions (T,A), transition_matrix Ws (D,D), action_matrix Wa (D,A), goal_matrix Wg (D,D). With s0 = initial_state and g = goal_state, for k=0,…,T−1:
- rk=tanh(Wssk+Waak+Wg(g−sk))
- αk=anchor_strength⋅(Tk+1)anchor_power
- sk+1=(1−αk)rk+αkg
Return a dict with 'trajectory' [s0,…,sT] of shape (T+1,D), 'anchor_weights' [α0,…,αT−1] of shape (T,), and 'raw_predictions' [r0,…,rT−1] of shape (T,D).
compute_future_anchor_loss(trajectory, goal_state, raw_predictions, lambda_goal=1.0, lambda_smooth=0.1, lambda_consistency=0.1)
goal_loss =∥sT−g∥2
smoothness_loss =T1∑k=1T∥sk−sk−1∥2
consistency_loss =T1∑k=0T−1∥rk−sk+1∥2
total_loss =λgoal⋅ goal_loss +λsmooth⋅ smoothness_loss +λconsistency⋅ consistency_loss
Return a dict with those four keys, each a Python float.