15 #include <unordered_map>
20 template <
class state,
class action>
26 std::vector<state> &thePath);
28 std::vector<action> &thePath);
38 state parent, state currState,
39 std::vector<state> &thePath,
double bound,
double g);
41 action forbiddenAction, state &currState,
42 std::vector<action> &thePath,
double bound,
double g);
52 template <
class state,
class action>
55 std::vector<state> &thePath)
58 nodesExpanded = nodesTouched = 0;
60 UpdateNextBound(0, 0);
63 while (thePath.size() == 0)
67 lastBound = nextBound;
68 DoIteration(env, from, from, thePath, nextBound, 0);
69 std::cout << nodesExpanded <<
" after next iteration with cost limit " << nextBound << std::endl;
70 if (
fequal(lastBound, nextBound))
75 template <
class state,
class action>
78 std::vector<action> &thePath)
81 nodesExpanded = nodesTouched = 0;
83 UpdateNextBound(0, 0);
85 std::vector<action> act;
89 while (thePath.size() == 0)
93 lastBound = nextBound;
94 DoIteration(env, act[0], from, thePath, nextBound, 0);
95 std::cout << nodesExpanded <<
" after iteration with cost limit " << nextBound << std::endl;
96 if (
fequal(lastBound, nextBound))
101 template <
class state,
class action>
103 state parent, state currState,
104 std::vector<state> &thePath,
double bound,
double g)
108 UpdateNextBound(bound, g);
117 std::vector<state> neighbors;
119 nodesTouched += neighbors.size();
123 for (
unsigned int x = 0; x < neighbors.size(); x++)
125 if (neighbors[x] == parent)
127 thePath.push_back(neighbors[x]);
128 double edgeCost = env->
GCost(currState, neighbors[x]);
129 if (DoIteration(env, currState, neighbors[x], thePath, bound, g+edgeCost))
136 template <
class state,
class action>
138 action forbiddenAction, state &currState,
139 std::vector<action> &thePath,
double bound,
double g)
143 UpdateNextBound(bound, g);
152 std::vector<action> actions;
154 nodesTouched += actions.size();
155 int depth = thePath.size();
157 for (
unsigned int x = 0; x < actions.size(); x++)
159 if ((depth != 0) && (actions[x] == forbiddenAction))
162 thePath.push_back(actions[x]);
164 double edgeCost = env->
GCost(currState, actions[x]);
167 if (DoIteration(env, actions[x], currState, thePath, bound, g+edgeCost))
180 template <
class state,
class action>
183 if (!
fgreater(nextBound, currBound))
188 else if (
fgreater(gCost, currBound) &&
fless(gCost, nextBound))