Skip to main content
. 2026 Feb 11;26(4):1170. doi: 10.3390/s26041170
Algorithm 2. Distributed Routing Decision Algorithm Based on GraphSAGE-MAPPO.
Input: the service flow arriving at agent i fij={typefij,datafij,Cfijdemand,reqfij}
Output: (aroute,aresource), routing and resource allocation actions.
  • 1:

    initialize the network G, Actor network parameters θ, Critic network parameters ω, Experience replay buffer D.

  • 2:

    while episode<Nepisodes

  • 3:

        for step from 1 to T

  • 4:

          if the current node is not the destination of the traffic flow.

  • 5:

    Obtain the initial feature vector of node ni xni={posni,Bni,Cni,Sni}.

  • 6:

    Compute the hidden feature vector of the node using the algorithm in Algorithm 1. hi, form the state space si by incorporating the traffic flow fij

  • 7:

    Generate the next-hop probability distribution according to the policy function πθii(ai,si), select the optimal next hop, allocate resources, and compute the reward Ri using Equation (26).

  • 8:

    Obtain the next state s, and store (s,a,r,s) in the experience replay buffer D

  • 9:

    Sample experiences from the replay buffer and compute the advantage function Ait according to Equation (30).

  • 10:

    Compute the loss function of the Actor network and update θ.

  • 11:

    Compute the loss function of the Critic network and update ω.

  • 12:

        end if

  • 13:

      end for

  • 14:

    end while

  • 15:

    Save the model.