Skip to content

Commit 859ef0c

Browse files
committed
additional feature to continue the optimization from the last point:
- This is in case the user wants to restart the optimization from the last point reached in previous iterations and want to use different settigns like a different optimization engine. It defaults to continued=False
1 parent b2ad1d7 commit 859ef0c

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

famodel/design/LineDesign.py

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def __init__(self, depth, lineProps=None, **kwargs):
7575
of line sections and the last entry is the DAF to be used for anchor loads. Default is 1.
7676
7777
'''
78+
self.settings = kwargs
7879

7980
self.display = getFromDict(kwargs, 'display', default=0)
8081

@@ -996,24 +997,37 @@ def clearNormalization(self):
996997
self.con_denorm = np.ones(len(self.constraints))
997998

998999

999-
def optimize(self, gtol=0.03, maxIter=40, nRetry=0, plot=False, display=0, stepfac=4, method='dopt'):
1000+
def optimize(self, gtol=0.03, maxIter=40, nRetry=0, plot=False, display=0, stepfac=4, method='dopt', continued=False):
10001001
'''Optimize the design variables according to objectve, constraints, bounds, etc.
10011002
'''
10021003

10031004
# set the display value to use over the entire process
10041005
self.display = display
10051006

1006-
# reset iteration counter
1007-
self.iter = -1
1008-
1009-
# clear optimization progress tracking lists
1010-
self.log['x'] = []
1011-
self.log['f'] = []
1012-
self.log['g'] = []
1013-
self.log['time'] = []
1014-
self.log['xe'] = []
1015-
self.log['a'] = []
1016-
1007+
if not continued:
1008+
# reset iteration counter
1009+
self.iter = -1
1010+
1011+
# clear optimization progress tracking lists
1012+
self.log['x'] = []
1013+
self.log['f'] = []
1014+
self.log['g'] = []
1015+
self.log['time'] = []
1016+
self.log['xe'] = []
1017+
self.log['a'] = []
1018+
1019+
# Set starting point to normalized value
1020+
X0 = self.X0 / self.X_denorm
1021+
1022+
else:
1023+
# Update starting point to the Xlast value
1024+
self.updateDesign(self.Xlast, normalized=False)
1025+
X0 = self.Xlast / self.X_denorm
1026+
1027+
dX_last = self.dX_last / self.X_denorm
1028+
Xmax = self.Xmax / self.X_denorm
1029+
Xmin = self.Xmin / self.X_denorm
1030+
10171031
def eval_func(X, args):
10181032
'''Mooring object evaluation function condusive with MoorSolve.dopt2'''
10191033

@@ -1031,11 +1045,7 @@ def eval_func(X, args):
10311045
else:
10321046
self.noFail = False
10331047

1034-
# Set starting point to normalized value
1035-
X0 = self.X0 / self.X_denorm
1036-
dX_last = self.dX_last / self.X_denorm
1037-
Xmax = self.Xmax / self.X_denorm
1038-
Xmin = self.Xmin / self.X_denorm
1048+
10391049

10401050

10411051
# call optimizer to perform optimization

0 commit comments

Comments
 (0)