import asyncio import logging from dotenv import load_dotenv from mathema.core.population_monitor import init_population from mathema.utils.logging_config import setup_logging setup_logging() log = logging.getLogger(__name__) N_RUNS = 10 async def run_single_car_experiment(run_idx: int): pop_id = f"car_pop_run{run_idx:02d}" log.info(f"=== START RUN {run_idx + 1}/{N_RUNS} ({pop_id}) ===") monitor = await init_population(( pop_id, [{"morphology": "car_racing_features", "neural_afs": ["tanh"]}], "gt", "competition", )) # 👉 warten, bis der Monitor sich selbst beendet await monitor._stopped_evt.wait() # optional: letzte Stats loggen s = monitor.state best = await monitor._best_fitness_in_population(s.population_id) log.info( f"=== END RUN {run_idx + 1}/{N_RUNS} " f"gens={s.pop_gen} best_fitness={best:.6f} evals={s.eval_acc} ===" ) async def main(): load_dotenv() for i in range(N_RUNS): await run_single_car_experiment(i) log.info("=== ALL RUNS FINISHED ===") if __name__ == "__main__": asyncio.run(main())