CHH3213 / Note-Ubuntu_CHH3213

ubuntu系统CHH3213上做的笔记
0 stars 0 forks source link

30. scipy库优化时定义函数时的两种方法 #30

Open CHH3213 opened 3 years ago

CHH3213 commented 3 years ago

lambda函数形式,例如:

def fun(args):
    b = args
    v = lambda x: (x - b)**2
    return v

嵌套函数形式

    def QPfun(self,ud):
        def fun(u):
            return (u - ud)**2 / 2
        return fun