diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml deleted file mode 100644 index 29e0fcb29..000000000 --- a/.github/workflows/python-lint.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Lint - -on: [push, pull_request] - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v5 - with: - python-version: "3.13" - - uses: psf/black@stable - with: - options: "--check --verbose" - src: "./openevolve ./tests ./examples ./scripts" - use_pyproject: true \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 184b790a9..d2620160b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,14 +19,6 @@ source env/bin/activate # On Windows: env\Scripts\activate pip install -e ".[dev]" ``` -## Code Style - -We follow the [Black](https://black.readthedocs.io/) code style. Please format your code before submitting a pull request: - -```bash -black openevolve tests examples -``` - ## Pull Request Process 1. Create a new branch for your feature or bugfix: `git checkout -b feat-your-feature-name` diff --git a/openevolve/database.py b/openevolve/database.py index b23b660dd..6e2cd8492 100644 --- a/openevolve/database.py +++ b/openevolve/database.py @@ -662,13 +662,38 @@ def _update_archive(self, program: Program) -> None: self.archive.add(program.id) return - # Otherwise, find worst program in archive - archive_programs = [self.programs[pid] for pid in self.archive] - worst_program = min(archive_programs, key=lambda p: safe_numeric_average(p.metrics)) + # Clean up stale references and get valid archive programs + valid_archive_programs = [] + stale_ids = [] - # Replace if new program is better - if self._is_better(program, worst_program): - self.archive.remove(worst_program.id) + for pid in self.archive: + if pid in self.programs: + valid_archive_programs.append(self.programs[pid]) + else: + stale_ids.append(pid) + + # Remove stale references from archive + for stale_id in stale_ids: + self.archive.discard(stale_id) + logger.debug(f"Removing stale program {stale_id} from archive") + + # If archive is now not full after cleanup, just add the new program + if len(self.archive) < self.config.archive_size: + self.archive.add(program.id) + return + + # Find worst program among valid programs + if valid_archive_programs: + worst_program = min( + valid_archive_programs, key=lambda p: safe_numeric_average(p.metrics) + ) + + # Replace if new program is better + if self._is_better(program, worst_program): + self.archive.remove(worst_program.id) + self.archive.add(program.id) + else: + # No valid programs in archive, just add the new one self.archive.add(program.id) def _update_best_program(self, program: Program) -> None: diff --git a/pyproject.toml b/pyproject.toml index fa4424fe8..267597a8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "openevolve" -version = "0.0.3" +version = "0.0.4" description = "Open-source implementation of AlphaEvolve" readme = "README.md" requires-python = ">=3.9" diff --git a/setup.py b/setup.py index 200863df2..bc5acd412 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="openevolve", - version="0.0.3", + version="0.0.4", packages=find_packages(), include_package_data=True, )