SciML / DiffEqNoiseProcess.jl

A library of noise processes for stochastic systems like stochastic differential equations (SDEs) and other systems that are present in scientific machine learning (SciML)
https://docs.sciml.ai/DiffEqNoiseProcess/stable/
Other
63 stars 29 forks source link

CI TRIGGER #184

Closed ArnoStrouwen closed 6 months ago

ArnoStrouwen commented 8 months ago

@ChrisRackauckas This package is in a bad shape. I cannot finish the CI improvements as is. CI does not pass. Test do not pass even more on windows. Can you take a look at this or delegate it to somebody?

ChrisRackauckas commented 8 months ago

@frankschae would you be able to take a look in the next week?

frankschae commented 8 months ago

Yup, I'll have a look.

frankschae commented 7 months ago

Are the Core1 tests actually running?

ChrisRackauckas commented 7 months ago

Yes, it might be slowing down due to depwarns or something though. I suspect there must be one part of the test that got a lot slower.

frankschae commented 7 months ago

Are the timestep_mean, timestep_meanvar, ... functions ok/updated for RAT3?

https://github.com/SciML/SciMLBase.jl/blob/master/src/ensemble/ensemble_analysis.jl

They seem to be the most likely origin for the remaining dep warnings in https://github.com/SciML/DiffEqNoiseProcess.jl/blob/master/test/pcn_test.jl https://github.com/SciML/DiffEqNoiseProcess.jl/blob/master/test/bridge_test.jl

@testset "Brownian Bridge" begin
    using DiffEqNoiseProcess, DiffEqBase, Test, Random, DiffEqBase.EnsembleAnalysis

    Random.seed!(100)
    W = BrownianBridge(0.0, 1.0, 0.0, 1.0, 0.0, 0.0)
    prob = NoiseProblem(W, (0.0, 1.0))
    ensemble_prob = EnsembleProblem(prob)
    @time sol = solve(ensemble_prob, dt = 0.1, trajectories = 100000)

    # Spot check the mean and the variance
    qs = 0:0.1:1
    for i in 2:10
        q = qs[i]
        @test ≈(timestep_mean(sol, i), q, atol = 1e-2)
        @test ≈(timestep_meanvar(sol, i)[2], (1 - q) * q, atol = 1e-2)
    end
    @test ≈(timestep_mean(sol, 1)[1], 0.0, atol = 1e-16)
    @test ≈(timestep_meanvar(sol, 1)[2], 0.0, atol = 1e-16)
    @test ≈(timestep_mean(sol, 11)[1], 1.0, atol = 1e-16)
    @test ≈(timestep_meanvar(sol, 11)[2], 0.0, atol = 1e-16)

    μ = 1.2
    σ = 2.2
    W = GeometricBrownianBridge(μ, σ, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0)
    prob = NoiseProblem(W, (0.0, 1.0))
    ensemble_prob = EnsembleProblem(prob)
    @time sol = solve(ensemble_prob, dt = 0.1, trajectories = 100)

    Random.seed!(100)
    r = 100 # should be independent of the rate, so make it crazy
    rate(u, p, t) = r
    W = CompoundPoissonBridge(rate, 0.0, 1.0, 0.0, 1.0)
    prob = NoiseProblem(W, (0.0, 1.0))
    ensemble_prob = EnsembleProblem(prob)
    @time sol = solve(ensemble_prob, dt = 0.1, trajectories = 100000)

    # Spot check the mean and the variance
    qs = 0:0.1:1
    for i in 2:10
        q = qs[i]
        # Mean and variance of binomial matches that of the Brownian bridge!
        @test ≈(timestep_mean(sol, i), q, atol = 1e-2)
        @test ≈(timestep_meanvar(sol, i)[2], (1 - q) * q, atol = 1e-2)
    end
    @test ≈(timestep_mean(sol, 1)[1], 0.0, atol = 1e-16)
    @test ≈(timestep_meanvar(sol, 1)[2], 0.0, atol = 1e-16)
    @test ≈(timestep_mean(sol, 11)[1], 1.0, atol = 1e-16)
    @test ≈(timestep_meanvar(sol, 11)[2], 0.0, atol = 1e-16)

    # check VBT distributional properties

    W = VirtualBrownianTree(0.0, 0.0; Wend = 1.0, tree_depth = 3)
    prob = NoiseProblem(W, (0.0, 1.0))
    function prob_func(prob, i, repeat)
        # to re-instantiate PRNG
        Wtmp = VirtualBrownianTree(0.0, 0.0; Wend = 1.0, tree_depth = 3)
        remake(prob, noise = Wtmp)
    end
    ensemble_prob = EnsembleProblem(prob, prob_func = prob_func)
    @time sol = solve(ensemble_prob, dt = 0.125, trajectories = 100000)

    # Spot check the mean and the variance
    qs = 0:0.125:1
    for i in 2:8
        q = qs[i]
        @test ≈(timestep_mean(sol, i), q, atol = 1e-2)
        @test ≈(timestep_meanvar(sol, i)[2], (1 - q) * q, atol = 1e-2)
    end
    @test ≈(timestep_mean(sol, 1)[1], 0.0, atol = 1e-16)
    @test ≈(timestep_meanvar(sol, 1)[2], 0.0, atol = 1e-16)
    @test ≈(timestep_mean(sol, Int(2^(W.tree_depth) + 1))[1], W.W[end], atol = 1e-16)
    @test ≈(timestep_meanvar(sol, Int(2^(W.tree_depth) + 1))[2], 0.0, atol = 1e-16)
end
ChrisRackauckas commented 7 months ago

@AayushSabharwal

AayushSabharwal commented 7 months ago

Looks like a one liner https://github.com/SciML/SciMLBase.jl/pull/598

The only depwarns I get in the test above are from geometric_bm which is fixed in this PR