Exemplo n.º 1
0
    def __init__(self,
                 func,
                 y0,
                 rtol,
                 atol,
                 first_step=None,
                 safety=0.9,
                 ifactor=10.0,
                 dfactor=0.2,
                 max_num_steps=2**31 - 1,
                 **unused_kwargs):
        _handle_unused_kwargs(self, unused_kwargs)
        del unused_kwargs

        self.func = func
        self.y0 = y0
        self.rtol = rtol if _is_iterable(rtol) else [rtol] * len(y0)
        self.atol = atol if _is_iterable(atol) else [atol] * len(y0)
        self.first_step = first_step
        self.safety = _convert_to_tensor(safety,
                                         dtype=tf.float64,
                                         device=y0[0].device)
        self.ifactor = _convert_to_tensor(ifactor,
                                          dtype=tf.float64,
                                          device=y0[0].device)
        self.dfactor = _convert_to_tensor(dfactor,
                                          dtype=tf.float64,
                                          device=y0[0].device)
        self.max_num_steps = _convert_to_tensor(max_num_steps,
                                                dtype=tf.int32,
                                                device=y0[0].device)
Exemplo n.º 2
0
    def __init__(self,
                 func,
                 y0,
                 rtol,
                 atol,
                 implicit=True,
                 first_step=None,
                 max_order=_MAX_ORDER,
                 safety=0.9,
                 ifactor=10.0,
                 dfactor=0.2,
                 **unused_kwargs):
        _handle_unused_kwargs(self, unused_kwargs)
        del unused_kwargs

        self.func = func
        self.y0 = y0
        self.rtol = rtol if _is_iterable(rtol) else [rtol] * len(y0)
        self.atol = atol if _is_iterable(atol) else [atol] * len(y0)
        self.implicit = implicit
        self.first_step = first_step
        self.max_order = int(max(_MIN_ORDER, min(max_order, _MAX_ORDER)))
        self.safety = _convert_to_tensor(safety,
                                         dtype=tf.float64,
                                         device=y0[0].device)
        self.ifactor = _convert_to_tensor(ifactor,
                                          dtype=tf.float64,
                                          device=y0[0].device)
        self.dfactor = _convert_to_tensor(dfactor,
                                          dtype=tf.float64,
                                          device=y0[0].device)
Exemplo n.º 3
0
    def __init__(self, func, y0, atol, rtol, **unused_kwargs):
        _handle_unused_kwargs(self, unused_kwargs)
        del unused_kwargs

        self.func = func
        self.y0 = y0
        self.atol = atol
        self.rtol = rtol
Exemplo n.º 4
0
    def __init__(self, func, y0, step_size=None, grid_constructor=None, **unused_kwargs):
        unused_kwargs.pop('rtol', None)
        unused_kwargs.pop('atol', None)
        _handle_unused_kwargs(self, unused_kwargs)
        del unused_kwargs

        self.func = func
        self.y0 = y0

        if step_size is not None and grid_constructor is None:
            self.grid_constructor = self._grid_constructor_from_step_size(step_size)
        elif grid_constructor is None:
            self.grid_constructor = lambda f, y0, t: t
        else:
            raise ValueError("step_size and grid_constructor are exclusive arguments.")