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

Major iteration counting #39

Merged
merged 43 commits into from
Feb 18, 2020
Merged

Major iteration counting #39

merged 43 commits into from
Feb 18, 2020

Conversation

ewu63
Copy link
Collaborator

@ewu63 ewu63 commented Jun 18, 2019

Addresses #21 by:

  1. calling the SNOPT routine snkerc instead of snoptc
  2. writing a custom snstop code in Python to replace the one supplied by SNOPT, and called every major iteration
  3. wrapping the snstop Python code with f2py and passing it into snkerc since snoptc does not allow passing a custom snstop function handle
  4. modifying the db file structure such that the flag isMajor is set to true when the evaluation is at a major iteration
  5. updating optview accordingly to filter iterations based on this flag

… f2py so that we can script it in python and pass it to SNOPT. Also added isMajor flag in db and modified optview accordingly
@ewu63
Copy link
Collaborator Author

ewu63 commented Jun 18, 2019

To test, run test_hs015.py under /test, and examine the resulting Hist.hst file both by loading it in Python, and by opening it with optview. The flag isMajor should be present and true for major iterations which match the SNOPT print out file. Note that this implementation is able to determine which line search iterations is the actual major iteration, for example callCounter 11 is not a major iteration despite being a funcs call, and this is evident in the SNOPT print out, where nCon is incremented by 2 in major iteration 4.

@johnjasa
Copy link
Member

@nwu63 what's the status on this? Should I test this out now?

@ewu63
Copy link
Collaborator Author

ewu63 commented Jul 18, 2019

Nobody reviewed/tested the code so never merged. I did bug @eirikurj about it but I know he's been very busy. Would be great if someone can check to make sure it works as expected and then pull it in.

@johnjasa johnjasa self-requested a review July 30, 2019 20:24
Copy link
Member

@johnjasa johnjasa left a comment

Choose a reason for hiding this comment

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

Need to change OptView logic to work well with other optimizers. Running with SLSQP then selecting Major Iterations on OptView produces a single point, the first iteration. Try with p hs015.py --opt=SLSQP --storeHistory=1 then running OptView on it.

Otherwise looks good on my end, with all tests passing and OptView looking good for SNOPT!

@johnjasa
Copy link
Member

johnjasa commented Jul 30, 2019

More changes requested:
With the proposed changes, you can't read older history files because they fail on a KeyError.
Here's a snippet:

Traceback (most recent call last):
  File "/home/john/Dropbox/git/pyoptsparse/postprocessing/OptView.py", line 1606, in <module>
    disp = Display(histList, outputDir, figsize)
  File "/home/john/Dropbox/git/pyoptsparse/postprocessing/OptView.py", line 106, in __init__
    self.OptimizationHistory()
  File "/home/john/Dropbox/git/pyoptsparse/postprocessing/OptView.py", line 232, in OptimizationHistory
    self.DetermineMajorIterations(db, OpenMDAO=OpenMDAO)
  File "/home/john/Dropbox/git/pyoptsparse/postprocessing/OptView.py", line 274, in DetermineMajorIterations
    if i == 0 or db[key]['isMajor']:
KeyError: 'isMajor'

Need to add some logic to avoid this issue.

@johnjasa
Copy link
Member

johnjasa commented Oct 7, 2019

We're waiting to merge this in until we have a discussion on the procedure for PyOptSparse updates going forward.

update travis.yml
* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml
* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml
* removed sqlitedict folder

* updated docs to say that sqlitedict is an explicit external dependency

* removed explicit import of sqlitedict from pyoptsparse

* updated docs to pin a version for sqlitedict, also added requirements.txt
@ewu63 ewu63 requested a review from eirikurj February 16, 2020 20:57
@@ -21,6 +21,7 @@
# External Python modules
# =============================================================================
import os
import numpy as np
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency of the code use numpy instead of the np

from .pyOpt_error import Error
from sqlitedict import SqliteDict
eps = numpy.finfo(1.0).eps
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using 1.0 use numpy.float_ or numpy.float64

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.

3 participants