Fawkes API  Fawkes Development Version
astar_state.h
1 
2 /***************************************************************************
3  * astar_state.h - Abstract class of a astar state.
4  *
5  * Generated: Mon Sep 15 18:48:00 2002
6  * Copyright 2002 Stefan Jacobs
7  * 2007 Martin Liebenberg
8  * 2012-2014 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 _ASTAR_ABSTRACT_STATE_H_
26 #define _ASTAR_ABSTRACT_STATE_H_
27 
28 #include <vector>
29 #include <cstdlib>
30 
31 namespace fawkes {
32 
33 /** @class AStarState <utils/search/astar_state.h>
34  * This is the abstract(!) class for an A* State.
35  *
36  * @author Stefan Jacobs
37  */
39 {
40  public:
41 
42  /** Constructor.
43  * @param cost_sofar costs for the path so far
44  * @param parent parent search state (maybe NULL for first state)
45  */
46  AStarState(float cost_sofar, AStarState *parent)
47  : parent(parent), path_cost(cost_sofar)
48  {};
49 
50  /** Destructor. */
51  virtual ~AStarState() {};
52 
53 
54  // ***** You have to implement the following 4 methods! ***** //
55  // ***** ============================================== ***** //
56 
57  /** Generates a unique key for this state.
58  * There has to be a unique key for each state (fast closed list -> bottleneck!)
59  * @return unique key
60  */
61  virtual size_t key() = 0;
62 
63  /** Estimate the heuristic cost to the goal.
64  * @return estimated cost
65  */
66  virtual float estimate() = 0;
67 
68  /** Check, wether we reached a goal or not.
69  * @return true, if this state is a goal, else false
70  */
71  virtual bool is_goal() = 0;
72 
73  /** Generate all successors and put them to this vector.
74  * @return a vector of pointers of AStarState to a successor
75  */
76  virtual std::vector<AStarState *> children() = 0;
77 
78  /** Predecessor. */
80 
81  /** Cost of path leading to this search state. */
82  float path_cost;
83 
84  /** Total estimated cost. */
86 
87 };
88 
89 } // end namespace fawkes
90 
91 #endif
This is the abstract(!) class for an A* State.
Definition: astar_state.h:38
AStarState * parent
Predecessor.
Definition: astar_state.h:79
virtual size_t key()=0
Generates a unique key for this state.
Fawkes library namespace.
float path_cost
Cost of path leading to this search state.
Definition: astar_state.h:82
virtual bool is_goal()=0
Check, wether we reached a goal or not.
virtual std::vector< AStarState * > children()=0
Generate all successors and put them to this vector.
virtual float estimate()=0
Estimate the heuristic cost to the goal.
float total_estimated_cost
Total estimated cost.
Definition: astar_state.h:85
virtual ~AStarState()
Destructor.
Definition: astar_state.h:51
AStarState(float cost_sofar, AStarState *parent)
Constructor.
Definition: astar_state.h:46