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 <cstdlib>
29#include <vector>
30
31namespace 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{
40public:
41 /** Constructor.
42 * @param cost_sofar costs for the path so far
43 * @param parent parent search state (maybe NULL for first state)
44 */
45 AStarState(float cost_sofar, AStarState *parent) : parent(parent), path_cost(cost_sofar){};
46
47 /** Destructor. */
48 virtual ~AStarState(){};
49
50 // ***** You have to implement the following 4 methods! ***** //
51 // ***** ============================================== ***** //
52
53 /** Generates a unique key for this state.
54 * There has to be a unique key for each state (fast closed list -> bottleneck!)
55 * @return unique key
56 */
57 virtual size_t key() = 0;
58
59 /** Estimate the heuristic cost to the goal.
60 * @return estimated cost
61 */
62 virtual float estimate() = 0;
63
64 /** Check, wether we reached a goal or not.
65 * @return true, if this state is a goal, else false
66 */
67 virtual bool is_goal() = 0;
68
69 /** Generate all successors and put them to this vector.
70 * @return a vector of pointers of AStarState to a successor
71 */
72 virtual std::vector<AStarState *> children() = 0;
73
74 /** Predecessor. */
76
77 /** Cost of path leading to this search state. */
78 float path_cost;
79
80 /** Total estimated cost. */
82};
83
84} // end namespace fawkes
85
86#endif
This is the abstract(!) class for an A* State.
Definition: astar_state.h:39
virtual size_t key()=0
Generates a unique key for this state.
virtual std::vector< AStarState * > children()=0
Generate all successors and put them to this vector.
AStarState * parent
Predecessor.
Definition: astar_state.h:75
virtual bool is_goal()=0
Check, wether we reached a goal or not.
virtual ~AStarState()
Destructor.
Definition: astar_state.h:48
float total_estimated_cost
Total estimated cost.
Definition: astar_state.h:81
virtual float estimate()=0
Estimate the heuristic cost to the goal.
float path_cost
Cost of path leading to this search state.
Definition: astar_state.h:78
AStarState(float cost_sofar, AStarState *parent)
Constructor.
Definition: astar_state.h:45
Fawkes library namespace.