Skip to content

Commit

Permalink
addressed Ella's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sseraj committed Jul 1, 2024
1 parent 41ae296 commit 5b845ac
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions tests/test_hs015.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,29 +195,32 @@ def test_snopt_snstop(self):
# we should get 70/74
self.assert_inform_equal(sol, optInform=74)

@staticmethod
def my_snstop_restart(iterDict, restartDict):
# Save the restart dictionary
writePickle("restart.pickle", restartDict)
def test_snopt_snstop_restart(self):
pickleFile = "restart.pickle"

# Exit after 5 major iterations
if iterDict["nMajor"] == 5:
return 1
def my_snstop_restart(iterDict, restartDict):
# Save the restart dictionary
writePickle(pickleFile, restartDict)

return 0
# Exit after 5 major iterations
if iterDict["nMajor"] == 5:
return 1

return 0

def test_snopt_snstop_restart(self):
# Run the optimization for 5 major iterations
self.optName = "SNOPT"
self.setup_optProb()
optOptions = {
"snSTOP function handle": self.my_snstop_restart,
"snSTOP function handle": my_snstop_restart,
"snSTOP arguments": ["restartDict"],
}
sol = self.optimize(optOptions=optOptions, storeHistory=True)

# Check that the optimization exited with 74
self.assert_inform_equal(sol, optInform=74)

# Read the restart dictionary pickle file saved by snstop
pickleFile = "restart.pickle"
restartDict = readPickle(pickleFile)

# Now optimize again but using the restart dictionary
Expand All @@ -227,7 +230,7 @@ def test_snopt_snstop_restart(self):
options={
"Start": "Hot",
"Verify level": -1,
"snSTOP function handle": self.my_snstop_restart,
"snSTOP function handle": my_snstop_restart,
"snSTOP arguments": ["restartDict"],
},
)
Expand Down

0 comments on commit 5b845ac

Please sign in to comment.