0

Firstly , For those of your who dont know - Anytime Algorithm is an algorithm that get as input the amount of time it can run and it should give the best solution it can on that time.

Weighted A* is the same as A* with one diffrence in the f function :

(where g is the path cost upto node , and h is the heuristic to the end of path until reaching a goal)

Original = f(node) = g(node) + h(node)

Weighted = f(node) = (1-w)g(node) +h(node)

My anytime algorithm runs Weighted A* with decaring weight from 1 to 0.5 until it reaches the time limit.

My problem is that most of the time , it takes alot time until this it reaches a solution , and if given somthing like 10 seconds it usaully doesnt find solution while other algorithms like anytime beam finds one in 0.0001 seconds.

Any ideas what to do?

RanZilber
  • 1,840
  • 4
  • 31
  • 42
  • Switch to beam search instead? – Fred Foo May 03 '11 at 16:01
  • beam doesn't give optimal solution – RanZilber May 03 '11 at 16:10
  • @RanZilber: neither will an anytime algorithm. – Fred Foo May 03 '11 at 16:12
  • The only real way I know to optimize A* is to make your heuristic as accurate as possible – Dan F May 03 '11 at 16:15
  • what is the range of the heuristic? (comaring to the real solution?) – amit May 03 '11 at 16:32
  • I have two heuristics . One that is acceptable - meaning that it is lower than the optimal solution , or if you wish , lower than the way the realy left it. And one that is actually unbounded .The first one allows me to get an optimal solution if ill give it enough time. the second one allows me to find solution faster. Another thing - i'm looking to optimize my time and my soultion. I want to find a better solution , faster. – RanZilber May 03 '11 at 17:56
  • and what is the valid`s heuristic value comparing to the real solution? (approximation)? 1/2? normalized (bad bad bad)? you can assume a valid heuristic will take a long time.. – amit May 03 '11 at 18:11

2 Answers2

2

If I were you I'd throw the unbounded heuristic away. Admissible heuristics are much better in that given a weight value for a solution you've found, you can say that it is at most 1/weight times the length of an optimal solution.

A big problem when implementing A* derivatives is the data structures. When I implemented a bidirectional search, just changing from array lists to a combination of hash augmented priority queues and array lists on demand, cut the runtime cost by three orders of magnitude - literally.

The main problem is that most of the papers only give pseudo-code for the algorithm using set logic - it's up to you to actually figure out how to represent the sets in your code. Don't be afraid of using multiple ADTs for a single list, i.e. your open list. I'm not 100% sure on Anytime Weighted A*, I've done other derivatives such as Anytime Dynamic A* and Anytime Repairing A*, not AWA* though.

Another issue is when you set the g-value too low, sometimes it can take far longer to find any solution that it would if it were a higher g-value. A common pitfall is forgetting to check your closed list for duplicate states, thus ending up in a (infinite if your g-value gets reduced to 0) loop. I'd try starting with something reasonably higher than 0 if you're getting quick results with a beam search.

Some pseudo-code would likely help here! Anyhow these are just my thoughts on the matter, you may have solved it already - if so good on you :)

Sekm
  • 1,658
  • 13
  • 22
0

Beam search is not complete since it prunes unfavorable states whereas A* search is complete. Depending on what problem you are solving, if incompleteness does not prevent you from finding a solution (usually many correct paths exist from origin to destination), then go for Beam search, otherwise, stay with AWA*. However, you can always run both in parallel if there are sufficient hardware resources.

Mark Jin
  • 2,616
  • 3
  • 25
  • 37