Not better counter counts how many times the solution after reset was
NOT better. The counter is reset when the improvement was significant,
currently 25 %. The algorithm is finished when there is number of
consecutive NOT better results, the current threshold is 5 results.
unsigned int icnt = 0;
unsigned int rcnt = 0;
unsigned int bcnt = 0;
+ unsigned int ncnt = 0; // not better counter
Json::Value best_path;
Json::Value pj;
double cost = 0.0;
double gc = pj["goal_cc"].asDouble();
assert(gc > 0.0);
if (cost == 0.0 || gc < cost) {
+ if (gc < 0.75 * cost) {
+ ncnt = 0;
+ }
best_path = pj["path"];
cost = gc;
bcnt += 1;
+ } else {
+ ncnt++;
}
}
+ if (ncnt > 5) {
+ break;
+ }
p.reset();
rcnt += 1;
}