Repository navigation
Conversation
…tion
getValues set major=True whenever a requested name was in iterKeys,
the union of the keys over all call counters. That union also holds the
keys stored at every iteration (isMajor, fail, iter), so
getValues("isMajor", major=False) and getValues(major=False) only
returned major iterations.
Record the keys stored at every function evaluation, and treat only the
others (e.g. SNOPT's merit and feasibility) as major-only. When names is
None, leave the major-only keys out instead of setting major=True.
Fixes mdolab#250, fixes mdolab#269
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #502 +/- ##
=======================================
Coverage 54.22% 54.22%
=======================================
Files 1 1
Lines 225 225
=======================================
Hits 122 122
Misses 103 103 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…nstead of a mocked history
ewu63
previously approved these changes
Oct 26, 2026
ewu63
left a comment
Collaborator
There was a problem hiding this comment.
Thank you for the PR! I'm happy with the library changes, but I pushed a commit to change your tests to be a real SNOPT (and 2 other optimizers) test to exercise the logic in real world optimizations -- wasn't sure if you had access to SNOPT. Hope that's ok
Author
|
Thanks, that is fine. I do not have SNOPT here, so tests with real optimizer histories are better than my constructed one. |
ewu63
approved these changes
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Fixes #250 and #269.
History.getValuessetmajor=Truewhenever a requested name was inself.iterKeys.iterKeysis the union of the keys over all call counters, so it also contains keys that are stored at every iteration, such asisMajor,failanditer. As a result:getValues("isMajor", major=False)returnedisMajorat the major iterations only (isMajornot returned for non-major iterations using getValues #269).getValues(major=False)always returned the major iterations only, because the defaultnamesinclude all iteration keys (getValuesdoes not return all values withmajor=False#250).This PR records the keys that are stored at every function evaluation when the history file is read. Only the other keys, such as
nMajor,meritandfeasibilityfrom SNOPT, count as major-only (self.majorIterKeys). Withmajor=False:namescontains no major-only key, all iterations are returned;namesis given and contains a major-only key,majoris set to True with the same warning as before;namesis None, the major-only keys are left out with a warning, and the other values are returned for all iterations, as suggested ingetValuesdoes not return all values withmajor=False#250.The docstring of
majordescribes this.Expected time until merged
A few days.
Type of change
Testing
New
tests/test_history.py. It makes a history file with ALPSO, then marks every second function evaluation as a minor iteration and storesnMajorandmeritat the major iterations only, as SNOPT does. It checks:getValues("isMajor", major=False)returns all iterations (6 of 12 on main);getValues(major=False)returns all iterations withoutmeritandnMajor(on main it returns the 6 major iterations);getValues(["obj", "merit"], major=False)andgetValues(major=True)return the major iterations, as on main.The first two tests fail on main and pass with this change. The whole
testsfolder on my machine (Windows, Python 3.12): 56 passed, including the 4 new tests, and 97 skipped. The 53 failures all come from optimizers I did not compile here (SLSQP, PSQP, CONMIN, NSGA2); none of them touch the history.Checklist
ruff checkandruff formatto make sure the Python code adheres to PEP-8 and is consistently formattedfprettifyor C/C++ code withclang-formatas applicable