Details and Options
ResourceFunction["AntColonyOptimization"] is a global stochastic optimization method for the solution of combinatorial arrangement problems. It imitates the swarm communication behaviour of ants during foraging (Stigmergic Optimization).
The optimization is based on the exchange of information between individuals (randomly generated solutions) using a virtual pheromone trail for the information exchange.
ResourceFunction["AntColonyOptimization"] finds a solution of vector x, where the ith element of x is chosen from the values of the ith list in array, such that fitness[x] has the smallest positive value found.
The input
array takes a
List of lists with available values at each row. The lists need not have uniform length.
The fitness function to be minimized must return a positive scalar value. Therefore, the standard method of negating the objective function to convert a minimization problem into a maximization problem doesn’t work in this ACO implementation.
Limitation: This implementation does not consider dependencies of design variables among each other. The assignment of the design variables must be independent of the settings of the others. The definition of the search space is therefore possible using only a given array and does therefore not require a given tree or graph structure of the search space. Optimization problems such as the traveling salesman cannot be encoded in this way.
Optimization parameters given as options include:
"PopulationSize" | 500 | number of ants |
"MaxIterations" | 200 | maximum iterations |
"FinishAtPheromoneThreshold" | 0.95 | stop criterion |
"PheromoneFunction" | (1/#)& | pheromone concentration to be deposited depending on fitness |
"WeatheringFactor" | 0.05 | fraction of decreasing pheromone concentration (selection probability) per iteration |
"ProbabilitySelectBestPath" | 0.02 | proportion of generated solution alternatives that currently prefer the best solution |
The computation will stop if the selection probability for a variable state exceeds the value of "FinishAtPheromoneThreshold".
"PheromoneFunction" is a function whose result marks the selection probability for the next step. By default, larger fitness results receive lower marking values than smaller fitness results.
Optimization parameters control the runtime behavior and solution quality as a tradeoff between exploitation and exploration. These can be modified depending on the target function and the number of variables, e.g. by trial and error.
The option "ProbabilitySelectBestPath" takes values between zero and one. Smaller values use probabilistic selecting resulting in slower convergence but exploring more possibilities.
The current minimal selection probability for a variable state is monitored during the iterations. The smaller it is, the greater the ability to explore new solutions.
The output of
ResourceFunction["AntColonyOptimization"] is a
List representing the best found solution. Due to the stochastic search method, this optimum does not necessarily have to be global, thus better solutions may exist.
When the third argument is
All, the output is an
Association with keys:
"Best" | variable allocation which minimizes fitness |
"Iterations" | for each iteration step:
{arguments which minimize fitness,
normalized pheromone matrix,
and current minimal selection probability for a variable state} |
"NumberOfFunctionCalls" | number of calls made to the fitness calls |