Skip to content

Commit b63ef85

Browse files
authored
Merge pull request algorithmicsuperintelligence#90 from codelion/feat-release-0.0.4
Fix archive cleanup and bump version to 0.0.4
2 parents 3dafd19 + 8ebe0a4 commit b63ef85

File tree

5 files changed

+33
-33
lines changed

5 files changed

+33
-33
lines changed

.github/workflows/python-lint.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ source env/bin/activate # On Windows: env\Scripts\activate
1919
pip install -e ".[dev]"
2020
```
2121

22-
## Code Style
23-
24-
We follow the [Black](https://black.readthedocs.io/) code style. Please format your code before submitting a pull request:
25-
26-
```bash
27-
black openevolve tests examples
28-
```
29-
3022
## Pull Request Process
3123

3224
1. Create a new branch for your feature or bugfix: `git checkout -b feat-your-feature-name`

openevolve/database.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -662,13 +662,38 @@ def _update_archive(self, program: Program) -> None:
662662
self.archive.add(program.id)
663663
return
664664

665-
# Otherwise, find worst program in archive
666-
archive_programs = [self.programs[pid] for pid in self.archive]
667-
worst_program = min(archive_programs, key=lambda p: safe_numeric_average(p.metrics))
665+
# Clean up stale references and get valid archive programs
666+
valid_archive_programs = []
667+
stale_ids = []
668668

669-
# Replace if new program is better
670-
if self._is_better(program, worst_program):
671-
self.archive.remove(worst_program.id)
669+
for pid in self.archive:
670+
if pid in self.programs:
671+
valid_archive_programs.append(self.programs[pid])
672+
else:
673+
stale_ids.append(pid)
674+
675+
# Remove stale references from archive
676+
for stale_id in stale_ids:
677+
self.archive.discard(stale_id)
678+
logger.debug(f"Removing stale program {stale_id} from archive")
679+
680+
# If archive is now not full after cleanup, just add the new program
681+
if len(self.archive) < self.config.archive_size:
682+
self.archive.add(program.id)
683+
return
684+
685+
# Find worst program among valid programs
686+
if valid_archive_programs:
687+
worst_program = min(
688+
valid_archive_programs, key=lambda p: safe_numeric_average(p.metrics)
689+
)
690+
691+
# Replace if new program is better
692+
if self._is_better(program, worst_program):
693+
self.archive.remove(worst_program.id)
694+
self.archive.add(program.id)
695+
else:
696+
# No valid programs in archive, just add the new one
672697
self.archive.add(program.id)
673698

674699
def _update_best_program(self, program: Program) -> None:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "openevolve"
7-
version = "0.0.3"
7+
version = "0.0.4"
88
description = "Open-source implementation of AlphaEvolve"
99
readme = "README.md"
1010
requires-python = ">=3.9"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="openevolve",
5-
version="0.0.3",
5+
version="0.0.4",
66
packages=find_packages(),
77
include_package_data=True,
88
)

0 commit comments

Comments
 (0)