Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update interface test #11

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
075c05d
Merge pull request #137 from ArnoStrouwen/master
ChrisRackauckas Dec 2, 2023
46542f4
Bump actions/checkout from 3 to 4
dependabot[bot] Dec 4, 2023
011f91b
Merge pull request #138 from SciML/dependabot/github_actions/actions/…
ChrisRackauckas Dec 4, 2023
73312c0
[skip ci] dependabot ignore typos patches
ArnoStrouwen Dec 7, 2023
045ad0c
Merge pull request #139 from ArnoStrouwen/db
ChrisRackauckas Dec 7, 2023
9e403cf
CompatHelper: bump compat for RecursiveArrayTools to 3, (keep existin…
Dec 12, 2023
f2f591d
CompatHelper: bump compat for Turing to 0.30 for package docs, (keep …
Dec 19, 2023
ceed252
CompatHelper: bump compat for OptimizationMOI to 0.2 for package docs…
Dec 20, 2023
fdcec1e
CompatHelper: bump compat for OptimizationNLopt to 0.2 for package do…
Jan 5, 2024
8610cfb
CompatHelper: bump compat for OptimizationMOI to 0.3 for package docs…
Jan 5, 2024
66cb759
Merge pull request #141 from SciML/compathelper/new_version/2023-12-1…
Vaibhavdixit02 Jan 8, 2024
d851dd0
Merge pull request #140 from SciML/compathelper/new_version/2023-12-1…
Vaibhavdixit02 Jan 8, 2024
c72ea84
Merge pull request #142 from SciML/compathelper/new_version/2023-12-2…
Vaibhavdixit02 Jan 8, 2024
23fa9ee
Merge branch 'master' into compathelper/new_version/2024-01-05-18-05-…
Vaibhavdixit02 Jan 8, 2024
6589f28
Merge pull request #143 from SciML/compathelper/new_version/2024-01-0…
Vaibhavdixit02 Jan 8, 2024
cd4feff
Merge branch 'master' into compathelper/new_version/2024-01-05-19-05-…
Vaibhavdixit02 Jan 8, 2024
3051dc4
Merge pull request #144 from SciML/compathelper/new_version/2024-01-0…
Vaibhavdixit02 Jan 8, 2024
12f9204
Bump crate-ci/typos from 1.16.23 to 1.17.0
dependabot[bot] Jan 8, 2024
010928a
Merge pull request #145 from SciML/dependabot/github_actions/crate-ci…
ChrisRackauckas Jan 8, 2024
a4401bf
Bump actions/cache from 3 to 4
dependabot[bot] Jan 22, 2024
1965323
Merge pull request #147 from SciML/dependabot/github_actions/actions/…
ChrisRackauckas Jan 25, 2024
6e1b0db
Integrals 4 upgrade
ArnoStrouwen Feb 1, 2024
061ae0b
remove 1.6 CI and fix documentation project
ArnoStrouwen Feb 1, 2024
02c1f9a
activate windows CI
ArnoStrouwen Feb 1, 2024
9703d27
do not fail fast
ArnoStrouwen Feb 1, 2024
c7d8d10
Update src/expectation.jl
ChrisRackauckas Feb 18, 2024
3bc3d4d
Update src/expectation.jl
ChrisRackauckas Feb 18, 2024
1e0d423
replace which system map functor is deleted
ArnoStrouwen Feb 18, 2024
3383ee6
Revert "Update src/expectation.jl"
ArnoStrouwen Feb 18, 2024
1d48420
Revert "Update src/expectation.jl"
ArnoStrouwen Feb 18, 2024
a486682
fix nout bug
lxvm Feb 18, 2024
f32b4e7
fix diff test
lxvm Feb 18, 2024
2de1f26
remove a deprecation warning
lxvm Feb 18, 2024
748a136
deprecate nout
lxvm Feb 19, 2024
c4560ea
remove nout from tests
lxvm Feb 19, 2024
f4e16a6
Integrals 4 updates
lxvm Feb 19, 2024
04dccc7
update docs
lxvm Feb 19, 2024
e345319
bump deps
lxvm Feb 22, 2024
44d5742
Update introduction.md
lxvm Feb 22, 2024
a6ed5a3
update tests
lxvm Feb 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
ignore:
- dependency-name: "crate-ci/typos"
update-types: ["version-update:semver-patch"]
10 changes: 7 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@ on:
- 'docs/**'
jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
group:
- Core
version:
- '1'
- '1.6'
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
- uses: actions/cache@v3
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/SpellCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Check spelling
uses: crate-ci/typos@v1.16.23
uses: crate-ci/typos@v1.17.0
18 changes: 9 additions & 9 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
Aqua = "0.8"
BenchmarkTools = "1"
ComponentArrays = "0.15"
Cuba = "2"
Cubature = "1.5"
DiffEqBase = "6.100"
DiffEqNoiseProcess = "5"
Distributions = "0.23, 0.24, 0.25"
FiniteDiff = "2"
ForwardDiff = "0.10"
Integrals = "3.1"
IntegralsCuba = "0.2"
IntegralsCubature = "0.2"
Integrals = "4.4"
KernelDensity = "0.6"
LinearAlgebra = "1"
OrdinaryDiffEq = "6"
Parameters = "0.12"
Pkg ="1"
Pkg = "1"
PkgBenchmark = "0.2"
Random = "1"
RecursiveArrayTools = "2"
RecursiveArrayTools = "2, 3"
Reexport = "0.2, 1.0"
ReferenceTests = "0.10"
SciMLBase = "1, 2"
SafeTestsets = "0.1"
SciMLBase = "2"
StaticArrays = "1"
Statistics = "1"
StochasticDiffEq = "6"
Expand All @@ -56,11 +56,11 @@ julia = "1.6"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
Cuba = "8a292aeb-7a57-582c-b821-06e4c11590b1"
Cubature = "667455a9-e2ce-5579-9412-b964f529a492"
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Integrals = "de52edbc-65ea-441a-8357-d3a637375a31"
IntegralsCuba = "e00cd5f1-6337-4131-8b37-28b2fe4cd6cb"
IntegralsCubature = "c31f79ba-6e32-46d4-a52f-182a8ac42a54"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
Expand All @@ -74,4 +74,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"

[targets]
test = ["Test", "Aqua", "SafeTestsets", "TestExtras", "Pkg", "PkgBenchmark", "BenchmarkTools", "ReferenceTests", "SymPy", "Random", "OrdinaryDiffEq", "ComponentArrays", "ForwardDiff", "Integrals", "IntegralsCubature", "IntegralsCuba", "FiniteDiff", "RecursiveArrayTools", "StochasticDiffEq"]
test = ["Test", "Aqua", "SafeTestsets", "TestExtras", "Pkg", "PkgBenchmark", "BenchmarkTools", "ReferenceTests", "SymPy", "Random", "OrdinaryDiffEq", "ComponentArrays", "ForwardDiff", "Integrals", "Cubature", "Cuba", "FiniteDiff", "RecursiveArrayTools", "StochasticDiffEq"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ the documentation, which contains the unreleased features.
### Example

```julia
using SciMLExpectations, OrdinaryDiffEq, Distributions, IntegralsCubature
using SciMLExpectations, OrdinaryDiffEq, Distributions, Cubature

function eom!(du, u, p, t, A)
du .= A * u
Expand Down Expand Up @@ -56,7 +56,7 @@ julia> analytical

```julia
g(sol, p) = sol[:, end]
exprob = ExpectationProblem(sm, g, cov, gd; nout = length(u0))
exprob = ExpectationProblem(sm, g, cov, gd)
sol = solve(exprob, Koopman(); quadalg = CubatureJLh(),
ireltol = 1e-3, iabstol = 1e-3)
sol.u # Expectation of the states 1 and 2 at the final time point
Expand Down
9 changes: 4 additions & 5 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[deps]
Cuba = "8a292aeb-7a57-582c-b821-06e4c11590b1"
DiffEqGPU = "071ae1c0-96b5-11e9-1965-c90190d839ea"
DiffEqNoiseProcess = "77a26b50-5914-5dd7-bc55-306e6241c503"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
IntegralsCuba = "e00cd5f1-6337-4131-8b37-28b2fe4cd6cb"
KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
Expand All @@ -26,15 +26,14 @@ DifferentialEquations = "7"
Distributions = "0.25"
Documenter = "1"
ForwardDiff = "0.10"
IntegralsCuba = "0.3"
KernelDensity = "0.6"
MCMCChains = "6"
Optimization = "3"
OptimizationMOI = "0.1"
OptimizationNLopt = "0.1"
OptimizationMOI = "0.1, 0.2, 0.3"
OptimizationNLopt = "0.1, 0.2"
OrdinaryDiffEq = "6"
Plots = "1"
SciMLSensitivity = "7"
StatsPlots = "0.15"
StochasticDiffEq = "6"
Turing = "0.29"
Turing = "0.29, 0.30"
4 changes: 2 additions & 2 deletions docs/src/tutorials/gpu_bayesian.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Let's start by importing all the necessary libraries:
using OrdinaryDiffEq
using Turing, MCMCChains, Distributions
using KernelDensity
using SciMLExpectations, IntegralsCuba
using SciMLExpectations, Cuba
using DiffEqGPU
using Plots, StatsPlots
using Random;
Expand Down Expand Up @@ -166,7 +166,7 @@ ub = [p_kde_i.x[end] for p_kde_i in p_kde] #upper bound for integration
gd = GenericDistribution(pdf_func, rand_func, lb, ub)
h(x, u, p) = u, x
sm = SystemMap(prob1, Tsit5())
exprob = ExpectationProblem(sm, g, h, gd; nout = 1)
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman(); reltol = 1e-2, abstol = 1e-2)
sol.u
```
Expand Down
44 changes: 22 additions & 22 deletions docs/src/tutorials/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ using SciMLExpectations
gd = GenericDistribution(u0_dist...)
h(x, u, p) = x, p
sm = SystemMap(prob, Tsit5())
exprob = ExpectationProblem(sm, g, h, gd; nout = 1)
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, MonteCarlo(100000))
sol.u
```
Expand Down Expand Up @@ -115,7 +115,7 @@ Changing the distribution, we arrive at
```@example introduction
u0_dist = [Uniform(0.0, 10.0)]
gd = GenericDistribution(u0_dist...)
exprob = ExpectationProblem(sm, g, h, gd; nout = length(u0))
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, MonteCarlo(100000))
sol.u
```
Expand All @@ -125,7 +125,7 @@ and
```@example introduction
u0_dist = [Uniform(0.0, 10.0)]
gd = GenericDistribution(u0_dist...)
exprob = ExpectationProblem(sm, g, h, gd; nout = length(u0))
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
```
Expand All @@ -141,7 +141,7 @@ Note that the `Koopman()` algorithm doesn't currently support infinite or semi-i
```@example introduction
u0_dist = [Normal(3.0, 2.0)]
gd = GenericDistribution(u0_dist...)
exprob = ExpectationProblem(sm, g, h, gd; nout = length(u0))
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
```
Expand All @@ -157,7 +157,7 @@ Using a truncated distribution will alleviate this problem. However, there is an
```@example introduction
u0_dist = [truncated(Normal(3.0, 2.0), -1000, 1000)]
gd = GenericDistribution(u0_dist...)
exprob = ExpectationProblem(sm, g, h, gd; nout = length(u0))
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
```
Expand All @@ -167,7 +167,7 @@ whereas truncating at $\pm 4\sigma$ produces the correct result
```@example introduction
u0_dist = [truncated(Normal(3.0, 2.0), -5, 11)]
gd = GenericDistribution(u0_dist...)
exprob = ExpectationProblem(sm, g, h, gd; nout = length(u0))
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
```
Expand All @@ -177,20 +177,20 @@ If a large truncation is required, it is best practice to center the distributio
```@example introduction
u0_dist = [truncated(Normal(3.0, 2.0), 3 - 1000, 3 + 1000)]
gd = GenericDistribution(u0_dist...)
exprob = ExpectationProblem(sm, g, h, gd; nout = length(u0))
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
```

## Vector-Valued Functions

`ExpectationProblem` can also handle vector-valued functions. Simply pass the vector-valued function and set the `nout` kwarg to the length of the vector the function returns.
`ExpectationProblem` can also handle vector-valued functions.

Here, we demonstrate this by computing the expectation of `u` at `t=4.0s` and `t=6.0s`

```@example introduction
g(sol, p) = [sol(4.0)[1], sol(6.0)[1]]
exprob = ExpectationProblem(sm, g, h, gd; nout = 2)
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
```
Expand All @@ -208,7 +208,7 @@ saveat = tspan[1]:0.5:tspan[2]
g(sol, p) = sol[1, :]
prob = ODEProblem(f, u0, tspan, p, saveat = saveat)
sm = SystemMap(prob, Tsit5())
exprob = ExpectationProblem(sm, g, h, gd; nout = length(saveat))
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
```
Expand All @@ -234,21 +234,21 @@ end
counter = [0, 0, 0]
g(sol, p, power) = g(sol, p, power, counter)
g(sol, p) = g(sol, p, 1)
exprob = ExpectationProblem(sm, g, h, gd; nout = 1)
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
```

```@example introduction
g(sol, p) = g(sol, p, 2)
exprob = ExpectationProblem(sm, g, h, gd; nout = 1)
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
```

```@example introduction
g(sol, p) = g(sol, p, 3)
exprob = ExpectationProblem(sm, g, h, gd; nout = 1)
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
```
Expand All @@ -269,7 +269,7 @@ function g(sol, p, counter)
end
counter = [0]
g(sol, p) = g(sol, p, counter)
exprob = ExpectationProblem(sm, g, h, gd; nout = 3)
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
```
Expand Down Expand Up @@ -305,7 +305,7 @@ function g(sol, p)
x = sol(4.0)[1]
[x, x^2]
end
exprob = ExpectationProblem(sm, g, h, gd; nout = 2)
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
mean_g = sol.u[1]
Expand All @@ -327,7 +327,7 @@ saveat = tspan[1]:0.5:tspan[2]
g(sol, p) = [sol[1, :]; sol[1, :] .^ 2]
prob = ODEProblem(f, u0, tspan, p, saveat = saveat)
sm = SystemMap(prob, Tsit5())
exprob = ExpectationProblem(sm, g, h, gd; nout = length(saveat) * 2)
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u

Expand All @@ -350,7 +350,7 @@ function g(sol, p)
x = sol(4.0)[1]
[x, x^2, x^3]
end
exprob = ExpectationProblem(sm, g, h, gd; nout = 3)
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman())
sol.u
mean_g = sol.u[1]
Expand All @@ -367,7 +367,7 @@ It is also possible to solve the various simulations in parallel by using the `b
The default quadrature algorithm to solve `ExpectationProblem` does not support batch-mode evaluation. So, we first load dependencies for additional quadrature algorithms

```@example introduction
using IntegralsCuba
using Cuba
```

We then solve our expectation as before, using a `batch=10` multi-thread parallelization via `EnsembleThreads()` of Cuba's SUAVE algorithm. We also introduce additional uncertainty in the model parameter.
Expand All @@ -379,7 +379,7 @@ gd = GenericDistribution(u0_dist, p_dist)
g(sol, p) = sol(6.0)[1]
h(x, u, p) = [x[1]], [x[2]]
sm = SystemMap(prob, Tsit5(), EnsembleThreads())
exprob = ExpectationProblem(sm, g, h, gd; nout = 1)
exprob = ExpectationProblem(sm, g, h, gd)
# batchmode = EnsembleThreads() #where to pass this?
sol = solve(exprob, Koopman(), batch = 10, quadalg = CubaSUAVE())
sol.u
Expand All @@ -392,8 +392,8 @@ Now, let's compare the performance of the batch and non-batch modes
```

```@example introduction
solve(exprob, Koopman(), batch = 0, quadalg = CubaSUAVE())
@time solve(exprob, Koopman(), batch = 0, quadalg = CubaSUAVE())
solve(exprob, Koopman(), quadalg = CubaSUAVE())
@time solve(exprob, Koopman(), quadalg = CubaSUAVE())
```

It is also possible to parallelize across the GPU. However, one must be careful of the limitations of ensemble solutions with the GPU. Please refer to [DiffEqGPU.jl](https://github.com/SciML/DiffEqGPU.jl) for details.
Expand Down Expand Up @@ -428,7 +428,7 @@ g(sol, p) = sol(6.0f0)[1]
h(x, u, p) = [x[1]], [x[2]]
prob = ODEProblem(f, u0, tspan, p)
sm = SystemMap(prob, Tsit5(), EnsembleCPUArray())
exprob = ExpectationProblem(sm, g, h, gd; nout = 1)
exprob = ExpectationProblem(sm, g, h, gd)
sol = solve(exprob, Koopman(), batch = 10, quadalg = CubaSUAVE())
sol.u
```
Expand Down
8 changes: 4 additions & 4 deletions docs/src/tutorials/optimization_under_uncertainty.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ using SciMLExpectations
gd = GenericDistribution(cor_dist)
h(x, u, p) = u, [p[1]; x[1]]
sm = SystemMap(prob, Tsit5(), callback = cbs)
exprob = ExpectationProblem(sm, obs, h, gd; nout = 1)
exprob = ExpectationProblem(sm, obs, h, gd)
sol = solve(exprob, Koopman(), ireltol = 1e-5)
sol.u
```
Expand All @@ -121,7 +121,7 @@ make_u0(θ) = [θ[1], θ[2], θ[3], 0.0]
function 𝔼_loss(θ, pars)
prob = ODEProblem(ball!, make_u0(θ), tspan, p)
sm = SystemMap(prob, Tsit5(), callback = cbs)
exprob = ExpectationProblem(sm, obs, h, gd; nout = 1)
exprob = ExpectationProblem(sm, obs, h, gd)
sol = solve(exprob, Koopman(), ireltol = 1e-5)
sol.u
end
Expand Down Expand Up @@ -228,7 +228,7 @@ Using the previously computed optimal initial conditions, let's compute the prob

```@example control
sm = SystemMap(remake(prob, u0 = make_u0(minx)), Tsit5(), callback = cbs)
exprob = ExpectationProblem(sm, constraint_obs, h, gd; nout = 1)
exprob = ExpectationProblem(sm, constraint_obs, h, gd)
sol = solve(exprob, Koopman(), ireltol = 1e-5)
sol.u
```
Expand All @@ -239,7 +239,7 @@ We then set up the constraint function for NLopt just as before.
function 𝔼_constraint(res, θ, pars)
prob = ODEProblem(ball!, make_u0(θ), tspan, p)
sm = SystemMap(prob, Tsit5(), callback = cbs)
exprob = ExpectationProblem(sm, constraint_obs, h, gd; nout = 1)
exprob = ExpectationProblem(sm, constraint_obs, h, gd)
sol = solve(exprob, Koopman(), ireltol = 1e-5)
res .= sol.u
end
Expand Down
Loading
Loading