Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ makedocs(sitename = "SciMLBase.jl",
format = Documenter.HTML(assets = ["assets/favicon.ico"],
canonical = "https://docs.sciml.ai/SciMLBase/stable"),
linkcheck_ignore = [
"https://www.sciencedirect.com/science/article/abs/pii/S0045782523007156"
"https://www.sciencedirect.com/science/article/abs/pii/S0045782523007156"
],
pages = pages)

Expand Down
2 changes: 1 addition & 1 deletion docs/src/interfaces/Ensembles.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ compute covariance matrices similarly:

```@example ensemble4
timeseries_steps_meancov(sim) # Use the time steps, assume fixed dt
timeseries_point_meancov(sim, 0:(1 // 2^(3)):1, 0:(1 // 2^(3)):1) # Use time points, interpolate
timeseries_point_meancov(sim, 0:(1 // 2 ^ (3)):1, 0:(1 // 2 ^ (3)):1) # Use time points, interpolate
```

For general analysis, we can build a `EnsembleSummary` type.
Expand Down
8 changes: 5 additions & 3 deletions ext/SciMLBaseChainRulesCoreExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ function ChainRulesCore.rrule(
j::Integer)
function ODESolution_getindex_pullback(Δ)
i = symbolic_type(sym) != NotSymbolic() ? variable_index(VA, sym) : sym
du, dprob = if i === nothing
du,
dprob = if i === nothing
getter = getobserved(VA)
grz = rrule_via_ad(config, getter, sym, VA.u[j], VA.prob.p, VA.t[j])[2](Δ)
du = [k == j ? grz[3] : zero(VA.u[1]) for k in 1:length(VA.u)]
Expand Down Expand Up @@ -83,7 +84,8 @@ function ChainRulesCore.rrule(
(NoTangent(), ȳ, ntuple(_ -> NoTangent(), length(args))...)
end

ODESolution{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16}(u, args...),
ODESolution{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16}(
u, args...),
ODESolutionAdjoint
end

Expand All @@ -99,7 +101,7 @@ function ChainRulesCore.rrule(
end

RODESolution{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
T11, T12, T13, T14}(u, args...),
T11, T12, T13, T14}(u, args...),
RODESolutionAdjoint
end

Expand Down
3 changes: 2 additions & 1 deletion ext/SciMLBaseMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ function Makie.convert_arguments(PT::Type{<:Plot},
@assert tscale isa Symbol "`tscale` if passed in to `Makie.plot` must be a Symbol, got a $(typeof(tscale))"

# Convert the solution to arrays - this is the hard part!
plot_vecs, labels = SciMLBase.diffeq_to_arrays(sol, plot_analytic, denseplot,
plot_vecs,
labels = SciMLBase.diffeq_to_arrays(sol, plot_analytic, denseplot,
plotdensity, tspan, vars, tscale, plotat)

# We must convert from plot Type to symbol here, for plotspec use
Expand Down
13 changes: 8 additions & 5 deletions src/SciMLBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ abstract type AbstractNonlinearProblem{uType, isinplace} <: AbstractDEProblem en
abstract type AbstractIntervalNonlinearProblem{uType, isinplace} <:
AbstractNonlinearProblem{uType,
isinplace} end
const AbstractSteadyStateProblem{uType, isinplace} = AbstractNonlinearProblem{uType,
const AbstractSteadyStateProblem{
uType, isinplace} = AbstractNonlinearProblem{uType,
isinplace}

"""
Expand Down Expand Up @@ -373,7 +374,6 @@ abstract type AbstractDiscretization <: AbstractSciMLAlgorithm end
# Discretization metadata
"""
$(TYPEDEF)

"""
abstract type AbstractDiscretizationMetadata{hasTime} end

Expand Down Expand Up @@ -566,7 +566,10 @@ abstract type AbstractPDENoTimeSolution{T, N, S, D} <:
"""
$(TYPEDEF)
"""
const AbstractPDESolution{T, N, S, D} = Union{AbstractPDETimeSeriesSolution{T, N, S, D},
const AbstractPDESolution{T,
N,
S,
D} = Union{AbstractPDETimeSeriesSolution{T, N, S, D},
AbstractPDENoTimeSolution{T, N, S, D}}

"""
Expand Down Expand Up @@ -628,8 +631,8 @@ abstract type ADOriginator end
"""
$(TYPEDEF)

Used to specify which variables can be aliased in a solve.
Every concrete AbstractAliasSpecifier should have at least the fields `alias_p` and `alias_f`.
Used to specify which variables can be aliased in a solve.
Every concrete AbstractAliasSpecifier should have at least the fields `alias_p` and `alias_f`.
"""
abstract type AbstractAliasSpecifier end

Expand Down
19 changes: 9 additions & 10 deletions src/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,15 @@ is constructed by passing the constructor `ContinuousCallback`, `DiscreteCallbac
You can pass as many callbacks as you like. When the solvers encounter multiple
callbacks, the following rules apply:

* `ContinuousCallback`s and `VectorContinuousCallback`s are applied before `DiscreteCallback`s. (This is because
they often implement event-finding that will backtrack the timestep to smaller
than `dt`).
* For `ContinuousCallback`s and `VectorContinuousCallback`s, the event times are found by rootfinding and only
the first `ContinuousCallback` or `VectorContinuousCallback` affect is applied.
* The `DiscreteCallback`s are then applied in order. Note that the ordering only
matters for the conditions: if a previous callback modifies `u` in such a way
that the next callback no longer evaluates condition to `true`, its `affect`
will not be applied.

- `ContinuousCallback`s and `VectorContinuousCallback`s are applied before `DiscreteCallback`s. (This is because
they often implement event-finding that will backtrack the timestep to smaller
than `dt`).
- For `ContinuousCallback`s and `VectorContinuousCallback`s, the event times are found by rootfinding and only
the first `ContinuousCallback` or `VectorContinuousCallback` affect is applied.
- The `DiscreteCallback`s are then applied in order. Note that the ordering only
matters for the conditions: if a previous callback modifies `u` in such a way
that the next callback no longer evaluates condition to `true`, its `affect`
will not be applied.
"""
struct CallbackSet{T1 <: Tuple, T2 <: Tuple} <: DECallback
continuous_callbacks::T1
Expand Down
6 changes: 4 additions & 2 deletions src/ensemble/basic_ensemble_solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ tighten_container_eltype(u) = u
function __solve(prob::EnsembleProblem{<:AbstractVector{<:AbstractSciMLProblem}},
alg::Union{AbstractDEAlgorithm, Nothing},
ensemblealg::BasicEnsembleAlgorithm; kwargs...)
Base.depwarn("This dispatch is deprecated for the standard ensemble syntax. See the Parallel
Ensembles Simulations Interface page for more details", :EnsembleProblemSolve)
Base.depwarn(
"This dispatch is deprecated for the standard ensemble syntax. See the Parallel
Ensembles Simulations Interface page for more details",
:EnsembleProblemSolve)
invoke(__solve, Tuple{AbstractEnsembleProblem, typeof(alg), typeof(ensemblealg)},
prob, alg, ensemblealg; trajectories = length(prob.prob), kwargs...)
end
Expand Down
33 changes: 19 additions & 14 deletions src/ensemble/ensemble_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Defines a structure to manage an ensemble (batch) of problems.
Each field controls how the ensemble behaves during simulation.

## Arguments

- `prob`: The original base problem to replicate or modify.
- `prob_func`: A function that defines how to generate each subproblem.
- `output_func`: A function to post-process each individual simulation result.
Expand Down Expand Up @@ -144,11 +145,14 @@ $(TYPEDEF)
Constructor for deprecated usage where a vector of problems is passed directly.

!!! warning

This constructor is deprecated. Use the standard ensemble syntax with `prob_func` instead.
"""
function EnsembleProblem(prob::AbstractVector{<:AbstractSciMLProblem}; kwargs...)
Base.depwarn("This dispatch is deprecated for the standard ensemble syntax. See the Parallel \
Ensembles Simulations Interface page for more details", :EnsembleProblem)
Base.depwarn(
"This dispatch is deprecated for the standard ensemble syntax. See the Parallel \
Ensembles Simulations Interface page for more details",
:EnsembleProblem)
invoke(EnsembleProblem,
Tuple{Any},
prob;
Expand All @@ -163,12 +167,12 @@ Main constructor for `EnsembleProblem`.

## Keyword Arguments

- `prob`: The base problem.
- `prob_func`: Function to modify the base problem per trajectory.
- `output_func`: Function to extract output from a solution.
- `reduction`: Function to aggregate results.
- `u_init`: Initial value for aggregation.
- `safetycopy`: Whether to deepcopy the problem before modifying.
- `prob`: The base problem.
- `prob_func`: Function to modify the base problem per trajectory.
- `output_func`: Function to extract output from a solution.
- `reduction`: Function to aggregate results.
- `u_init`: Initial value for aggregation.
- `safetycopy`: Whether to deepcopy the problem before modifying.
"""
function EnsembleProblem(prob;
prob_func = DEFAULT_PROB_FUNC,
Expand Down Expand Up @@ -203,12 +207,15 @@ $(TYPEDEF)
Constructor that is used for NOnlinearProblem.

!!! warning

This dispatch is deprecated. See the Parallel Ensembles Simulations Interface page.
"""
function SciMLBase.EnsembleProblem(
prob::AbstractSciMLProblem, u0s::Vector{Vector{T}}; kwargs...) where {T}
Base.depwarn("This dispatch is deprecated for the standard ensemble syntax. See the Parallel \
Ensembles Simulations Interface page for more details", :EnsembleProblem)
Base.depwarn(
"This dispatch is deprecated for the standard ensemble syntax. See the Parallel \
Ensembles Simulations Interface page for more details",
:EnsembleProblem)
prob_func = (prob, i, repeat = nothing) -> remake(prob, u0 = u0s[i])
return SciMLBase.EnsembleProblem(prob; prob_func, kwargs...)
end
Expand All @@ -220,8 +227,8 @@ Defines a weighted version of an `EnsembleProblem`, where different simulations

## Arguments

- `ensembleprob`: The base ensemble problem.
- `weights`: A vector of weights corresponding to each simulation.
- `ensembleprob`: The base ensemble problem.
- `weights`: A vector of weights corresponding to each simulation.
"""
struct WeightedEnsembleProblem{T1 <: AbstractEnsembleProblem, T2 <: AbstractVector} <:
AbstractEnsembleProblem
Expand Down Expand Up @@ -251,7 +258,6 @@ end
$(TYPEDEF)

Constructor for `WeightedEnsembleProblem`. Ensures weights sum to 1 and matches problem count.

"""
function WeightedEnsembleProblem(args...; weights, kwargs...)
# TODO: allow skipping checks?
Expand All @@ -260,4 +266,3 @@ function WeightedEnsembleProblem(args...; weights, kwargs...)
@assert length(ep.prob) == length(weights)
WeightedEnsembleProblem(ep, weights)
end

20 changes: 11 additions & 9 deletions src/initialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ the `u0` and `p` as-is, and is always successful if it returns. Valid only for
`AbstractDEProblem` and `AbstractDAEProblem`. Requires a `DEIntegrator` as its second argument.

Keyword arguments:
- `abstol`: The absolute value below which the norm of the residual of algebraic equations
should lie. The norm function used is `integrator.opts.internalnorm` if present, and
`LinearAlgebra.norm` if not.

- `abstol`: The absolute value below which the norm of the residual of algebraic equations
should lie. The norm function used is `integrator.opts.internalnorm` if present, and
`LinearAlgebra.norm` if not.
"""
function get_initial_values(
prob::AbstractDEProblem, integrator::DEIntegrator, f, alg::CheckInit,
Expand Down Expand Up @@ -219,12 +220,13 @@ If the field is absent or the value is `nothing`, return `u0` and `p` successful
The success value returned depends on the success of the nonlinear solve.

Keyword arguments:
- `nlsolve_alg`: The NonlinearSolve.jl algorithm to use. If not provided, this function will
throw an error.
- `abstol`, `reltol`: The `abstol` (`reltol`) to use for the nonlinear solve. The value
provided to the `OverrideInit` constructor takes priority over this keyword argument.
If the former is `nothing`, this keyword argument will be used. If it is also not provided,
an error will be thrown.

- `nlsolve_alg`: The NonlinearSolve.jl algorithm to use. If not provided, this function will
throw an error.
- `abstol`, `reltol`: The `abstol` (`reltol`) to use for the nonlinear solve. The value
provided to the `OverrideInit` constructor takes priority over this keyword argument.
If the former is `nothing`, this keyword argument will be used. If it is also not provided,
an error will be thrown.

All additional keyword arguments are forwarded to `solve`.

Expand Down
6 changes: 4 additions & 2 deletions src/remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,8 @@ function updated_u0_p(
return (u0 === missing ? state_values(prob) : u0),
(p === missing ? parameter_values(prob) : p)
end
newu0, newp = _updated_u0_p_internal(
newu0,
newp = _updated_u0_p_internal(
prob, u0, p, t0; interpret_symbolicmap, use_defaults)
return late_binding_update_u0_p(prob, u0, p, t0, newu0, newp)
end
Expand Down Expand Up @@ -1164,7 +1165,8 @@ function maybe_eager_initialize_problem(prob::AbstractSciMLProblem, initializati
end
if initialization_data !== nothing && !lazy_initialization &&
(!is_time_dependent(prob) || current_time(prob) !== nothing)
u0, p, _ = get_initial_values(
u0, p,
_ = get_initial_values(
prob, prob, prob.f, OverrideInit(), Val(isinplace(prob)))
if u0 !== nothing && eltype(u0) == Any && isempty(u0)
u0 = nothing
Expand Down
Loading
Loading