AntColony.acoMethod
aco(dist_mat; start_node=nothing, end_node=nothing; is_tour=false, beta=2, rho=0.1,
q=0.1, Q=1.0, tau_min=1.0, tau_max=10.0, max_iter=20, reset_iter=10,
top_perc_ants=0.05, verbose=false)

Ant Colony Optimization for directed graphs based on Max-Min Ant System, Elitist Ant System and Ant Colony System.

Arguments

• dist_mat: must be a square distance matrix (NxN) and edges are accessed like this dist_mat[to, from]
• start_node: must be an integer <= N or nothing (both nodes or none must be specified)
• end_node: must be an integer <= N or nothing (both nodes or none must be specified)
• is_tour: whether path should start and end with same node (will set end_node = start_node)
• beta: influences how important distance is for the ants decision making
• rho: pheromones evaporation percentage for each iteration (0.0 <= rho <= 1.0)
• q: percentage of roulette wheel style decisions of ants
• Q: pheromone deposit factor
• tau_min: lower bound for pheromone levels for any edge
• tau_max: upper bound for pheremone levels for any edge (initial level of pheromones)
• max_iter: number of iterations run for the algorithm
• reset_iter: number of iterations after which the pheromone levels are reset to tau_max
• top_perc_ants: the percentage of top perfoming ants which deposit pheromones on their trails
• verbose: print to console whenever a better path was found

Examples

Find a tour

Find any path with the same start and end node i.e. a tour. Note that the start node only appears once!

julia> distances = rand(5, 5);
julia> aco(distances, is_tour = true)
5-element Array{Int64,1}:
4
3
5
1
2

Find a path

Finda a specific path from node 1 to node 5

julia> distances = rand(5, 5);
julia> aco(distances, start_node = 1, end_node = 5)
5-element Array{Int64,1}:
1
2
4
3
5
AntColony.edgesMethod
edges(path, is_tour)

Generate node pairs representing edges in path

AntColony.sampleMethod
sample(x, weights)

Sample from x with a custom distribution defined by weights

AntColony.travelFunction
travel(P, q, start_node, end_node)

Travel through graph based on probability P