MCPcopy Create free account
hub / github.com/FareedKhan-dev/ai-long-task / _update_best_program

Method _update_best_program

data/database.py:1184–1222  ·  view source on GitHub ↗

Update the absolute best program tracking Args: program: Program to consider as the new best

(self, program: Program)

Source from the content-addressed store, hash-verified

1182 self.archive.add(program.id)
1183
1184 def _update_best_program(self, program: Program) -> None:
1185 """
1186 Update the absolute best program tracking
1187
1188 Args:
1189 program: Program to consider as the new best
1190 """
1191 # If we don't have a best program yet, this becomes the best
1192 if self.best_program_id is None:
1193 self.best_program_id = program.id
1194 logger.debug(f"Set initial best program to {program.id}")
1195 return
1196
1197 # Compare with current best program (if it still exists)
1198 if self.best_program_id not in self.programs:
1199 logger.warning(
1200 f"Best program {self.best_program_id} no longer exists, clearing reference"
1201 )
1202 self.best_program_id = program.id
1203 logger.info(f"Set new best program to {program.id}")
1204 return
1205
1206 current_best = self.programs[self.best_program_id]
1207
1208 # Update if the new program is better
1209 if self._is_better(program, current_best):
1210 old_id = self.best_program_id
1211 self.best_program_id = program.id
1212
1213 # Log the change
1214 if "combined_score" in program.metrics and "combined_score" in current_best.metrics:
1215 old_score = current_best.metrics["combined_score"]
1216 new_score = program.metrics["combined_score"]
1217 score_diff = new_score - old_score
1218 logger.info(
1219 f"New best program {program.id} replaces {old_id} (combined_score: {old_score:.4f} → {new_score:.4f}, +{score_diff:.4f})"
1220 )
1221 else:
1222 logger.info(f"New best program {program.id} replaces {old_id}")
1223
1224 def _update_island_best_program(self, program: Program, island_idx: int) -> None:
1225 """

Callers 1

addMethod · 0.95

Calls 1

_is_betterMethod · 0.95

Tested by

no test coverage detected