Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
astar.h
1 
2 /***************************************************************************
3  * astar.h - Implementation of A*
4  *
5  * Generated: Mon Sep 15 18:39:00 2002
6  * Copyright 2002-2007 Stefan Jacobs, Martin Liebenberg
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _ABSTRACT_ASTAR_H_
25 #define _ABSTRACT_ASTAR_H_
26 
27 #include <utils/search/astar_state.h>
28 
29 #include <vector>
30 #include <map>
31 #include <queue>
32 
33 namespace fawkes {
34 
35 
36 class AStar
37 {
38  public:
39  AStar ();
40  ~AStar();
41 
42  std::vector< AStarState * > solve( AStarState * initialState );
43 
44  private:
45 
46  struct Cmp {
47  bool operator() ( AStarState * a1, AStarState * a2 ) const
48  { return (a1->totalEstimatedCost >= a2->totalEstimatedCost); }
49  };
50 
51  std::priority_queue< AStarState *, std::vector< AStarState * >, Cmp > openList;
52  std::map< const long, AStarState*> closedList;
53 
54  AStarState * search();
55 
56  std::vector< AStarState * > getSolutionSequence( AStarState * node );
57  std::vector< AStarState * > solution;
58 
59 };
60 
61 
62 } // end namespace fawkes
63 
64 #endif