1

I am doing ant colony optimization algorithm. I have got a few questions. I tried to search throw , but found nothing.

1 — What is the result of the algorithm?

I have some graph and I need to find optimal path from start point to goal point, right? This algorithm is not working like dijkstra algorithm (which find one shortest path). There is a probability factor in it. After 10 cycles and 5000 ants worst path can be chosen, despite of that fact, that pheromone on better path will be 1000 times more. I mean 5000'th can chose path 1 -> 3 -> 5 (which has avg probability of 1%), despite of that fact, that 4999 ants had chosen 1 -> 2 -> 5 (99% probability). It is just an example ofc. So the question is how to detect most optimized (best, best on some parameter?) path and should I detect it or 1 -> 2 -> 5 in my example is correct outcome (happens...) and I have to output last chosen path?

2 — How results should be outputted

Well this answer depends on first answer maybe. Well how? I assume, that I have to output total summary of working algorithm and protocol of each cycle.

Summary data will be:

Path found: Yes/no
Path: path/message, that best path is not found
Iteration: N

Protocol will be:

Start data for iteration 3
    Pheromone level for this iteration
    Path found on this level or not (?)
    Path on this iteration (?)
End data for iteration 3

Start data for iteration 2
    Pheromone level for this iteration
    Path found on this level or not (?)
    Path on this iteration (?)
End data for iteration 2


Start data for iteration 1
    Pheromone level for this iteration
    Path found on this level or not (?)
    Path on this iteration (?)
End data for iteration 1

Any suggestions? Help me with output data for each iteration please.

3 — Pheromone level stops growing when it reaches a certain value

Why it is so? For example (500 ants), pheromone level on best path is growing up up to ~10 step of search (cycle) and after that becomes stable. Is it good behaviour or it means some errors in my algorithm? If no errors, why this behaviour appears?

4 — Architecture of my program

I think that good way is to create onclick handler, which calls NEXT STEP (next cycle) of algorithm. I saw some examples, that it was on loop some time (don't remember link, can't show you :'( now). Is my method is acceptable or it is wrong at all?

josliber
  • 43,891
  • 12
  • 98
  • 133
Sharikov Vladislav
  • 7,049
  • 9
  • 50
  • 87

1 Answers1

2

1) You'd usually store the best-so-far path of all iterations (as in Elitist Ant System etc.), which is also the final result then.

2) With cycle you mean iteration? Anyway, as for "Path found on this level or not", I'd only allow successful (complete) paths in the first place, or let all ants run until every ant has found one and cut the loops. Otherwise placing pheromones and recording the path wouldn't make much sense here, I think. So I'd suggest to record the optimal path's length of each iteration (and thereby the pheromones to place) and the vertices of that path, of course.

3) Usually you'd break the algorithm if the pheromones stagnate and no better solution is being found for a certain number of iterations.

4) Certainly not wrong. I've seen an online implementation somewhere as well, and was a bit disappointed that you couldn't watch the ants step-by-step...

megapop
  • 61
  • 3
  • 1) what path is best path? path of last ant, founded goal point? 2) 1 "search cycle" means all specified ants tried to find goal point (yes, I meant iteration, sorry); again the question: what path is better then another path and on what property? I have to place pheromones because of task. So: I have to output optimal (again: which is optimal (best)) and length of that path. Ok, but one question. 3) Ok, I got this, thank you. I have to detect stagnation and show message about it. 4) Ok, I got it. – Sharikov Vladislav Apr 17 '14 at 20:44
  • As I assume that you want to minimise, the best path is the shortest one. The shorter a particular path is, the more pheromones will the according ant place there; and thereby you compare its length with your current (best-so-far) minimal solution, and if it's shorter, you update your current solution with that particular path. As for the cycles -- yes, thanks. I was only a bit confused because you've tagged your question with the TSP... Hamilton cycle and all, you know. Anyway, you probably want the path length as relevant property. (And compare it to your current minimal solution). – megapop Apr 19 '14 at 12:02
  • Thank you for your comment. Mhm. I did this: set best length like `2147000000`; if ant found path I calculate founded path length and if it is lesser then current best length — I do it all time when ant finds goal point. Am I right? You mentioned same, right? – Sharikov Vladislav Apr 20 '14 at 09:05
  • Yes. Just to clarify, you have to calculate the paths' lengths anyway for pheromone deposition, don't you? Just use that result for comparison. The shorter, the better. :) – megapop Apr 21 '14 at 10:58
  • Yes, I did this. I have another problem now... Imagine situation: I selected 1 as start and 10 as goal, there are no path from 1 to 10. 10 is just 'in air'. My algorithm will say: `go next cycle, path not found`. It is organizational issue. Just don't know what to write to user and which variant is better. I am thinking about writing this: `path not found. possibly path doesn't exists. do more steps to make sure.` What do you think? – Sharikov Vladislav Apr 21 '14 at 11:04
  • But when would you break the ants' search process anyway? I think there are basically two approaches: (1) you set a max number of steps after which they return something like you suggested if they didn't find the goal... problem is, you never know... or (2) as in this case it seems to be unnecessary to visit a vertex multiple times anyway, you let the ants store the vertices they already visited in each iteration and only allow them to move to "new" vertices. If there isn't any possibility left and the goal isn't reached yet, you know for sure that there is no way from A to B and quit. – megapop Apr 21 '14 at 13:22
  • Or, as (2) is possibly less time-efficient because you have to re-check every step, or as loops can be desired, you can run a check like this one time and then let the ants behave as in (1). – megapop Apr 21 '14 at 13:29