Skip to main content
. 2020 Jan 8;20(2):356. doi: 10.3390/s20020356
Algorithm 2 Genetic Algorithm (GA)
Input:
        Maximum number of generations (MaxGen).
        Population size (PopSize).
        Lower and upper bound variables (varmin,varmax).
Output:
        Best value of all chromosomes (GlobalBestrssi).
  • 1:

    for i=1:PopSize do

  • 2:

        posi=rand(varmin,varmax)

  • 3:

        rssii=pathloss(posi)

  • 4:

        Bestposi=posi

  • 5:

    end for

  • 6:

    for t=1:MaxGen do

  • 7:

        for i=1:PopSize do

  • 8:

            SelectParents

  • 9:

            Crossover

  • 10:

            Mutation

  • 11:

            posi=posi+1

  • 12:

            Bestposi=posi

  • 13:

            Bestrssii=rssii

  • 14:

            GlobalBestrssi=Bestrssii

  • 15:

        end for

  • 16:

    end for