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
评论列表
文章目录