Пример #1
0
    def before_integrate(self, t):
        prev_f = collections.deque(maxlen=self.max_order + 1)
        prev_t = collections.deque(maxlen=self.max_order + 1)
        phi = collections.deque(maxlen=self.max_order)

        t0 = t[0]
        f0 = self.func(tf.cast(t0, self.y0[0].dtype), self.y0)
        prev_t.appendleft(t0)
        prev_f.appendleft(f0)
        phi.appendleft(f0)
        first_step = _select_initial_step(self.func,
                                          t[0],
                                          self.y0,
                                          2,
                                          self.rtol[0],
                                          self.atol[0],
                                          f0=f0)
        first_step = move_to_device(first_step, t.device)
        first_step = tf.cast(first_step, t[0].dtype)

        self.vcabm_state = _VCABMState(self.y0,
                                       prev_f,
                                       prev_t,
                                       next_t=t[0] + first_step,
                                       phi=phi,
                                       order=1)
Пример #2
0
 def before_integrate(self, t):
     f0 = self.func(tf.cast(t[0], self.y0[0].dtype), self.y0)
     if self.first_step is None:
         first_step = _select_initial_step(self.func, t[0], self.y0, 1, self.rtol[0], self.atol[0], f0=f0)
         first_step = move_to_device(tf.cast(first_step, t.dtype), t.device)
     else:
         first_step = _convert_to_tensor(self.first_step, dtype=t.dtype, device=t.device)
     self.rk_state = _RungeKuttaState(self.y0, f0, t[0], t[0], first_step, interp_coeff=[self.y0] * 5)
Пример #3
0
 def before_integrate(self, t):
     if self.first_step is None:
         first_step = _convert_to_tensor(_select_initial_step(self.func, t[0], self.y0, 4, self.rtol, self.atol),
                                         device=t.device)
     else:
         first_step = _convert_to_tensor(0.01, dtype=t.dtype, device=t.device)
     self.rk_state = _RungeKuttaState(
         self.y0,
         cast_double(self.func(t[0], self.y0)), t[0], t[0], first_step,
         tuple(map(lambda x: [x] * 7, self.y0))
     )
Пример #4
0
    def before_integrate(self, t):
        if self.first_step is None:
            first_step = _convert_to_tensor(_select_initial_step(self.func, t[0], self.y0, 4, self.rtol, self.atol),
                                            device=t.device)
        else:
            first_step = _convert_to_tensor(self.first_step, dtype=t.dtype, device=t.device)

        self.rk_state = _RungeKuttaState(
            self.y0,
            self.func(t[0], self.y0), t[0], t[0], first_step,
            [self.y0] * 7
        )