Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isMajor not returned for non-major iterations using getValues #269

Open
joanibal opened this issue Jul 19, 2021 · 1 comment
Open

isMajor not returned for non-major iterations using getValues #269

joanibal opened this issue Jul 19, 2021 · 1 comment

Comments

@joanibal
Copy link
Collaborator

Description

The code incorrectly assumes that isMajor is only defined at major iterations.
The code makes the check for the isMajor flag as part of the check here

Possibly related to issue #250

Steps to reproduce issue

  1. create a history file using SNOPT
  2. optHist = History(hist_file)
    histValues = optHist.getValues('isMajor',major=False)

Current behavior

raises the warning

"The major flag has been set to True, since some names specified only exist on major iterations."

and returns the values of isMajor at only major iterations

Expected behavior

returns the value lf isMajor at all iterations

Code versions

List versions only if relevant

  • pyoptsparse: 2.6.2
@marcomangano
Copy link
Contributor

It does look that the two issues are essentially the same, and I think what @nwu63 recommended (showing all the shared values, and add the major-only where applies) still makes sense. With some luck we should be able to fix this directly within getValues().

I append an example to show the difference between major and minor history entries:

Major --> 74 dict_keys(['xuser', 'funcs', 'fail', 'iter', 'isMajor', 'nMajor', 'nMinor', 'step', 'merit', 'feasibility', 'optimality', 'penalty'])
Minor --> 76 dict_keys(['xuser', 'funcs', 'fail', 'iter', 'isMajor'])
Gradient evaluation --> 77 dict_keys(['xuser', 'funcsSens', 'fail', 'iter', 'isMajor'])  (all calls to func or funcSens increase the counter, then the iteration number is "corrected" at a later stage, we discussed a bit of this in #252 and related #182 )

How a bit of history might look like:

78 dict_keys(['xuser', 'funcs', 'fail', 'iter', 'isMajor'])
79 dict_keys(['xuser', 'funcsSens', 'fail', 'iter', 'isMajor'])
80 dict_keys(['xuser', 'funcs', 'fail', 'iter', 'isMajor'])
81 dict_keys(['xuser', 'funcsSens', 'fail', 'iter', 'isMajor'])
83 dict_keys(['xuser', 'funcsSens', 'fail', 'iter', 'isMajor'])
82 dict_keys(['xuser', 'funcs', 'fail', 'iter', 'isMajor', 'nMajor', 'nMinor', 'step', 'merit', 'feasibility', 'optimality', 'penalty'])
84 dict_keys(['xuser', 'funcs', 'fail', 'iter', 'isMajor'])
85 dict_keys(['xuser', 'funcsSens', 'fail', 'iter', 'isMajor'])
86 dict_keys(['xuser', 'funcs', 'fail', 'iter', 'isMajor'])
87 dict_keys(['xuser', 'funcsSens', 'fail', 'iter', 'isMajor'])
88 dict_keys(['xuser', 'funcs', 'fail', 'iter', 'isMajor'])
89 dict_keys(['xuser', 'funcsSens', 'fail', 'iter', 'isMajor'])
91 dict_keys(['xuser', 'funcsSens', 'fail', 'iter', 'isMajor'])
90 dict_keys(['xuser', 'funcs', 'fail', 'iter', 'isMajor', 'nMajor', 'nMinor', 'step', 'merit', 'feasibility', 'optimality', 'penalty'])
93 dict_keys(['xuser', 'funcsSens', 'fail', 'iter', 'isMajor'])
92 dict_keys(['xuser', 'funcs', 'fail', 'iter', 'isMajor', 'nMajor', 'nMinor', 'step', 'merit', 'feasibility', 'optimality', 'penalty'])

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

No branches or pull requests

2 participants