def __init__(self, nn, xs, ys, alpha, beta, gamma, width, bc):
"""xs: x-coordinates
ys: y-coordinates"""
# load the vertices
self.vertices = []
for v in zip(xs, ys):
self.vertices.append(array(v))
self.vertices = array(self.vertices)
self.length = self.vertices.shape[0]
# boundary condition
assert bc == 'PBC' or bc == 'OBC'
self._bc = bc
# width of snake (determining the sensing region)
self.widths = np.ones((self.length, 1)) * width
# for neighbour calculations
id_ = np.arange(self.length)
self.less1 = np.roll(id_, +1)
self.less2 = np.roll(id_, +2)
self.more1 = np.roll(id_, -1)
self.more2 = np.roll(id_, -2)
# implicit time-evolution matrix as in Kass
self._A = alpha * self._alpha_term() + beta * self._beta_term()
self._gamma = gamma
self._inv = np.linalg.inv(self._A + self._gamma * np.identity(self.length))
# the NN for this snake
self.nn = nn
评论列表
文章目录