Add iteration_found field to track when best program was discovered #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the best_program_info.json file contains the current iteration number, not the iteration when the best program was actually discovered. This makes it difficult to analyze how quickly the algorithm finds better solutions.
When monitoring the progress using a command like:
watch -n 10 'jq ".metrics.combined_score, .iteration" "$(ls -d checkpoint_* | sort -V | tail -n1)/best_program_info.json"'The iteration value shown is the checkpoint iteration, not when the best program was actually found.
Solution
Added iteration_found field to the Program class to track when a program was discovered during evolution
Updated the add method in ProgramDatabase to set this field when adding a new program
Modified the _save_checkpoint and _save_best_program methods to include the iteration_found field in the output JSON files
Updated initialization of the initial program to set its iteration_found value
Testing
Tested with the function_minimization example to confirm the field is correctly saved in best_program_info.json. The monitoring command can now be updated to:
watch -n 10 'jq ".metrics.combined_score, .iteration_found, .iteration" "$(ls -d checkpoint_* | sort -V | tail -n1)/best_program_info.json"'This now correctly shows:
The iteration when that best program was found
The current iteration (checkpoint iteration)