How to set optimization variable resolution in scipy.optimize.minimize

半腔热情 提交于 2019-12-11 07:24:45

问题


Background: A ship is berthed to a jetty using 24 mooring lines and 4 fenders. These mooring lines needs to be pre-tensioned to a design value by experienced engineers. Pre-tensioning is done by setting the appropriate length of each mooring line. Static simulation is done to obtain tension on the lines and compression on the fenders. This is an iterative process as small change in mooring line lenght may cause significant variation in the tension.

Problem Description: An objective function is set up to take mooring line lenghs as an input array and return the sum of absolute differences between target and achieved pretension values.

Now, I am using the scipy.optimize.minimize function with following options:

target_wire_lenghts = {'Line1': (48.0, 49.0),'Line2': (48.0, 49.0),'Line3': (45.0,46.0),
                       'Line4': (10.0,11.0),'Line5': (8.0,9.0),'Line6': (7.0,8.0),
                       'Line7': (46.0,47.0),'Line8': (48.0,49.0),'Line9': (50.0,51.0),
                       'Line10': (33.0,34.0),'Line11': (31.0,32.0),'Line12': (29.0,30.0),
                       'Line13': (32.0,33.0),'Line14': (34.0,35.0),'Line15': (36.0,37.0), 
                       'Line16': (48.0,49.0),'Line17': (46.0,47.0),'Line18': (45.0,46.0),
                       'Line19': (8.0,9.0), 'Line20': (8.0,9.0), 'Line21': (9.0,10.0),
                       'Line22': (44.0,45.0),'Line23': (45.0,46.0), 'Line24': (46.0,48.0)}

# Bounds
bounds = list(target_wire_lenghts.values())
# Initial guess
x0 = [np.mean([min, max], axis=0) for min,max in bounds]

# Options
options = {'ftol' : 0.1,
           'xtol' : 0.1,
           'gtol' : 0.1,
           'maxiter' : 100,
           'accuracy' : 0.1}

result = minimize(objfn, x0, method = 'TNC', bounds = bounds, options =         options)
print(result)

However, the optimizer is not varying the input array. The results are the same as initial input array x0(See the length column below). I tried playing around with the optional tolerance parameters of the 'TNC' solver, but do not see any improvement. Also, notice that eventhough I have set the maxiter = 100, the iteration went to 130.

Please suggest what mistake am I making while calling the minimize function.

EDIT: I figured the optimization was running, but changing the variables by 0.000001 at a time. The option parameter eps (Step size used for numerical approximation of the jacobian.) when set to 0.01, the optimization looked working. Unfortunately, it still was not able to reach a reasonable solution. I tried doing an unbounded optimization, with initial guess x0 being very close to the answer (which I found by manually altering each variable), and then the optimizer was able to give a better solution than my manual one.

So the question now is how to do a 24 variable optimization quickly with bad initial guess? Could multi objective optimization be the answer, where reaching each line pre-tension is an objective?

来源:https://stackoverflow.com/questions/44598954/how-to-set-optimization-variable-resolution-in-scipy-optimize-minimize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!