python:优化中的brentq优化

时间:2015-02-03 10:40:27

标签: python optimization scipy

我的代码遇到了一些非常烦人的问题。 我认为我的问题是在最小壁厚部分(wtMIN)下,我在最佳范围内计算最佳值。答案会收敛到某个值,但在该转换中,brentq到函数所需的零点会移动到计算边界之外。

 def wtMIN(self,diameter):
    '''
    #here the minimum required wallthickness is calculated for a given diameter
    #Firstly the minimum diameter required to overcome stresses is calculated
    #Since inertia increases to the power of 4 this optimisation always leads to 
    #very large diameter and very small wall thickness, this causes the structure
    #to buckle.
    #Therefore a bucking check is done to see if the structure would buckle
    #Under de BuckOk check. If the structure would buckle a smaller diameter is
    #used and the buckling calculation is made again up untill a diameter and wall
    #thickness if found were no buckling occurs.
    #This buckling optimization cant be done with an optimizer since the
    #function is not contintous.
    '''
    try:
        diameter=diameter[0]
    except TypeError:
        diameter=diameter
    D=diameter
    wt=brentq(self.stressRATIO,D/10000,D/3,args=(D),xtol=0.001)
    buckOK = 'False'
    while buckOK == 'False':
        buckOK=self.buckcheck(D,wt)
        if buckOK == 'False':
            D=D-0.01
            wt=brentq(self.stressRATIO,D/10000,D/3,args=(D),xtol=0.001)
    return wt

同样,我认为这里的问题是想要找到最小屈曲直径的D = D-01环导致最佳偏移超出brentq范围(我得到f(a)和f的值误差( b)需要有不同的标志。

有没有人知道如何解决这个问题?现在已经四个星期以来一直在破坏我的球:(

感谢名单

0 个答案:

没有答案