Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions pyoptsparse/pyOpt_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,16 +542,25 @@ def setDVsFromHistory(self, histFile: str, key: str | None = None) -> None:
default is None which will use the last x-value stored in
the dictionary.
"""

if os.path.exists(histFile):
hist = SqliteDict(histFile)
if key is None:
key = hist["last"]

self.setDVs(hist[key]["xuser"])
hist.close()
else:
raise FileNotFoundError(f"History file '{histFile}' not found!.")
xuser = None
exc: Exception | None = None
if self.comm.rank == 0:
try:
if not os.path.exists(histFile):
raise FileNotFoundError(f"History file '{histFile}' not found!.")
hist = SqliteDict(histFile)
try:
if key is None:
key = hist["last"]
xuser = hist[key]["xuser"]
finally:
hist.close()
except Exception as e: # re-raised on all processors after the bcast
exc = e
exc, xuser = self.comm.bcast((exc, xuser), root=0)
if exc is not None:
raise exc
self.setDVs(xuser)

def printSparsity(self, verticalPrint: bool = False) -> None:
"""
Expand Down
Loading