Skip to main content
. 2025 Dec 26;28(1):30. doi: 10.3390/e28010030
Algorithm 2 Local Foraging Behavior of an Ant
  • 1:

    if  nc(ai)<p  then

  • 2:

          Increment memory counter: nc(ai)nc(ai)+1

  • 3:

          Create a new hunting site near the nest

  • 4:

          Snc(ai)Θexpo(N,Asite)

  • 5:

          en(ai)0                      ▹ Failure counter

  • 6:

    end if

  • 7:

    Let sj be the last visited site

  • 8:

    if  ej>0  then

  • 9:

          Randomly choose another site from memory

  • 10:

    end if

  • 11:

    Perform local exploration: SuΘlocal(sj,Alocal)

  • 12:

    if  f(Su)>f(sj)  then

  • 13:

          Update site: sjSu

  • 14:

          ej0

  • 15:

    else

  • 16:

          Increment failure counter: ejej+1

  • 17:

          if ej>Plocal then

  • 18:

               Remove sj from memory

  • 19:

               nc(ai)nc(ai)1

  • 20:

          end if

  • 21:

    end if