2 This file is part of I am car.
4 I am car is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 I am car is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with I am car. If not, see <http://www.gnu.org/licenses/>.
24 std::vector<RRTNode *> &nodes,
26 float (*cost)(RRTNode *, RRTNode *))
28 RRTNode *root = nodes[0];
29 std::vector<RRTNode *> s; // DFS stack
30 std::vector<RRTNode *> r; // reset visited_
33 float mcost = (*cost)(root, node);
36 while (s.size() > 0) {
41 if ((*cost)(tmp, node) < mcost) {
43 mcost = (*cost)(tmp, node);
45 for (auto ch: tmp->children()) {
57 std::vector<RRTNode *> &nodes,
59 float (*cost)(RRTNode *, RRTNode *))
61 RRTNode *nn = nodes[0];
62 float mcost = (*cost)(nn, node);
64 // TODO fix see, user-defined reductions
65 #pragma omp parallel for
66 for (i = 0; i < nodes.size(); i++) {
67 if ((*cost)(nodes[i], node) < mcost) {
69 mcost = (*cost)(nodes[i], node);
76 std::vector<RRTNode *> (&nodes)[IYSIZE],
78 float (*cost)(RRTNode *, RRTNode *))
80 int iy = IYI(node->y());
84 unsigned int i = 0; // vector step
85 unsigned int j = 0; // array step
87 while (nn.mc > j * IYSTEP) {
91 #pragma omp parallel for reduction(minn: nn)
92 for (i = 0; i < nodes[iyj].size(); i++) {
93 if ((*cost)(nodes[iyj][i], node) < nn.mc) {
94 nn.mc = (*cost)(nodes[iyj][i], node);
95 nn.nn = nodes[iyj][i];
102 #pragma omp parallel for reduction(minn: nn)
103 for (i = 0; i < nodes[iyj].size(); i++) {
104 if ((*cost)(nodes[iyj][i], node) < nn.mc) {
105 nn.mc = (*cost)(nodes[iyj][i], node);
106 nn.nn = nodes[iyj][i];
116 std::vector<RRTNode *> (&nodes)[IYSIZE],
118 float (*cost)(RRTNode *, RRTNode *))
120 int iy = IYI(node->y());
124 unsigned int i = 0; // vector step
125 unsigned int j = 0; // array step
128 while (nn.mc > j * IYSTEP) {
129 iyj = (int) (iy + j);
132 #pragma omp parallel for reduction(minn: nn)
133 for (i = 0; i < nodes[iyj].size(); i++) {
135 node->h(nodes[iyj][i]->h());
136 if ((*cost)(nodes[iyj][i], node) < nn.mc) {
137 nn.mc = (*cost)(nodes[iyj][i], node);
138 nn.nn = nodes[iyj][i];
143 iyj = (int) (iy - j);
146 #pragma omp parallel for reduction(minn: nn)
147 for (i = 0; i < nodes[iyj].size(); i++) {
149 node->h(nodes[iyj][i]->h());
150 if ((*cost)(nodes[iyj][i], node) < nn.mc) {
151 nn.mc = (*cost)(nodes[iyj][i], node);
152 nn.nn = nodes[iyj][i];