top of page

A Template of Multivariable Ant System for Engineering Design Problems

In a multivariable design problem, the structure of the single variable can be maintained. The only modification is to insert an additional loop for each design variable into the ant loop. After each iteration, only the pheromone slots relating to the current solution for each ant 'k' are updated.

Pheromone updating for each iteration i.e. Delta_Tau = 1/sum(X1j,X2j)
Pheromone updating for each iteration i.e. Delta_Tau = 1/sum(X1j,X2j)

The following code template is shown below to explain the structure of the code.


INPUT:

  V             = number of variables (e.g., beams, columns)

  O[v]          = list of discrete options for variable v

  EVALUATE(X)   = returns (cost, feasible) for a full solution X

  alpha, beta   = parameters (pheromone vs heuristic influence)

  rho           = evaporation rate

  Q             = pheromone deposit scale

  m             = number of ants

  maxIter       = maximum iterations



INITIALIZE:

  tau[v][j] = 1 for all variables v and options j

  eta[v][j] = heuristic value for option j of variable v

              (e.g., 1/As, closeness to demand)

  bestSolution = none, bestCost = infinity



FOR iter = 1..maxIter

    # --- Ants build solutions ---

    FOR each ant k = 1..m

        X = []

        FOR each variable v = 1..V

            # Probabilities for each option

            P[j] = (tau[v][j]^alpha * eta[v][j]^beta) / sum(all j)


            # Choose option by roulette wheel

            choice = SAMPLE(P)

            X[v] = choice

        END



        (cost, feasible) = EVALUATE(X)

        if not feasible: cost = infinity


        Save X, cost for this ant

        If cost < bestCost: update bestSolution, bestCost

    END



    # --- Update pheromones ---

    FOR each variable v and option j

        tau[v][j] = (1 - rho) * tau[v][j]   # evaporation

    END


    FOR each ant k

        if cost_k < infinity

            deposit = Q / cost_k   # better solutions deposit more

            FOR each variable v

                j = X_k[v]        # option chosen by ant k

                tau[v][j] += deposit

            END

        END

    END

END



OUTPUT: bestSolution, bestCost



bottom of page