Fawkes API  Fawkes Development Version
astar.h
1 
2 /***************************************************************************
3  * astar.h - Implementation of A*
4  *
5  * Created: Mon Sep 15 18:39:00 2002
6  * Copyright 2007 Martin Liebenberg
7  * 2002 Stefan Jacobs
8  * 2012 Tim Niemueller [www.niemueller.de]
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #ifndef _ABSTRACT_ASTAR_H_
26 #define _ABSTRACT_ASTAR_H_
27 
28 #include <utils/search/astar_state.h>
29 
30 #include <vector>
31 #include <map>
32 #include <queue>
33 
34 namespace fawkes {
35 
36 class AStar
37 {
38  public:
39  AStar ();
40  ~AStar();
41 
42  std::vector<AStarState *> solve( AStarState * initialState );
43 
44  private:
45  struct CmpSearchStateCost {
46  bool operator() ( AStarState * a1, AStarState * a2 ) const
47  { return (a1->total_estimated_cost >= a2->total_estimated_cost); }
48  };
49 
50  std::priority_queue<AStarState *, std::vector<AStarState *>, CmpSearchStateCost> open_list;
51  std::map<const size_t, AStarState*> closed_list;
52 
53  AStarState * search();
54 
55  std::vector<AStarState *> solution_sequence(AStarState * node);
56  std::vector<AStarState *> solution;
57 };
58 
59 
60 } // end namespace fawkes
61 
62 #endif
This is the abstract(!) class for an A* State.
Definition: astar_state.h:38
This class tries to translate the found plan to interpreteable data for the rest of the program...
Fawkes library namespace.
~AStar()
Destructor.
Definition: astar.cpp:63
std::vector< AStarState * > solve(AStarState *initialState)
Solves a situation given by the initial state with AStar, and returns a vector of AStarStates that so...
Definition: astar.cpp:80
Class AStar.
Definition: astar.h:36
float total_estimated_cost
Total estimated cost.
Definition: astar_state.h:85
AStar()
Constructor.
Definition: astar.cpp:56