Skip to main content
. 2025 Apr 16;25(8):2502. doi: 10.3390/s25082502
Algorithm 6 Balance UAVs Across Clusters
Input:
  • N: Total number of available UAVs.

  • M: Total number of existing tasks.

  • nC: Number of clusters.

  • C: Set of clusters, where each contains a subset of tasks.

Output:
  • C: Clusters after distributing UAVs among them.

Step 1: Compute the Initial Number of UAVs Per Cluster

  •  1:

    Compute the initial number of tasks per UAV:

    nTUM/N

  •  2:

    Initialize the number of unassigned UAVs:

    unUN

  •  3:

    for k=1 to nC do

  •  4:

        Calculate the number of tasks in cluster Ck:

         nTCk|Ck|

  •  5:

        Compute the initial number of UAVs for cluster Ck:

         nUCknTCk/nTU

  •  6:

        Update the number of unassigned UAVs:

         unUunUnUCk

  •  7:

    end for

Step 2: Balance and Distribute Extra UAVs Among Clusters

  •  8:

    if unU0 then

  •  9:

        for  q=1 to unU do

  • 10:

            Initialize the most crowded cluster:

            idxCrowdedC0

            lCrowdedC0

  • 11:

            for k=1 to nC do

  • 12:

               Compute initial UAV load in cluster Ck:

                IULknTCk/nUCk

  • 13:

               if IULk>lCrowdedC then

  • 14:

                   Update the most crowded cluster index and load.

                   lCrowdedCIULk

                   idxCrowdedCk

  • 15:

               end if

  • 16:

            end for

  • 17:

            Assign the extra UAV to the most crowded cluster.

             nUCidxCrowdedCnUCidxCrowdedC+1

  • 18:

        end for

  • 19:

    end if

  • 20:

    Assign UAVs to each cluster based on nUCk.