Research Article

Multiagent Task Planning Based on Distributed Resource Scheduling under Command and Control Structure

Algorithm 2

MultiAgent-HTN algorithm flow in distributed environment.
(1)Procedure MA-HTN
(2)set , initial state
(3)set , initial task set
(4)set , domain
(5)initial operator
(6)set  the empty plan
(7)
(8)loop
(9) if is empty then return
(10)  nondeterministically choose any in
(11)   if is a primitive task then
(12)    choose a ground instance for with the smallest among the available resources
(13)    
(14)    
(15)    
(16)    send to the other planners
(17)    if
(18)     
(19)     conflict actions
(20)     
(21)     , then
(22)    if
(23)     delete the rest in
(24)     
(25)     delete in and add into
(26)    else if
(27)     delete in
(28)     
(29)     Backtrack
(30)    else delete in and add into
(31)   if is a nonprimitive task then
(32)    choose a method to decompose into subtasks
(33)    delete in and add into
(34)   if receiving a new in of and
(35)    
(36)    conflict actions
(37)    
(38)    
(39)   if
(40)    delete the rest in
(41)    
(42)    Backtrack to task node at action
(43)   else if
(44)    delete in
(45)    
(46)    delete in and add into
(47) repeat
(48)end MA-HTN