Skip to content

Refactor GA Output Directory Code into Reusable Base Class - #455

Open
electronsandstuff wants to merge 13 commits into
xopt-org:mainfrom
electronsandstuff:pierce/ga-outputs3
Open

Refactor GA Output Directory Code into Reusable Base Class#455
electronsandstuff wants to merge 13 commits into
xopt-org:mainfrom
electronsandstuff:pierce/ga-outputs3

Conversation

@electronsandstuff

@electronsandstuff electronsandstuff commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Note This is stacked on top of #454. Wait until merged to handle.

This PR refactors the NSGA2 output code into a reusable base class to enable the addition of other genetic algorithms without duplicate code.

  • New base class GAGeneratorBase that includes functionality for checkpointing, population, and data output.
  • Refactor NSGA2Generator to use GAGeneratorBase for output, simplifying the class.
  • New unit tests for output functionality.
  • output_dir now expands environment variables and home character (~)
  • output_dir accepts any os.PathLike
  • Add vocs.txt output back in. I removed it from Refactor Generator Checkpointing into Reusable Class #454 as VOCS data is no longer required to be stored separately to load the serialized generator from a checkpoint. However, I realized that this data is still needed for analysis of optimization results.

TODO

  • Expand home and env variables in output_dir
  • Accept any os.PathLike
  • Add VOCS output back to the output directory. This is necessary for analysis of data after the fact without the config file present.

@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.22485% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
xopt/generators/ga/base.py 93.05% 2 Missing and 3 partials ⚠️
xopt/tests/generators/ga/test_base.py 99.29% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@electronsandstuff
electronsandstuff marked this pull request as ready for review August 11, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant