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

EnsembleProblem support AbstractVector #1062

Closed
Beforerr opened this issue Oct 30, 2024 · 9 comments
Closed

EnsembleProblem support AbstractVector #1062

Beforerr opened this issue Oct 30, 2024 · 9 comments

Comments

@Beforerr
Copy link

Beforerr commented Oct 30, 2024

Is your feature request related to a problem? Please describe.

Rightnow EnsembleProblem(prob::AbstractSciMLProblem, u0s::Vector{Vector{T}}; kwargs...) only support Vector{Vector{T}} as u0s, but in some cases, we may want to use Vector{StaticVector} as u0s.

Describe the solution you’d like

So I think it would be better to support AbstractVector as u0s.

@ChrisRackauckas
Copy link
Member

I don't understand. EnsembleProblem allows for static array problems via prob_func. Can you share an example/MWE?

@Beforerr
Copy link
Author

Yes, using prob_func would works. But the EnsembleProblem(prob, u0s) interface would not work.

using OrdinaryDiffEq
using StaticArrays

function lorenz(u, p, t)
    du1 = 10.0 * (u[2] - u[1])
    du2 = u[1] * (28.0 - u[3]) - u[2]
    du3 = u[1] * u[2] - (8 / 3) * u[3]
    return [du1, du2, du3]
end

# working
u0s = [randn(3) for i in 1:100]
prob = ODEProblem(lorenz, u0s[1], (0.0, 1.0))
ensemble_prob = EnsembleProblem(prob, u0s)
sim = solve(ensemble_prob, Tsit5(), EnsembleThreads(), trajectories=length(u0s))

# not working
function slorenz(u, p, t)
    du1 = 10.0 * (u[2] - u[1])
    du2 = u[1] * (28.0 - u[3]) - u[2]
    du3 = u[1] * u[2] - (8 / 3) * u[3]
    return SA[du1, du2, du3]
end

su0s = [SVector{3}(u0) for u0 in u0s]
prob = ODEProblem(slorenz, u0s[1], (0.0, 1.0))
ensemble_prob = EnsembleProblem(prob, su0s)

@ChrisRackauckas
Copy link
Member

What interface? share the docs link?

@Beforerr
Copy link
Author

@ChrisRackauckas
Copy link
Member

The u0s thing isn't documented and is deprecated before it ever got documented though?

@Beforerr
Copy link
Author

Thanks for clarification!

@ChrisRackauckas
Copy link
Member

Okay so this wasn't pulled from any documentation? If so, then this is at least a completion to the issue since there hasn't been an intent to finish it. If it's just from reading the code, note that this interface is not planned to be finished, it's planned to be removed since there's some issues with it and it does not save much over just using the prob_func interface.

@ChrisRackauckas
Copy link
Member

But if this is documented anywhere, please please let me know, that's not intended.

@Beforerr
Copy link
Author

Thanks. I do not think it is documented anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants