Skip to content

[WIP] PRLO-RAVEN version comparison - #2583

Open
W0lfShAd0w wants to merge 70 commits into
idaholab:develfrom
W0lfShAd0w:PRLO_optimizer_additions
Open

[WIP] PRLO-RAVEN version comparison#2583
W0lfShAd0w wants to merge 70 commits into
idaholab:develfrom
W0lfShAd0w:PRLO_optimizer_additions

Conversation

@W0lfShAd0w

Copy link
Copy Markdown
Collaborator

DO NOT MERGE

Diff comparison for RAVEN and the RAVEN/PRLO development fork.

khnguy22 and others added 30 commits September 10, 2025 09:02
…ange in GA with new mutation and crossover type
…s removes the arbitrary restriction requiring DataObjects to include both 'Inputs' and 'Outputs' nodes, despite the situations where that doesn't makes sense.
…o be calculated incorrectly. (#2)

Co-authored-by: Rollins <rollnk@sawtooth1.ib0.sawtooth.hpc.inl.gov>
…on on the output values prior to calculating the fitness. This had to be implemented separately from the standard RAVEN noramlizeData methodology, as we didn't want to normalize the inputs or return the output values to the user in a normalized format; the normalized values are ONLY needed to estimate the fitness when requested.
… support a reduced input format. Penalty scaling factors are now interpreted as a 2d-array of shape (len(objVar),constraintNum). Function docstrings have been updated accordingly.
…e the way the kwargs dict was being provided to the function.
…ividuals from GA are correctly added to and printed with the list of final solutions in the _solutionExport.
…ce redundancy and prevent data from being deleted unnecessarily.
* The outdated behavior of having randomUtils initialize the RNG with a hardcoded seed value (e.g. 5489) has been replaced with the default seed value of 'None', which prompts numpy.random to take a high-entropy seed value from the OS (e.g. the system clock). A new subnode was added to <RunInfo> to allow for a globalSeed to be set in RAVEN prior to any code execution, which ensures a user-supplied RNG seed is applied before any RNG calls are made, if desired. Setting this globalSeed value to 5489 was necessary in all test files to ensure backwards compatibility with old gold results.

* globalSeed parameter of RunInfo now supports 'None' as a valid input.

* Added a print statement for when no GlobalSeed is provided.

* Minor changes made to address comments in PR idaholab#2534. Several tests were updated to have the proper expliciting seeding of the RNG. The unseeded test in testRandomUtils.py was modified to check 5 random floats for any repeats, which could indicate the RNG is failing.

* global seed added to more tests to ensure consistency with golds.

* Minor change to clarify output messages from globalSeed check.

* Deprecate Rattlesnake and Mammoth (idaholab#2519)

* remove Rattlesnake, Mammoth, and Instant tests

* remove Rattlesnake and Mammoth codeinterfaces

* removing from CodeInterface factory

* removing Mammoth and Rattlesnake references in the docs

* Added globalSeed parameter to test input file for backwards compatability.

* Modified the tolerance on the multiYearDWT test to account for uncertainties in the fitted coefficients due to the small amount of training data.

* Increased tolerances further for multiYearDWT test to get around fitting inconsistencies on the Linux OS test machines. This will be raised and corrected in an issue.

* Attempt at addressing the possible intermittent test error on Fedora machine.

---------

Co-authored-by: Rollins <rollnk@sawtooth1.ib0.sawtooth.hpc.inl.gov>
Co-authored-by: Rollins <rollnk@bitterroot1.ib>
Co-authored-by: Gabriel J. Soto Gonzalez <109242402+GabrielSoto-INL@users.noreply.github.com>
Co-authored-by: Rollins <rollnk@bitterroot1.eth>
Co-authored-by: rollnk <nicholas.rollins@inl.gov>
* Minor bug fixes and formatting improvements. Fixed the bug previously identified and fixed by Khang where non-objective optimization values were not being returned by the GA.

* Applied hotfix from Khang Nguyen that corrects a synchronization issue in the _SolutionExport of NSGA-ii that resulted in model inputs and outputs being coupledi incorrectly. This hotfix does NOT correct the same issue with RAVEN's estimation for the 'final' best values.

* Further improvements from Khang and Mohammad Abdo to improve the syncing of optimizer results and the crowding distance calculation for NSGA-ii. Tested with the GA test suite and stress tested with the ZDT1 test in particular.

* Temporary fix made to correct desyncing issues in the Optimizer between the solution inputs, constraints, and objectives. The culprit was a dict.update() line that was overwriting the correct values with desynced values. This line was necessary because the self._solutionExport() is not being defined correctly. This will be fixed in a subsequent commit.

* Fixed a bug in NSGA-II causing the fitness values to be desynced from the solutions. The desyncing occurs when the 'populationFitness' local variable (used by single-objective optimization) is stored as the 'self.fitness' attribute of the Algorithm by the survivor selection method. NSGA-II can use the populationFitness local variable just fine, so the 'self.fitness' attribute is superfluous anyway.

* Overhauled the method by which NSGA-II was storing data/tracking for solutions to make sure each part of the reproduction process was using the correct values and data for grandparents, parents, and children and that these data were being stored appropriately without overwriting. This in turn fixed the fitness value desyncing issue in NSGA-II as well.

* removed tab character.

* removed trailing whitespace from comment line.

* Commented out a line that is an artifact from cherry-picking from a different branch. This needs to be re-added in a future merge.

* Fixed new variable name to match the camelCase convention used in RAVEN. Also, fixed a bug where unneeded multiobjective variables were expected but not initialized in single objective GA.

---------

Co-authored-by: Rollins <rollnk@sawtooth1.ib0.sawtooth.hpc.inl.gov>
Co-authored-by: Rollins <rollnk@bitterroot1.ib>
Co-authored-by: rollnk <nicholas.rollins@inl.gov>
* Rng improvements (#3)

* The outdated behavior of having randomUtils initialize the RNG with a hardcoded seed value (e.g. 5489) has been replaced with the default seed value of 'None', which prompts numpy.random to take a high-entropy seed value from the OS (e.g. the system clock). A new subnode was added to <RunInfo> to allow for a globalSeed to be set in RAVEN prior to any code execution, which ensures a user-supplied RNG seed is applied before any RNG calls are made, if desired. Setting this globalSeed value to 5489 was necessary in all test files to ensure backwards compatibility with old gold results.

* globalSeed parameter of RunInfo now supports 'None' as a valid input.

* Added a print statement for when no GlobalSeed is provided.

* Minor changes made to address comments in PR idaholab#2534. Several tests were updated to have the proper expliciting seeding of the RNG. The unseeded test in testRandomUtils.py was modified to check 5 random floats for any repeats, which could indicate the RNG is failing.

* global seed added to more tests to ensure consistency with golds.

* Minor change to clarify output messages from globalSeed check.

* Deprecate Rattlesnake and Mammoth (idaholab#2519)

* remove Rattlesnake, Mammoth, and Instant tests

* remove Rattlesnake and Mammoth codeinterfaces

* removing from CodeInterface factory

* removing Mammoth and Rattlesnake references in the docs

* Added globalSeed parameter to test input file for backwards compatability.

* Modified the tolerance on the multiYearDWT test to account for uncertainties in the fitted coefficients due to the small amount of training data.

* Increased tolerances further for multiYearDWT test to get around fitting inconsistencies on the Linux OS test machines. This will be raised and corrected in an issue.

* Attempt at addressing the possible intermittent test error on Fedora machine.

---------

Co-authored-by: Rollins <rollnk@sawtooth1.ib0.sawtooth.hpc.inl.gov>
Co-authored-by: Rollins <rollnk@bitterroot1.ib>
Co-authored-by: Gabriel J. Soto Gonzalez <109242402+GabrielSoto-INL@users.noreply.github.com>
Co-authored-by: Rollins <rollnk@bitterroot1.eth>
Co-authored-by: rollnk <nicholas.rollins@inl.gov>

* Optimizer data storage fixes (#5)

* Minor bug fixes and formatting improvements. Fixed the bug previously identified and fixed by Khang where non-objective optimization values were not being returned by the GA.

* Applied hotfix from Khang Nguyen that corrects a synchronization issue in the _SolutionExport of NSGA-ii that resulted in model inputs and outputs being coupledi incorrectly. This hotfix does NOT correct the same issue with RAVEN's estimation for the 'final' best values.

* Further improvements from Khang and Mohammad Abdo to improve the syncing of optimizer results and the crowding distance calculation for NSGA-ii. Tested with the GA test suite and stress tested with the ZDT1 test in particular.

* Temporary fix made to correct desyncing issues in the Optimizer between the solution inputs, constraints, and objectives. The culprit was a dict.update() line that was overwriting the correct values with desynced values. This line was necessary because the self._solutionExport() is not being defined correctly. This will be fixed in a subsequent commit.

* Fixed a bug in NSGA-II causing the fitness values to be desynced from the solutions. The desyncing occurs when the 'populationFitness' local variable (used by single-objective optimization) is stored as the 'self.fitness' attribute of the Algorithm by the survivor selection method. NSGA-II can use the populationFitness local variable just fine, so the 'self.fitness' attribute is superfluous anyway.

* Overhauled the method by which NSGA-II was storing data/tracking for solutions to make sure each part of the reproduction process was using the correct values and data for grandparents, parents, and children and that these data were being stored appropriately without overwriting. This in turn fixed the fitness value desyncing issue in NSGA-II as well.

* removed tab character.

* removed trailing whitespace from comment line.

* Commented out a line that is an artifact from cherry-picking from a different branch. This needs to be re-added in a future merge.

* Fixed new variable name to match the camelCase convention used in RAVEN. Also, fixed a bug where unneeded multiobjective variables were expected but not initialized in single objective GA.

---------

Co-authored-by: Rollins <rollnk@sawtooth1.ib0.sawtooth.hpc.inl.gov>
Co-authored-by: Rollins <rollnk@bitterroot1.ib>
Co-authored-by: rollnk <nicholas.rollins@inl.gov>

---------

Co-authored-by: Rollins <rollnk@sawtooth1.ib0.sawtooth.hpc.inl.gov>
Co-authored-by: Rollins <rollnk@bitterroot1.ib>
Co-authored-by: Gabriel J. Soto Gonzalez <109242402+GabrielSoto-INL@users.noreply.github.com>
Co-authored-by: Rollins <rollnk@bitterroot1.eth>
Co-authored-by: rollnk <nicholas.rollins@inl.gov>
…r bug still exists where the evaluated constraints are not being correctly stored in this container.
* Rng improvements (#3)

* The outdated behavior of having randomUtils initialize the RNG with a hardcoded seed value (e.g. 5489) has been replaced with the default seed value of 'None', which prompts numpy.random to take a high-entropy seed value from the OS (e.g. the system clock). A new subnode was added to <RunInfo> to allow for a globalSeed to be set in RAVEN prior to any code execution, which ensures a user-supplied RNG seed is applied before any RNG calls are made, if desired. Setting this globalSeed value to 5489 was necessary in all test files to ensure backwards compatibility with old gold results.

* globalSeed parameter of RunInfo now supports 'None' as a valid input.

* Added a print statement for when no GlobalSeed is provided.

* Minor changes made to address comments in PR idaholab#2534. Several tests were updated to have the proper expliciting seeding of the RNG. The unseeded test in testRandomUtils.py was modified to check 5 random floats for any repeats, which could indicate the RNG is failing.

* global seed added to more tests to ensure consistency with golds.

* Minor change to clarify output messages from globalSeed check.

* Deprecate Rattlesnake and Mammoth (idaholab#2519)

* remove Rattlesnake, Mammoth, and Instant tests

* remove Rattlesnake and Mammoth codeinterfaces

* removing from CodeInterface factory

* removing Mammoth and Rattlesnake references in the docs

* Added globalSeed parameter to test input file for backwards compatability.

* Modified the tolerance on the multiYearDWT test to account for uncertainties in the fitted coefficients due to the small amount of training data.

* Increased tolerances further for multiYearDWT test to get around fitting inconsistencies on the Linux OS test machines. This will be raised and corrected in an issue.

* Attempt at addressing the possible intermittent test error on Fedora machine.

---------

Co-authored-by: Rollins <rollnk@sawtooth1.ib0.sawtooth.hpc.inl.gov>
Co-authored-by: Rollins <rollnk@bitterroot1.ib>
Co-authored-by: Gabriel J. Soto Gonzalez <109242402+GabrielSoto-INL@users.noreply.github.com>
Co-authored-by: Rollins <rollnk@bitterroot1.eth>
Co-authored-by: rollnk <nicholas.rollins@inl.gov>

* Optimizer data storage fixes (#5)

* Minor bug fixes and formatting improvements. Fixed the bug previously identified and fixed by Khang where non-objective optimization values were not being returned by the GA.

* Applied hotfix from Khang Nguyen that corrects a synchronization issue in the _SolutionExport of NSGA-ii that resulted in model inputs and outputs being coupledi incorrectly. This hotfix does NOT correct the same issue with RAVEN's estimation for the 'final' best values.

* Further improvements from Khang and Mohammad Abdo to improve the syncing of optimizer results and the crowding distance calculation for NSGA-ii. Tested with the GA test suite and stress tested with the ZDT1 test in particular.

* Temporary fix made to correct desyncing issues in the Optimizer between the solution inputs, constraints, and objectives. The culprit was a dict.update() line that was overwriting the correct values with desynced values. This line was necessary because the self._solutionExport() is not being defined correctly. This will be fixed in a subsequent commit.

* Fixed a bug in NSGA-II causing the fitness values to be desynced from the solutions. The desyncing occurs when the 'populationFitness' local variable (used by single-objective optimization) is stored as the 'self.fitness' attribute of the Algorithm by the survivor selection method. NSGA-II can use the populationFitness local variable just fine, so the 'self.fitness' attribute is superfluous anyway.

* Overhauled the method by which NSGA-II was storing data/tracking for solutions to make sure each part of the reproduction process was using the correct values and data for grandparents, parents, and children and that these data were being stored appropriately without overwriting. This in turn fixed the fitness value desyncing issue in NSGA-II as well.

* removed tab character.

* removed trailing whitespace from comment line.

* Commented out a line that is an artifact from cherry-picking from a different branch. This needs to be re-added in a future merge.

* Fixed new variable name to match the camelCase convention used in RAVEN. Also, fixed a bug where unneeded multiobjective variables were expected but not initialized in single objective GA.

---------

Co-authored-by: Rollins <rollnk@sawtooth1.ib0.sawtooth.hpc.inl.gov>
Co-authored-by: Rollins <rollnk@bitterroot1.ib>
Co-authored-by: rollnk <nicholas.rollins@inl.gov>

* temporary fix to improve data archiving in the solutionExport. A minor bug still exists where the evaluated constraints are not being correctly stored in this container.

* added a comment in EntityFactoryBase for a bug that needs to be fixed later.

---------

Co-authored-by: Rollins <rollnk@sawtooth1.ib0.sawtooth.hpc.inl.gov>
Co-authored-by: Rollins <rollnk@bitterroot1.ib>
Co-authored-by: Gabriel J. Soto Gonzalez <109242402+GabrielSoto-INL@users.noreply.github.com>
Co-authored-by: Rollins <rollnk@bitterroot1.eth>
Co-authored-by: rollnk <nicholas.rollins@inl.gov>
…es aren't correctly being stored in the solutionExport.
… being written to/read from _solutionExport correctly.
…ursive reloading behavior that was causing a while loop to hang.
Updates and fixes in RAVEN related to the PRLO PARCS code interface development and restructuring.
…GA reproduction operators uniformEQCrossoverMethod and swapMutatorEQ.
…Shape input parameter. The coreShape is now inferred from the geometry input parameter.
… calc types (#10)

* Added support for the 'eq_uprate' PRLO calculation type in the RAVEN GA reproduction operators uniformEQCrossoverMethod and swapMutatorEQ.

* Changes made in EQChecker to mirror PRLO updates. Deprecated the coreShape input parameter. The coreShape is now inferred from the geometry input parameter.

---------

Co-authored-by: rollnk <nicholas.rollins@inl.gov>
rollnk and others added 14 commits April 6, 2026 16:56
* Adding modification for equilibrium cycle optimzation samplers and change in GA with new mutation and crossover type

* update and add PRLO module

* Fixed plot name printed in error messages.

* Added logic to allow 'Inputs', 'Outputs', and 'Index' to be None. This removes the arbitrary restriction requiring DataObjects to include both 'Inputs' and 'Outputs' nodes, despite the situations where that doesn't makes sense.

* fixed a bug frontUtils.py that was causing nonfitness pareto fronts to be calculated incorrectly. (#2)

Co-authored-by: Rollins <rollnk@sawtooth1.ib0.sawtooth.hpc.inl.gov>

* Added functionality in the GA optimizer to perform zscore normalization on the output values prior to calculating the fitness. This had to be implemented separately from the standard RAVEN noramlizeData methodology, as we didn't want to normalize the inputs or return the output values to the user in a normalized format; the normalized values are ONLY needed to estimate the fitness when requested.

* Changed the utility of the scaling factors in fitness.py so that they support a reduced input format. Penalty scaling factors are now interpreted as a 2d-array of shape (len(objVar),constraintNum). Function docstrings have been updated accordingly.

* Fixed the way default scaling factors were being applied to accomodate the way the kwargs dict was being provided to the function.

* Adopted some lines from Josh Cogliati to ensure that the most fit individuals from GA are correctly added to and printed with the list of final solutions in the _solutionExport.

* Improved the data storing used in the sampler._solutionExport to reduce redundancy and prevent data from being deleted unnecessarily.

* fixed bug in SSChecker missing symmetricMultiplicity parameter.

* elevated Nth cycle input parameters from 'full' to 'reduced' verbosity.

---------

Co-authored-by: khnguy22 <khnguy22@bright90.cm.cluster>
Co-authored-by: Congjian Wang <congjian.wang@inl.gov>
Co-authored-by: Rollins <rollnk@sawtooth1.ib0.sawtooth.hpc.inl.gov>
Co-authored-by: Rollins <rollnk@bitterroot1.ib>
Co-authored-by: rollnk <nicholas.rollins@inl.gov>
…rst sorted into faFuelDict to avoid confusion with reflector entries.
…s, like the swapMutatorSingleCycle. Previously, this was enabled but not updated in the chromosome correctly, so it was always flagged as invalid.
… fuel locations, but also reloaded locations as long as the batch number and fuel type are the same. This is admittedly very limited and not very useful, but it is an improvement on the old approach.
… PRLO and made discoverable in RAVEN. The old RAVEN versions remain but have been marked with deprecated messages. Once this change is fully validated and merged in PRLO, the old RAVEN versions should be removed (backwards compatability does not need to be maintained here).
@W0lfShAd0w
W0lfShAd0w requested review from Jimmy-INL and wangcj05 June 23, 2026 16:53
@W0lfShAd0w W0lfShAd0w self-assigned this Jun 23, 2026
## Search the rest of the population
if hasattr(self,"_sampledPopulationInfo"):
bestInPopulation = {}
# find best solns from the population

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wangcj05 , @W0lfShAd0w , @JunyungKim What is this doing here? RavenSampled is not Genetic Algorithm, it is actually a base class that all optimizers inherit from. Why does it have fitness and other terms of GA? How will Gradient Descent, Simulated annealing, Bayesian Optimization act when it sees these variables? If the answer is: all of those were modified, this would be even worse! I must be missing something here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good criticism. The concept here is easily generalizable: "population" and "history" should be synonymous. "Fitness" and "optimization goal" are also equivalent. For the time being, I'm using "self._objectiveVar" to represent the optimization goal, though I don't think that evaluates to "fitness" for GA. @Jimmy-INL @wangcj05 do we have an attribute that represents the "goal" value for the optimizer?

#!TODO(rollnk): Deprecated. Replaced by PRLO/src/Optimizers/mutators.py::swapMutatorSS.
#! Remove this copy once the PRLO version is validated in production.
"""
if not any("prlodata" in sublist for sublist in kwargs["files"]):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the swapMutatorSS, swapMutatorEQ, swapMutatorSingleCycle PRLO specific? Didn't we agree that these will be only in PRLO? Can any other user of the RAVEN optimizer use them on any other optimization other than fuel reload? If the answer is no, why are they here? even prlodata is mentioned here, that cannot be the case.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in the TODO message in the docstring, these methods have been migrated to PRLO and the ones found here should not be used. They have been deprecated and will be deleted once it has been deemed safe to do so.

Uniform crossover for equilibrium-cycle (EQ) PRLO shuffling schemes.
Two crossover passes are performed within each retry iteration:

Pass 1 — Fresh-batch (batch-1) crossover: positions where both parents carry

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. This should be in PRLO

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in the TODO message in the docstring, these methods have been migrated to PRLO and the ones found here should not be used. They have been deprecated and will be deleted once it has been deemed safe to do so.

Comment thread scripts/conversionScripts/convert_globalseed.py Outdated
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.

4 participants