Skip to content

Commit e061fec

Browse files
committed
improve decision for better programs
1 parent 65bc168 commit e061fec

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ To install or update LODA, please follow the [installation instructions](https:/
99
### Enhancements
1010

1111
* Increase max number of interpreter cycles to 15 million
12+
* Improve decision for "better" programs
1213
* Clear caches before comparing programs
1314

1415
# v22.8.4

src/finder.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,14 @@ std::string Finder::isOptimizedBetter(Program existing, Program optimized,
322322
evaluator.clearCaches();
323323
const auto existing_steps = evaluator.eval(existing, tmp, num_terms, false);
324324

325-
// compare number of successfully computed terms
326-
if (optimized_steps.runs > existing_steps.runs) {
327-
return "Better";
328-
} else if (optimized_steps.runs < existing_steps.runs) {
329-
return not_better; // worse
325+
// ensure a minimum number of known terms before comparing
326+
if (terms.size() >= OeisSequence::DEFAULT_SEQ_LENGTH) {
327+
// compare number of successfully computed terms
328+
if (optimized_steps.runs > existing_steps.runs) {
329+
return "Better";
330+
} else if (optimized_steps.runs < existing_steps.runs) {
331+
return not_better; // worse
332+
}
330333
}
331334

332335
// compare number of "bad" operations

0 commit comments

Comments
 (0)