コード例 #1
0
def load_lotkavolterra():
    """Load LV system as a basic IVP."""
    y0 = np.array([20, 20])
    return diffeq_zoo.lotkavolterra(t0=0.0,
                                    tmax=0.55,
                                    y0=y0,
                                    params=(0.5, 0.05, 0.5, 0.05))
コード例 #2
0
def posterior(stepsize, timespan):
    """Kalman smoothing posterior."""
    t0, tmax = timespan
    y0 = 20 * np.ones(2)
    ivp = diffeq_zoo.lotkavolterra(t0=t0, tmax=tmax, y0=y0)
    f = ivp.f
    t0, tmax = ivp.t0, ivp.tmax
    return diffeq.probsolve_ivp(f, t0, tmax, y0, step=stepsize, adaptive=False)
コード例 #3
0
def perturbed_solution(steprule):
    y0 = np.array([0.1, 0.1])
    ode = diffeq_zoo.lotkavolterra(t0=0.0, tmax=1.0, y0=y0)
    rng = np.random.default_rng(seed=1)
    testsolver = diffeq.perturbed.scipy_wrapper.WrappedScipyRungeKutta(
        rk.RK45, steprule=steprule)
    sol = diffeq.perturbed.step.PerturbedStepSolver(
        rng=rng,
        solver=testsolver,
        noise_scale=0.1,
        perturb_function=diffeq.perturbed.step.perturb_uniform,
    )
    return sol.solve(ode)
コード例 #4
0
def ivp():
    y0 = 20.0 * np.ones(2)
    return diffeq_zoo.lotkavolterra(t0=0.0, tmax=0.25, y0=y0)
コード例 #5
0
def case_lotkavolterra(perturbfun, steprule):
    y0 = np.array([0.1, 0.1])
    ode = diffeq_zoo.lotkavolterra(t0=0.0, tmax=1.0, y0=y0)
    return setup_solver(y0, ode, perturbfun, steprule=steprule)
コード例 #6
0
def problem_lotka_volterra():
    ivp = diffeq_zoo.lotkavolterra()
    inits_matrix_full = known_initial_derivatives.LV_INITS
    return ivp, inits_matrix_full
コード例 #7
0

@pytest.fixture
def locations():
    return np.linspace(0.0, 1.0, 20)


@pytest.fixture
def ode_information_operator():
    op = diffeq.odefilter.information_operators.ODEResidual(
        num_prior_derivatives=3, ode_dimension=2)
    return op


@pytest.mark.parametrize(
    "ivp", [diffeq_zoo.lotkavolterra(),
            diffeq_zoo.fitzhughnagumo()])
@pytest.mark.parametrize("ode_measurement_variance", [0.0, 1.0])
@pytest.mark.parametrize("exclude_initial_condition", [True, False])
@pytest.mark.parametrize(
    "approx_strategy",
    [
        None,
        diffeq.odefilter.approx_strategies.EK0(),
        diffeq.odefilter.approx_strategies.EK1(),
    ],
)
def test_ivp_to_regression_problem(
    ivp,
    locations,
    ode_information_operator,
コード例 #8
0
import numpy as np
import pytest

import probnum.problems as pnpr
import probnum.problems.zoo.diffeq as diffeqzoo

ODE_LIST = [
    diffeqzoo.vanderpol(),
    diffeqzoo.threebody(),
    diffeqzoo.rigidbody(),
    diffeqzoo.lotkavolterra(),
    diffeqzoo.logistic(),
    diffeqzoo.seir(),
    diffeqzoo.fitzhughnagumo(),
    diffeqzoo.lorenz63(),
    diffeqzoo.lorenz96(),
]

all_odes = pytest.mark.parametrize("ivp", ODE_LIST)


@all_odes
def test_isinstance(ivp):
    assert isinstance(ivp, pnpr.InitialValueProblem)


@all_odes
def test_eval(ivp):
    f0 = ivp.f(ivp.t0, ivp.y0)
    assert isinstance(f0, np.ndarray)
    if ivp.df is not None:
コード例 #9
0
@pytest.fixture
def locations():
    return np.linspace(0.0, 1.0, 20)


@pytest.fixture
def ode_information_operator():
    op = diffeq.odefilter.information_operators.ODEResidual(
        num_prior_derivatives=3, ode_dimension=2
    )
    return op


@pytest.mark.parametrize(
    "ivp", [diffeq_zoo.lotkavolterra(), diffeq_zoo.fitzhughnagumo()]
)
@pytest.mark.parametrize("ode_measurement_variance", [0.0, 1.0])
@pytest.mark.parametrize("exclude_initial_condition", [True, False])
@pytest.mark.parametrize(
    "approx_strategy",
    [
        None,
        diffeq.odefilter.approx_strategies.EK0(),
        diffeq.odefilter.approx_strategies.EK1(),
    ],
)
def test_ivp_to_regression_problem(
    ivp,
    locations,
    ode_information_operator,
コード例 #10
0
ファイル: conftest.py プロジェクト: tskarvone/probnum
def lotka_volterra():
    y0 = np.array([20.0, 20.0])

    # tmax is ignored anyway
    return diffeq_zoo.lotkavolterra(t0=0.0, tmax=np.inf, y0=y0)