Skip to content

Commit

Permalink
Prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
zfoxer committed Nov 12, 2020
1 parent dd50b8b commit 47856f5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ License: GNU GPL Version 3

The shortest path problem is solved by many methods. Heuristics offer lower complexity in expense of accuracy. There are many use cases where the lower accuracy is acceptable in return of lower consumption of computing resources.

The basic idea of the Ant System (AS) [1, 2] is that virtual ants are exploited for finding paths with a specific property, e.g., short distance between physical nodes, in the same way nature guides physical ants. A special chemical substance is being deposited upon their path which raises the probability for other ants to follow it during subsequent traversals. When this substance concentrates in high levels on a path, all subsequent ants have higher probability to follow it, and at the same time, increment it even more. Evaporation takes place on paths that are less traversed. Usually, the path with the highest pheromone concentration is the shortest path. The AS emulates this natures behaviour with satisfying results solving computational problems. When the number of virtual ants and iterations are high enough, the right paths are usually found under polynomial complexity.
The basic idea of the Ant System (AS) [1, 2] is that virtual ants are exploited for finding paths with a specific property, e.g., short distance between physical nodes, in the same way nature guides physical ants. A special chemical substance is being deposited upon their path which raises the probability for other ants to follow it during subsequent traversals. When this substance concentrates in high levels on a path, all subsequent ants have higher probability to follow it and increment it as well even more. Evaporation takes place on paths that are less traversed. Usually, the path with the highest pheromone concentration is the shortest path. The AS emulates this nature's behaviour with satisfying results solving computational problems. When the number of virtual ants and iterations are high enough, the right paths are usually found under polynomial complexity.

This is a heuristic method, i.e., optimal results are not always feasible. According to topologys resources like the node and edge numbers, the proper numbers of iterations and virtual ants must be used. Large numbers lead to paths with higher probability of being optimal but more computational resources are consumed.
This is a heuristic method, i.e., optimal results are not always feasible. According to topology's resources like the node and edge numbers, the proper numbers of iterations and virtual ants must be used. Large numbers lead to paths with higher probability of being optimal but more computational resources are consumed.


## Prerequisites to build
Expand Down
8 changes: 1 addition & 7 deletions antsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ std::vector<int> AntSystem::path(int start, int end)
void AntSystem::clear()
{
edge2phero.clear();
edges.clear();
edges.clear();
}

double AntSystem::diffPheromone(double length)
Expand Down Expand Up @@ -252,9 +252,3 @@ bool AntSystem::isCyclic(int nd, const std::vector<int>& nodes)

return nodes.size() + 1 != uniqueNodes.size();
}

const double AntSystem::EVAPO_RATE = 0.5;

const double AntSystem::A_PAR = 1;

const double AntSystem::B_PAR = 5;
6 changes: 3 additions & 3 deletions antsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class AntSystem : public AdaptiveSystem
static const int ANTS = 250;
static const int ITERATIONS = 150;
static const int PHERO_QUANTITY = 100;
static const double A_PAR;
static const double B_PAR;
static const double EVAPO_RATE;
static constexpr double A_PAR = 1;
static constexpr double B_PAR = 5;
static constexpr double EVAPO_RATE = 0.5;
AntSystem(const std::string&, int = 0, int = 0);
virtual ~AntSystem();
virtual std::vector<int> path(int, int);
Expand Down
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

int simpleRun()
{
AdaptiveSystem* aco = new AntSystem("topology.json",
AntSystem::ANTS, AntSystem::ITERATIONS);
AdaptiveSystem* aco = new AntSystem("topology.json", AntSystem::ANTS,
AntSystem::ITERATIONS);
auto nodePath = aco->path(0, 19);
for(int n : nodePath)
std::cout << n << " ";
Expand Down

0 comments on commit 47856f5

Please sign in to comment.