MCPcopy Index your code
hub / github.com/algorithmicsuperintelligence/openevolve / run

Method run

openevolve/controller.py:249–413  ·  view source on GitHub ↗

Run the evolution process with improved parallel processing Args: iterations: Maximum number of iterations (uses config if None) target_score: Target score to reach (continues until reached if specified) checkpoint_path: Path to resume from check

(
        self,
        iterations: Optional[int] = None,
        target_score: Optional[float] = None,
        checkpoint_path: Optional[str] = None,
    )

Source from the content-addressed store, hash-verified

247 return f.read()
248
249 async def run(
250 self,
251 iterations: Optional[int] = None,
252 target_score: Optional[float] = None,
253 checkpoint_path: Optional[str] = None,
254 ) -> Optional[Program]:
255 """
256 Run the evolution process with improved parallel processing
257
258 Args:
259 iterations: Maximum number of iterations (uses config if None)
260 target_score: Target score to reach (continues until reached if specified)
261 checkpoint_path: Path to resume from checkpoint
262
263 Returns:
264 Best program found
265 """
266 max_iterations = iterations or self.config.max_iterations
267
268 # Determine starting iteration
269 start_iteration = 0
270 if checkpoint_path and os.path.exists(checkpoint_path):
271 self._load_checkpoint(checkpoint_path)
272 start_iteration = self.database.last_iteration + 1
273 logger.info(f"Resuming from checkpoint at iteration {start_iteration}")
274 else:
275 start_iteration = self.database.last_iteration
276
277 # Only add initial program if starting fresh (not resuming from checkpoint)
278 should_add_initial = (
279 start_iteration == 0
280 and len(self.database.programs) == 0
281 and not any(
282 p.code == self.initial_program_code for p in self.database.programs.values()
283 )
284 )
285
286 if should_add_initial:
287 logger.info("Adding initial program to database")
288 initial_program_id = str(uuid.uuid4())
289
290 # Evaluate the initial program
291 initial_metrics = await self.evaluator.evaluate_program(
292 self.initial_program_code, initial_program_id
293 )
294
295 initial_program = Program(
296 id=initial_program_id,
297 code=self.initial_program_code,
298 changes_description=self.config.prompt.initial_changes_description,
299 language=self.config.language,
300 metrics=initial_metrics,
301 iteration_found=start_iteration,
302 )
303
304 self.database.add(initial_program)
305
306 # Check if combined_score is present in the metrics

Calls 13

_load_checkpointMethod · 0.95
_save_best_programMethod · 0.95
ProgramClass · 0.90
format_metrics_safeFunction · 0.90
addMethod · 0.80
startMethod · 0.80
stopMethod · 0.80
closeMethod · 0.80
getMethod · 0.80
get_best_programMethod · 0.80