| Algorithm 1. HA-PM node planning and execution |
|
Inputs: Node state N, configuration Γ, received events ℰ, observation limit tstop. Output: Decision and actual execution record R; updated node state. 01 procedure NodeControl(N, Γ, ℰ, tstop) 02 Process received events; settle elapsed nominal targets and actual misses. 03 Restart only at an eligible checkpoint; materialize jobs through the current target H. 04 I ← immutable local snapshot; WH ← required jobs and pending ancestors for H. 05 R ← SelectFeasible(I, Γ, WH, H, 1); retain full-horizon assessments. 06 if R.status = NO_FEASIBLE_PLAN then 07 h ← CausalNearHorizon(I, Γ) using only known jobs and the calendar. 08 if h is defined and t + 2τctl < h < H then 09 Wh ← required jobs and pending ancestors for h; retain all other jobs. 10 Rh ← SelectFeasible(I, Γ, Wh, h, 2); retain the recovery assessment. 11 Record the searches actually attempted; preserve the original target H. 12 if Rh contains a feasible plan then 13 Attach its plan to R and mark RECOVERY_SELECTED. 14 end if 15 end if 16 end if 17 if R contains a selected plan then 18 Revalidate snapshot, time, calendar and available energy before installation. 19 If stale or the energy check fails, return R with the applicable replan status. 20 Execute the plan under the physical-execution contract, up to tstop. 21 else 22 Execute only the controller charge for searches actually attempted. 23 If time remains, perform finite M0 or OFF waiting; record actual missed work. 24 end if 25 return R, retaining actual phases, service outcomes and any censored tail. 26 end procedure 27 function SelectFeasible(I, Γ, W, H, q) 28 Validate input and decision-state preconditions; reject malformed input. 29 Return distinct OFF, energy-observation or control-unavailable status when applicable. 30 C ← {EARLIEST, LATEST} × {M0, …, M19}, including the q-search cost. 31 Assess every candidate under the same I, W, H and equivalent terminal conditions. 32 Check timing, capabilities, predecessors, data and mode-transition constraints. 33 Check phase energy and reserve throughout the plan; credit no future harvest. 34 F ← {p ∈ C: p satisfies every feasibility check}. 35 if F = ∅ then 36 return NO_FEASIBLE_PLAN with all candidate assessments. 37 end if 38 p* ← lexicographic arg min over p ∈ F of (Êtot(p), ntr(p), id(p)). 39 return SELECTED, p* and all candidate assessments. 40 end function |