From: Jiri Vlasak Date: Fri, 10 Sep 2021 10:43:21 +0000 (+0200) Subject: Add not better counter to template with reset X-Git-Tag: v0.5.0~4 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/hubacji1/iamcar2.git/commitdiff_plain/b282229be03a242d09a7c0c6315a823aa1188f42 Add not better counter to template with reset 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. --- diff --git a/src/template-with-reset.cc b/src/template-with-reset.cc index 75a1776..3060190 100644 --- a/src/template-with-reset.cc +++ b/src/template-with-reset.cc @@ -75,6 +75,7 @@ int main() 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; @@ -87,11 +88,19 @@ int main() 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; }