Skip to content

Refactor Generator Checkpointing into Reusable Class - #454

Open
electronsandstuff wants to merge 5 commits into
xopt-org:mainfrom
electronsandstuff:pierce/ga-outputs
Open

Refactor Generator Checkpointing into Reusable Class#454
electronsandstuff wants to merge 5 commits into
xopt-org:mainfrom
electronsandstuff:pierce/ga-outputs

Conversation

@electronsandstuff

@electronsandstuff electronsandstuff commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

This PR moves the checkpointing feature in NSGA2Generator out into a new class to allow for reuse and enable new genetic algorithms with similar output to be created.

  • New class CheckpointMixin containing attribute checkpoint_file allowing end users to load their checkpoints.
    • Validator load_from_checkpoint which loads the data from the checkpoint and merges with other data from YAML file
    • _save_checkpoint callable by the generator to save a new checkpoint. The idea is that when checkpoints are saved is implementation specific.
  • While implementing, I realized that with Xopt 2.0, VOCS object is serialized with the generator, meaning that the previous workaround of saving a vocs.txt is no longer required. I have migrated the checkpoint system to not save, and to load from the full generator checkpoint instead. If it is not present (as in an old checkpoint is being loaded) it will still search for ../vocs.txt for legacy support. NOTE: Saving of vocs.txt, but not reading for checkpoint, is added back in Refactor GA Output Directory Code into Reusable Base Class #455 (see comments there as to why)
  • New unit tests confirming that the checkpointing feature works.

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@nikitakuklev

Copy link
Copy Markdown
Collaborator

can you rebase this onto the updated ci? (aka current head)

@nikitakuklev

Copy link
Copy Markdown
Collaborator

A bit confused on ordering: if #455 is readding vocs, should this one still delete that code?

@electronsandstuff

Copy link
Copy Markdown
Collaborator Author

A bit confused on ordering: if #455 is readding vocs, should this one still delete that code?

Yeah, the reason I did it this way is:

  • Checkpoints no longer need vocs.txt since the data is included in the dump, so deleted from here
  • External tools still use it, so ownership got changed to the file output code

I think it's best to pull it in this way because vocs.txt should be output with the general MOGA output which isn't factored out of the class until the next PR, so moving it here would look like moving it to NSGA2Generator then moving it out again next PR.

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.

2 participants