15 #include <unordered_map>
22 template <
class state,
class action,
bool verbose = true>
30 std::vector<action> &thePath);
43 action forbiddenAction, state &currState,
44 std::vector<action> &thePath,
double bound,
double g);
78 template <
class state,
class action,
bool verbose>
81 std::vector<action> &thePath)
85 solutionCost = DBL_MAX;
86 nodesExpanded = nodesTouched = 0;
95 std::vector<action> act;
98 double currBound = heuristic->HCost(from, to);
99 while (solution.size() == 0)
102 printf(
"Starting iteration with bound %f; %llu expanded, %llu generated\n", currBound, nodesExpanded, nodesTouched);
104 DoIteration(env, act[0], from, thePath, currBound, 0);
110 template <
class state,
class action,
bool verbose>
112 action forbiddenAction, state &currState,
113 std::vector<action> &thePath,
double bound,
double g)
115 double h = heuristic->HCost(currState, goal);
127 printf(
"Improved solution to %1.5f\n", solutionCost);
132 std::vector<action> &actions = *actCache.getItem();
134 nodesTouched += actions.size();
136 int depth = (int)thePath.size();
138 for (
unsigned int x = 0; x < actions.size(); x++)
140 if ((depth != 0) && (actions[x] == forbiddenAction))
143 thePath.push_back(actions[x]);
144 double edgeCost = env->
GCost(currState, actions[x]);
146 action a = actions[x];
148 DoIteration(env, a, currState, thePath, bound, g+edgeCost);
152 actCache.returnItem(&actions);