optimize.py 文件源码

python
阅读 40 收藏 0 点赞 0 评论 0

项目:optimize-stencil 作者: Ablinne 项目源码 文件源码
def _optimize_single(self, x0):
        x0 = list(x0)

        if x0[0] == None:
            x0[0] = 0
            dt_ok = np.asscalar(self.dispersion.dt_ok(x0))
            if dt_ok < 0:
                # Initial conditions violate constraints, reject
                return x0, None, float('inf')

            x0[0] = dt_ok
            x0[0] = min(x0[0], self.dtmax)
            x0[0] = max(x0[0], self.dtmin)

        x0 = np.asfarray(x0)

        stencil_ok = self.dispersion.stencil_ok(x0)
        if stencil_ok < 0:
            # Initial conditions violate constraints, reject
            return x0, None, float('inf')

        res = scop.minimize(self.dispersion.norm, x0, method='SLSQP', constraints = self.constraints, options = dict(disp=False, iprint = 2))
        norm = self.dispersion_high.norm(res.x)

        return x0, res, norm
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号