Class AntColony

Inheritance Relationships

Base Type

Class Documentation

class AntColony : public Planner

Class for objects that plan using the Ant Colony algorithm.

Public Functions

AntColony(const std::vector<std::vector<int>> &grid)

Constructor.

Return
no return value
Parameters
  • grid: the grid on which the planner is to plan

void SetParams(const int n_ants = 10, const double alpha = 1, const double beta = 0.2, const double evap_rate = 0.5, const double Q = 10, const int iterations = 50)

Constructor for set up of Ant Colony class.

Return
no return value
Parameters
  • n_ants: number of ants yo be created in every iterations
  • alpha: value of exponent for the use of the pheromone trails in assigning probability to possible next positions
  • beta: value of exponent for the use of the heuristic in assigning probability to possible next positions
  • evap_rate: evaporation rate of the pheromone trail as a value between 0 and 1
  • iterations: number of iterations of the simulation
  • Q: Constant multiplication factor for the cost/reward function

void PrintAntPath(Ant &ant) const

Prints the path taken by the ant.

Prints the path taken by the ant on the grid, using the PrintPath function in

utils.cpp. It can be used to print incomplete paths as well, as long as the end point and start point are specified.
Return
void
Parameters
  • ant: ant for which the path is to be printed.

std::tuple<bool, std::vector<Node>> Plan(const Node &start, const Node &goal)

Ant Colony algorithm implementation.

Return
tuple contatining a bool as to whether a path was found, and the path
Parameters
  • start: start node
  • goal: goal node

Public Static Functions

void RemoveLoop(Ant &ant)

Removes loops in path.

Removes loops in path of an ant only when a point is revisted.

Return
void
Parameters
  • ant: Ant in whose path the loops are to be removed