### Algorithm-Specific Arguments Example Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md Illustrates how algorithm-specific keyword arguments are handled via the algorithm constructor, not the solve function. For example, 'autodiff' for Rodas5. ```julia Rodas5(autodiff=true) ``` -------------------------------- ### Incorrect init Method Dispatch Example Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Init_Solve.md Illustrates an example of an `init` method dispatch that should be avoided to prevent method ambiguity. The first argument must be dispatched on the package-defined type. ```julia init(::AbstractVector, ::AlgorithmType) ``` -------------------------------- ### Setup for Distributed Ensemble Simulation Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Initializes distributed processes and makes OrdinaryDiffEq available to all workers. This is required for distributed ensemble simulations. ```julia using Distributed using OrdinaryDiffEq using Plots addprocs() @everywhere using OrdinaryDiffEq ``` -------------------------------- ### Execute Ensemble Simulation with Threads Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Example of solving an ensemble problem using the `EnsembleThreads` algorithm, specifying the number of trajectories to simulate. ```julia solve(ensembleprob, alg, EnsembleThreads(); trajectories = 1000) ``` -------------------------------- ### Example of ODEAliases for aliasing u0 Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Common_Keywords.md Demonstrates how to use ODEAliases to alias the u0 array in an ODE solver. This can optimize memory usage. ```julia solve(prob,alias = ODEAliases(alias_u0 = true)) ``` -------------------------------- ### Get Time Step Data Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Retrieves data summarized by time steps, assuming consistent time points across simulations. ```julia SciMLBase.EnsembleAnalysis.get_timestep ``` -------------------------------- ### Interpolate Solution at Time t Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Solutions.md Call the solution object with a time `t` to get all state variables. You can also specify specific components by index or symbol, or request derivatives. ```julia sol(t) # all state variables at time t sol(t; idxs = 1) # single component sol(t; idxs = [:x, :y]) # symbolic variables sol(t, Val{1}) # first derivative ``` -------------------------------- ### Get Time Point Data Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Retrieves data summarized by time points, requiring interpolation if time points are not consistent. ```julia SciMLBase.EnsembleAnalysis.get_timepoint ``` -------------------------------- ### Check Forward Differentiation Chunk Size Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md Use this trait to get the forward differentiation chunk size used by the algorithm. ```julia SciMLBase.forwarddiff_chunksize ``` -------------------------------- ### Create SDEProblem Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Initializes the SDEProblem with drift, noise functions, initial conditions, time span, and parameters. ```julia using StochasticDiffEq p = [1.5, 1.0, 0.1, 0.1] prob = SDEProblem(f, g, [1.0, 1.0], (0.0, 10.0), p) ``` -------------------------------- ### Using `remake` with Symbolic Maps Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Problems.md Demonstrates how to use `remake` with symbolic maps for initial conditions (`u0`) or parameters (`p`). Values can be numeric or expressions, and maps can be complete or partial. The `use_defaults` keyword argument controls the preference for system defaults. ```julia remake(prob; p = [:b => 2.0]) remake(prob; p = [:b => 2.0], use_defaults = true) remake(prob; p = [:b => 2.0, :a => 3.0]) ``` -------------------------------- ### ODEFunction with In-place and Specialization Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/SciMLFunctions.md Demonstrates the basic construction of an ODEFunction, specifying whether it operates in-place and its specialization level. ```julia ODEFunction(f) ODEFunction{iip}(f) ``` ```julia ODEFunction{iip, specialization}(f) ``` -------------------------------- ### Display System and Julia Version Information Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/index.md Provides detailed information about the machine and Julia version used to build the documentation. This helps in reproducing the build environment. ```julia using InteractiveUtils # hide versioninfo() # hide ``` -------------------------------- ### ODEProblem Constructor with Specialization Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Problems.md Shows how to specify both the 'in-place' (iip) choice and the specialization level for the ODEProblem constructor. Specialization controls the amount of compilation for model functions. ```julia ODEProblem{iip, specialization}(f, u0, tspan, p) ``` -------------------------------- ### Defining Independent Variables and Domains Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/PDE.md Illustrates how to specify independent variables and their corresponding domains using interval notation or predefined domain types. ```julia t ∈ (0.0, 1.0) (t, x) ∈ UnitDisk() [v, w, x, y, z] ∈ VectorUnitBall(5) ``` -------------------------------- ### Import Ensemble Analysis Module Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Import the EnsembleAnalysis module to use its functionalities. This is the first step before utilizing any analysis tools. ```julia using SciMLBase.EnsembleAnalysis ``` -------------------------------- ### Create EnsembleSummary Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Builds an EnsembleSummary object to summarize simulation results at each time step. ```julia summ = EnsembleSummary(sim) ``` -------------------------------- ### GPU Ensemble Simulation with Custom Kernel Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Use `EnsembleGPUKernel` for highly optimized GPU ensemble simulations by building a custom GPU kernel. This offers lower overhead but has compatibility limitations. ```julia EnsembleGPUKernel() ``` -------------------------------- ### Solve Ensemble Problem and Plot Trajectories Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Sets up and solves an EnsembleProblem, then plots the resulting trajectories in phase space. Requires StochasticDiffEq and Plots. ```julia ensemble_prob = EnsembleProblem(prob, prob_func = prob_func) sim = solve(ensemble_prob, SRIW1(), trajectories = 10) using Plots; plot(sim, linealpha = 0.6, color = :blue, idxs = (0, 1), title = "Phase Space Plot"); plot!(sim, linealpha = 0.6, color = :red, idxs = (0, 2), title = "Phase Space Plot") ``` -------------------------------- ### Interface for init and solve! Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Init_Solve.md Defines the expected interface for the `init` and `solve!` functions, specifying their input and output types. ```julia init(::ProblemType, args...; kwargs...)::IteratorType solve!(::IteratorType)::SolutionType ``` -------------------------------- ### Create and Solve EnsembleProblem (Distributed) Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Creates an EnsembleProblem using the base ODE problem and the `prob_func`, then solves it using distributed parallelism with 10 trajectories. ```julia ensemble_prob = EnsembleProblem(prob, prob_func = prob_func) sim = solve(ensemble_prob, Tsit5(), EnsembleDistributed(), trajectories = 10) ``` -------------------------------- ### GPU Ensemble Simulation with OneAPI Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Utilize `EnsembleGPUArray` for GPU-accelerated ensemble simulations with Intel GPUs using oneAPI.jl. ```julia oneAPI.oneAPIBackend() ``` -------------------------------- ### GPU Ensemble Simulation with Metal Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Utilize `EnsembleGPUArray` for GPU-accelerated ensemble simulations with Apple Silicon GPUs using Metal.jl. ```julia Metal.MetalBackend() ``` -------------------------------- ### Display Full Manifest Status Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/index.md Shows the status of all dependencies, including indirect ones, as recorded in the manifest file. This provides a complete picture of the project's dependency tree. ```julia using Pkg # hide Pkg.status(; mode = PKGMODE_MANIFEST) # hide ``` -------------------------------- ### ODEProblem Constructor with In-place Choice Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Problems.md Demonstrates how to specify the 'in-place' (iip) choice for the ODEProblem constructor. This boolean indicates if the function mutates the first argument. ```julia ODEProblem(f, u0, tspan, p) ODEProblem{iip}(f, u0, tspan, p) ``` -------------------------------- ### Compute Mean and Variance Time Series (Steps) Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Generates time series for the mean and variance at each fixed timestep of the simulation. ```julia m_series, v_series = timeseries_steps_meanvar(sim) ``` -------------------------------- ### Display Return Code Enum Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Solutions.md Displays the documentation for the `SciMLBase.ReturnCode` enumeration, which defines the possible states of a solution's return code. ```julia ```@docs SciMLBase.ReturnCode ``` ``` -------------------------------- ### Default error for missing sensitivity rules Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Differentiation.md Provides a default implementation for `_concrete_solve_forward` that throws an error, indicating that sensitivity rules have not been added. This typically means `using DiffEqSensitivity` is missing. ```julia function _concrete_solve_forward(args...; kwargs...) error("No sensitivity rules exist. Check that you added `using DiffEqSensitivity`") end ``` -------------------------------- ### Available Ensemble Algorithms Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Lists the available ensemble algorithm types for controlling how multiple trajectories are handled during parallel simulations. ```julia EnsembleSerial ``` ```julia EnsembleThreads ``` ```julia EnsembleDistributed ``` ```julia EnsembleSplitThreads ``` -------------------------------- ### Create EnsembleSummary with Specific Time Points Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Builds an EnsembleSummary object to summarize simulation results at specified time points using interpolation. ```julia summ = EnsembleSummary(sim, 0.0:0.1:1.0) ``` -------------------------------- ### Display Package Status Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/index.md Shows the status of all direct dependencies for the current project. This is useful for understanding the immediate dependencies of a package. ```julia using Pkg # hide Pkg.status() # hide ``` -------------------------------- ### Solve EnsembleProblem with Custom Reduction and Output Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Solves an EnsembleProblem using Tsit5, with a custom probability function, output function, and reduction function. The simulation halts when the standard error of the mean is below a tolerance. ```julia prob2 = EnsembleProblem(prob, prob_func = prob_func, output_func = output_func, reduction = reduction, u_init = Vector{Float64}()) sim = solve(prob2, Tsit5(), trajectories = 10000, batch_size = 20) ``` -------------------------------- ### Define an Ensemble Problem Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Use the `EnsembleProblem` constructor to define a template problem for ensemble simulations. ```julia EnsembleProblem ``` -------------------------------- ### Set Specialization Level Preference Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Problems.md Demonstrates how to set the default specialization level for SciMLBase using the Preferences package. This is useful for controlling how algorithms specialize to problem structures. ```julia using Preferences, UUIDs set_preferences!( UUID("0bca4576-84f4-4d90-8ffe-ffa030f20462"), "SpecializationLevel" => "FullSpecialize") ``` -------------------------------- ### Abstract Quadrature Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for quadrature (numerical integration) algorithms. ```julia SciMLBase.AbstractQuadratureAlgorithm ``` -------------------------------- ### ODEFunction with Explicit Jacobian Prototype Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/SciMLFunctions.md Creates an inplace ODEFunction and explicitly defines its Jacobian and the prototype for the Jacobian matrix, here a Diagonal matrix. ```julia using LinearAlgebra f = (du, u, p, t) -> du .= t .* u jac = (J, u, p, t) -> (J[1, 1] = t; J[2, 2] = t; J) jp = Diagonal(zeros(2)) fun = ODEFunction(f; jac = jac, jac_prototype = jp) ``` -------------------------------- ### Define SDEProblem Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Defines the functions for the drift and diffusion coefficients and initializes an SDEProblem for a 4x2 system of linear stochastic differential equations. ```julia function f(du, u, p, t) for i in 1:length(u) du[i] = 1.01 * u[i] end end function σ(du, u, p, t) for i in 1:length(u) du[i] = 0.87 * u[i] end end using StochasticDiffEq prob = SDEProblem(f, σ, ones(4, 2) / 2, (0.0, 1.0)) ``` -------------------------------- ### Abstract Steady State Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for steady-state problem algorithms. ```julia SciMLBase.AbstractSteadyStateAlgorithm ``` -------------------------------- ### Access Multi-dimensional Solution Component at Timestep (Higher Dimensions) Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Solutions.md Access a specific component defined by indices 'i' and 'k' of a system at timestep 'j'. This extends the indexing for systems with more than two dimensions. ```julia sol[i, k, j] ``` -------------------------------- ### Default error for missing adjoint rules Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Differentiation.md Provides a default implementation for `_concrete_solve_adjoint` that throws an error, indicating that adjoint rules have not been added. This typically means `using DiffEqSensitivity` is missing. ```julia function _concrete_solve_adjoint(args...; kwargs...) error("No adjoint rules exist. Check that you added `using DiffEqSensitivity`") end ``` -------------------------------- ### GPU Ensemble Simulation with CUDA Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Utilize `EnsembleGPUArray` for GPU-accelerated ensemble simulations with NVIDIA GPUs using CUDA.jl. ```julia EnsembleGPUArray() ``` -------------------------------- ### GPU Ensemble Simulation with ROCm Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Utilize `EnsembleGPUArray` for GPU-accelerated ensemble simulations with AMD GPUs using AMDGPU.jl. ```julia AMDGPU.ROCBackend() ``` -------------------------------- ### Define ODEProblem and Custom Probability Function for Ensembles Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Sets up a linear ODE problem and a probability function that randomizes the initial condition for each trajectory in an ensemble simulation. Requires OrdinaryDiffEq and SciMLBase. ```julia using OrdinaryDiffEq using SciMLBase # Linear ODE which starts at 0.5 and solves from t=0.0 to t=1.0 prob = ODEProblem((u, p, t) -> 1.01u, 0.5, (0.0, 1.0)) function prob_func(prob, ctx) remake(prob, u0 = rand() * prob.u0) end ``` -------------------------------- ### Access Solution Value at Timestep Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Solutions.md Access the solution value at a specific timestep 'j'. This is useful for retrieving the state of the system at a particular point in time. ```julia sol[j] ``` -------------------------------- ### Check Forward Differentiation Model for Time Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md Use this trait to check the forward differentiation model specifically for time derivatives. ```julia SciMLBase.forwarddiffs_model_time ``` -------------------------------- ### Default solve Function Definition Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Init_Solve.md This is the default definition for the `solve` function, which chains `init` and `solve!`. ```julia solve(args...; kwargs...) = solve!(init(args...; kwargs...)) ``` -------------------------------- ### Display Return Code Traits Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Solutions.md Shows the documentation for `SciMLBase.successful_retcode`, a trait used to determine if a return code signifies successful completion. ```julia ```@docs SciMLBase.successful_retcode ``` ``` -------------------------------- ### Generate Ensemble Summary Plot Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Creates an EnsembleSummary object from simulation results and plots it to visualize mean and quantile bounds over time. The default quantile bounds are [0.05, 0.95]. ```julia summ = EnsembleSummary(sim, 0:0.1:10) plot(summ, fillalpha = 0.5) ``` -------------------------------- ### Check Forward Differentiation Model Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md Use this trait to check the forward differentiation model used by the algorithm. ```julia SciMLBase.forwarddiffs_model ``` -------------------------------- ### Define solve with sensealg keyword argument Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Differentiation.md This function defines the top-level `solve` interface, handling the `sensealg` keyword argument and passing it to `solve_up`. ```julia function solve(prob::AbstractDEProblem, args...; sensealg = nothing, u0 = nothing, p = nothing, kwargs...) u0 = u0 !== nothing ? u0 : prob.u0 p = p !== nothing ? p : prob.p if sensealg === nothing && haskey(prob.kwargs, :sensealg) sensealg = prob.kwargs[:sensealg] end solve_up(prob, sensealg, u0, p, args...; kwargs...) end ``` -------------------------------- ### Abstract Interval Nonlinear Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for interval nonlinear problem algorithms. ```julia SciMLBase.AbstractIntervalNonlinearAlgorithm ``` -------------------------------- ### Define Base ODE Problem Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Defines a linear ODE problem with a fixed initial condition and time span. This serves as the base for ensemble simulations. ```julia # Linear ODE which starts at 0.5 and solves from t=0.0 to t=1.0 prob = ODEProblem((u, p, t) -> 1.01u, 0.5, (0.0, 1.0)) ``` -------------------------------- ### Access Multi-dimensional Solution Component at Timestep Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Solutions.md Access a specific component 'i' of a multi-dimensional system at a given timestep 'j'. Julia's column-major ordering means components are accessed first, followed by time. ```julia sol[i, j] ``` -------------------------------- ### Define `prob_func` for Pre-Determined Initial Conditions Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Defines a function to set initial conditions for each trajectory based on a pre-defined array and the trajectory's unique ID (`ctx.sim_id`). ```julia initial_conditions = range(0, stop = 1, length = 100) function prob_func(prob, ctx) remake(prob, u0 = initial_conditions[ctx.sim_id]) end ``` -------------------------------- ### Abstract SDE Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for Stochastic Differential Equation algorithms. ```julia SciMLBase.AbstractSDEAlgorithm ``` -------------------------------- ### Check if Algorithm has Initialization Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md Use this trait to determine if the algorithm requires or supports an initialization step. ```julia SciMLBase.has_init ``` -------------------------------- ### Compute Mean and Covariance Time Series (Steps) Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Computes the mean and covariance matrices for each time step, assuming a fixed dt. ```julia timeseries_steps_meancov(sim) ``` -------------------------------- ### Single Time Statistics by Time Step Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Calculates single time statistics (mean, median, quantile, meanvar, meancov, meancor, weighted_meancov) for ensemble data summarized by time steps. ```julia SciMLBase.EnsembleAnalysis.timestep_mean SciMLBase.EnsembleAnalysis.timestep_median SciMLBase.EnsembleAnalysis.timestep_quantile SciMLBase.EnsembleAnalysis.timestep_meanvar SciMLBase.EnsembleAnalysis.timestep_meancov SciMLBase.EnsembleAnalysis.timestep_meancor SciMLBase.EnsembleAnalysis.timestep_weighted_meancov ``` -------------------------------- ### Abstract DDE Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for Delay Differential Equation algorithms. ```julia SciMLBase.AbstractDDEAlgorithm ``` -------------------------------- ### Time steps vs time points Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Functions to extract data either by time steps or by time points. Summarizing by time steps assumes uniform time intervals, while summarizing by time points requires interpolation. ```APIDOC ## Time steps vs time points ### Description Functions to extract data either by time steps or by time points. Summarizing by time steps assumes uniform time intervals, while summarizing by time points requires interpolation. ### Functions - `SciMLBase.EnsembleAnalysis.get_timestep` - `SciMLBase.EnsembleAnalysis.get_timepoint` - `SciMLBase.EnsembleAnalysis.componentwise_vectors_timestep` - `SciMLBase.EnsembleAnalysis.componentwise_vectors_timepoint` ``` -------------------------------- ### Abstract SciML Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for all SciML algorithms. ```julia SciMLBase.AbstractSciMLAlgorithm ``` -------------------------------- ### Compute Mean and Variance at Timestep Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Calculates the mean and variance of the ensemble solutions at a specific timestep (e.g., the 3rd timestep). ```julia using SciMLBase.EnsembleAnalysis m, v = timestep_meanvar(sim, 3) ``` -------------------------------- ### Abstract Optimization Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for optimization algorithms. ```julia SciMLBase.AbstractOptimizationAlgorithm ``` -------------------------------- ### Custom Reduction Function for Ensemble Convergence Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Implements a reduction function that appends batch results and checks for convergence based on the standard error of the mean. Requires Statistics. ```julia using Statistics function reduction(u, batch, I) u = append!(u, batch) finished = (var(u) / sqrt(last(I))) / mean(u) < 0.5 u, finished end ``` -------------------------------- ### Component-wise Vectors by Time Step Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Converts ensemble data into component-wise vectors based on time steps. ```julia SciMLBase.EnsembleAnalysis.componentwise_vectors_timestep ``` -------------------------------- ### Compute Mean and Variance at Timepoint Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Calculates the mean and variance of the ensemble solutions at a specific timepoint (e.g., t=0.5). ```julia m, v = timepoint_meanvar(sim, 0.5) ``` -------------------------------- ### Abstract Nonlinear Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for nonlinear problem algorithms. ```julia SciMLBase.AbstractNonlinearAlgorithm ``` -------------------------------- ### Display Specific Return Codes Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Solutions.md Lists and documents specific return codes available in `SciMLBase.ReturnCode`, such as `Success`, `Failure`, `MaxIters`, and `Unstable`. ```julia ```@docs SciMLBase.ReturnCode.Default ``` ``` ```julia ```@docs SciMLBase.ReturnCode.Success ``` ``` ```julia ```@docs SciMLBase.ReturnCode.Terminated ``` ``` ```julia ```@docs SciMLBase.ReturnCode.DtNaN ``` ``` ```julia ```@docs SciMLBase.ReturnCode.MaxIters ``` ``` ```julia ```@docs SciMLBase.ReturnCode.MaxNumSub ``` ``` ```julia ```@docs SciMLBase.ReturnCode.MaxTime ``` ``` ```julia ```@docs SciMLBase.ReturnCode.DtLessThanMin ``` ``` ```julia ```@docs SciMLBase.ReturnCode.Unstable ``` ``` ```julia ```@docs SciMLBase.ReturnCode.InitialFailure ``` ``` ```julia ```@docs SciMLBase.ReturnCode.ConvergenceFailure ``` ``` ```julia ```@docs SciMLBase.ReturnCode.Failure ``` ``` ```julia ```@docs SciMLBase.ReturnCode.Infeasible ``` ``` ```julia ```@docs SciMLBase.ReturnCode.ExactSolutionLeft ``` ``` ```julia ```@docs SciMLBase.ReturnCode.ExactSolutionRight ``` ``` ```julia ```@docs SciMLBase.ReturnCode.FloatingPointLimit ``` ``` ```julia ```@docs SciMLBase.ReturnCode.InternalLineSearchFailed ``` ``` ```julia ```@docs SciMLBase.ReturnCode.InternalLinearSolveFailed ``` ``` ```julia ```@docs SciMLBase.ReturnCode.APosterioriSafetyFailure ``` ``` ```julia ```@docs SciMLBase.ReturnCode.ShrinkThresholdExceeded ``` ``` ```julia ```@docs SciMLBase.ReturnCode.Stalled ``` ``` ```julia ```@docs SciMLBase.ReturnCode.StalledSuccess ``` ``` -------------------------------- ### Abstract DE Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for Differential Equation algorithms. ```julia SciMLBase.AbstractDEAlgorithm ``` -------------------------------- ### Plot Ensemble Simulation Results Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Plots the results of the ensemble simulation, showing multiple trajectories with different initial conditions. The `linealpha` parameter controls the transparency of the lines. ```julia plot(sim, linealpha = 0.4) ``` -------------------------------- ### Abstract SciMLProblems Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Problems.md Defines the core abstract types for various scientific machine learning problems, serving as base types for concrete problem implementations. ```APIDOC ## Abstract SciMLProblems ### Description These are abstract base types for various scientific machine learning problems. ### Types - `SciMLBase.AbstractSciMLProblem` - `SciMLBase.AbstractDEProblem` - `SciMLBase.AbstractLinearProblem` - `SciMLBase.AbstractNonlinearProblem` - `SciMLBase.AbstractIntegralProblem` - `SciMLBase.AbstractOptimizationProblem` - `SciMLBase.AbstractNoiseProblem` - `SciMLBase.AbstractODEProblem` - `SciMLBase.AbstractDiscreteProblem` - `SciMLBase.AbstractAnalyticalProblem` - `SciMLBase.AbstractRODEProblem` - `SciMLBase.AbstractSDEProblem` - `SciMLBase.AbstractDAEProblem` - `SciMLBase.AbstractDDEProblem` - `SciMLBase.AbstractConstantLagDDEProblem` - `SciMLBase.AbstractSecondOrderODEProblem` - `SciMLBase.AbstractBVProblem` - `SciMLBase.AbstractJumpProblem` - `SciMLBase.AbstractSDDEProblem` - `SciMLBase.AbstractConstantLagSDDEProblem` - `SciMLBase.AbstractPDEProblem` ``` -------------------------------- ### Abstract SDDE Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for Stochastic Delay Differential Equation algorithms. ```julia SciMLBase.AbstractSDDEAlgorithm ``` -------------------------------- ### Return DiffEqArray for Interpolation Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Solutions.md Providing an array of time points to the solution object returns a `DiffEqArray` which itself supports callable interpolation. ```julia sol([0.1, 0.5, 0.9]) # returns a DiffEqArray result = sol([0.0, 1.0]) # DiffEqArray with interp result(0.5) # interpolate the sub-result ``` -------------------------------- ### Plot EnsembleSummary (Mean of All Components) Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Plots the mean of every component over time from an EnsembleSummary object, without error bars. ```julia plot(summ; error_style = :none) ``` -------------------------------- ### Abstract ODE Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for Ordinary Differential Equation algorithms. ```julia SciMLBase.AbstractODEAlgorithm ``` -------------------------------- ### Full Timeseries Statistics by Time Step Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Analyzes the full timeseries of ensemble data summarized by time steps. Mean and meanvar return DiffEqArrays, while meancov and meancor return matrices of tuples. ```julia timeseries_steps_mean timeseries_steps_median timeseries_steps_quantile timeseries_steps_meanvar timeseries_steps_meancov timeseries_steps_meancor timeseries_steps_weighted_meancov ``` -------------------------------- ### Abstract RODE Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for Random Ordinary Differential Equation algorithms. ```julia SciMLBase.AbstractRODEAlgorithm ``` -------------------------------- ### Plot EnsembleSummary (Multiple Components with Errorbars) Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Plots the summary of an EnsembleSummary object, visualizing the 3rd and 5th components using error bars. ```julia plot(summ; idxs = (3, 5), error_style = :bars) ``` -------------------------------- ### Abstract SciML Functions Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/SciMLFunctions.md Defines the abstract base types for various types of SciML functions, serving as a common interface for different scientific modeling tasks. ```APIDOC ## Abstract SciML Functions ### Description Abstract base types for various SciML functions. ### Types - `SciMLBase.AbstractDiffEqFunction` - `SciMLBase.AbstractODEFunction` - `SciMLBase.AbstractSDEFunction` - `SciMLBase.AbstractDDEFunction` - `SciMLBase.AbstractDAEFunction` - `SciMLBase.AbstractRODEFunction` - `SciMLBase.AbstractDiscreteFunction` - `SciMLBase.AbstractSDDEFunction` - `SciMLBase.AbstractNonlinearFunction` ### Usage These types form the foundation for defining and dispatching on different types of differential equations and related mathematical problems within the SciML ecosystem. ``` -------------------------------- ### EnsembleSummary Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Represents a summary of an ensemble simulation, used for analysis. ```julia EnsembleSummary ``` -------------------------------- ### Solve EnsembleProblem Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Solves an EnsembleProblem for a given SDEProblem with fixed timesteps and a specified number of trajectories. ```julia prob2 = EnsembleProblem(prob) sim = solve(prob2, SRIW1(), dt = 1 // 2^(3), trajectories = 10, adaptive = false) ``` -------------------------------- ### Single Time Statistics by Time Point Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Calculates single time statistics (mean, median, quantile, meanvar, meancov, meancor, weighted_meancov) for ensemble data summarized by time points. ```julia SciMLBase.EnsembleAnalysis.timepoint_mean SciMLBase.EnsembleAnalysis.timepoint_median SciMLBase.EnsembleAnalysis.timepoint_quantile SciMLBase.EnsembleAnalysis.timepoint_meanvar SciMLBase.EnsembleAnalysis.timepoint_meancov SciMLBase.EnsembleAnalysis.timepoint_meancor SciMLBase.EnsembleAnalysis.timepoint_weighted_meancov ``` -------------------------------- ### ChainRules.jl rrule for solve_up Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Differentiation.md Defines the reverse rule (rrule) for `solve_up` using the ChainRules.jl interface, which is used for reverse mode automatic differentiation (adjoints). ```julia function ChainRulesCore.rrule(::typeof(solve_up), prob::SciMLBase.AbstractDEProblem, sensealg::Union{Nothing, AbstractSensitivityAlgorithm}, u0, p, args...; kwargs...) _solve_adjoint(prob, sensealg, u0, p, args...; kwargs...) end ``` -------------------------------- ### Check if Algorithm is Adaptive Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md Use this trait to determine if a SciML algorithm is adaptive (e.g., adjusts step size automatically). ```julia SciMLBase.isadaptive ``` -------------------------------- ### Solve Ensemble Problem with Multithreading Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Solves an ensemble of ODE problems using multithreading. This approach shares memory across threads and does not require the `@everywhere` macro. Ensure JULIA_NUM_THREADS is set externally. ```julia using OrdinaryDiffEq using SciMLBase prob = ODEProblem((u, p, t) -> 1.01u, 0.5, (0.0, 1.0)) function prob_func(prob, ctx) remake(prob, u0 = rand() * prob.u0) end ensemble_prob = EnsembleProblem(prob, prob_func = prob_func) sim = solve(ensemble_prob, Tsit5(), EnsembleThreads(), trajectories = 10) using Plots; plot(sim); ``` -------------------------------- ### Plot EnsembleSummary (Single Component) Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Plots the summary of an EnsembleSummary object, visualizing the 3rd component with ribbons. ```julia using Plots; plot(summ; idxs = 3); ``` -------------------------------- ### Single Time Statistics Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Provides functions for calculating summary statistics at single time steps or time points across an ensemble simulation. ```APIDOC ## Single Time Statistics ### Description Functions for calculating summary statistics at single time steps or time points across an ensemble simulation. ### Time Step Statistics - `SciMLBase.EnsembleAnalysis.timestep_mean` - `SciMLBase.EnsembleAnalysis.timestep_median` - `SciMLBase.EnsembleAnalysis.timestep_quantile` - `SciMLBase.EnsembleAnalysis.timestep_meanvar` - `SciMLBase.EnsembleAnalysis.timestep_meancov` - `SciMLBase.EnsembleAnalysis.timestep_meancor` - `SciMLBase.EnsembleAnalysis.timestep_weighted_meancov` ### Time Point Statistics - `SciMLBase.EnsembleAnalysis.timepoint_mean` - `SciMLBase.EnsembleAnalysis.timepoint_median` - `SciMLBase.EnsembleAnalysis.timepoint_quantile` - `SciMLBase.EnsembleAnalysis.timepoint_meanvar` - `SciMLBase.EnsembleAnalysis.timepoint_meancov` - `SciMLBase.EnsembleAnalysis.timepoint_meancor` - `SciMLBase.EnsembleAnalysis.timepoint_weighted_meancov` ``` -------------------------------- ### Compute Mean Time Series (Points) Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Generates a time series for the mean at specified time points, using interpolation if necessary. ```julia ts = 0:0.1:1 m_series = timeseries_point_mean(sim, ts) ``` -------------------------------- ### Abstract Second Order ODE Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for second-order Ordinary Differential Equation algorithms. ```julia SciMLBase.AbstractSecondOrderODEAlgorithm ``` -------------------------------- ### EnsembleSummary Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Represents a summary of an ensemble simulation, likely containing aggregated statistics or results. ```APIDOC ## EnsembleSummary ### Description Represents a summary of an ensemble simulation, likely containing aggregated statistics or results. ``` -------------------------------- ### Abstract DAE Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for Differential-Algebraic Equation algorithms. ```julia SciMLBase.AbstractDAEAlgorithm ``` -------------------------------- ### Abstract Linear Algorithm Type Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The base abstract type for linear problem algorithms. ```julia SciMLBase.AbstractLinearAlgorithm ``` -------------------------------- ### ChainRules.jl frule for solve_up Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Differentiation.md Defines the forward rule (frule) for `solve_up` using the ChainRules.jl interface, which is used for forward mode automatic differentiation. ```julia function ChainRulesCore.frule(::typeof(solve_up), prob, sensealg::Union{Nothing, AbstractSensitivityAlgorithm}, u0, p, args...; kwargs...) _solve_forward(prob, sensealg, u0, p, args...; kwargs...) end ``` -------------------------------- ### Full Timeseries Statistics Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Functions for analyzing the entire timeseries of an ensemble simulation, providing statistics like mean, median, variance, covariance, and correlation. ```APIDOC ## Full Timeseries Statistics ### Description Functions for analyzing the entire timeseries of an ensemble simulation, providing statistics like mean, median, variance, covariance, and correlation. The `mean` and `meanvar` versions return a `DiffEqArray` which can be directly plotted. The `meancov` and `meancor` return a matrix of tuples, where the tuples are the `(mean_t1,mean_t2,cov or cor)`. ### Time Step Statistics - `timeseries_steps_mean` - `timeseries_steps_median` - `timeseries_steps_quantile` - `timeseries_steps_meanvar` - `timeseries_steps_meancov` - `timeseries_steps_meancor` - `timeseries_steps_weighted_meancov` ### Time Point Statistics - `SciMLBase.EnsembleAnalysis.timeseries_point_mean` - `SciMLBase.EnsembleAnalysis.timeseries_point_median` - `SciMLBase.EnsembleAnalysis.timeseries_point_quantile` - `SciMLBase.EnsembleAnalysis.timeseries_point_meanvar` - `SciMLBase.EnsembleAnalysis.timeseries_point_meancov` - `SciMLBase.EnsembleAnalysis.timeseries_point_meancor` - `SciMLBase.EnsembleAnalysis.timeseries_point_weighted_meancov` ``` -------------------------------- ### Solve an Ensemble Problem Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Solve an `AbstractEnsembleProblem` using a specified algorithm and ensemble algorithm. This function is used internally by the `solve` interface. ```julia SciMLBase.__solve(prob::SciMLBase.AbstractEnsembleProblem, alg, ensemblealg::SciMLBase.BasicEnsembleAlgorithm) ``` -------------------------------- ### Solve EnsembleProblem for Summing Endpoints Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Solves an EnsembleProblem where the reduction function sums the endpoints of each trajectory. The initial value is set to 0.0, and the final result `sim2.u` will be the total sum of endpoints. ```julia prob2 = EnsembleProblem(prob, prob_func = prob_func, output_func = output_func, reduction = reduction, u_init = 0.0) sim2 = solve(prob2, Tsit5(), trajectories = 100, batch_size = 20) ``` -------------------------------- ### Problem Traits Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Problems.md These traits provide information about the properties of a problem, such as whether it operates in-place or has diagonal noise. ```APIDOC ## `SciMLBase.isinplace` ### Description Checks if a problem operates in-place. ### Method `isinplace(prob::SciMLBase.AbstractDEProblem)` ## `SciMLBase.is_diagonal_noise` ### Description Indicates whether the problem has diagonal noise. ### Method `is_diagonal_noise` ``` -------------------------------- ### Component-wise Vectors by Time Point Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Converts ensemble data into component-wise vectors based on time points. ```julia SciMLBase.EnsembleAnalysis.componentwise_vectors_timepoint ``` -------------------------------- ### Compute Mean and Covariance Time Series (Points) Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Computes the mean and covariance matrices at specified time points, using interpolation. ```julia timeseries_point_meancov(sim, 0:(1 // 2 ^ (3)):1, 0:(1 // 2 ^ (3)):1) ``` -------------------------------- ### Access Timeseries for a Specific Component Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Solutions.md Retrieve the complete timeseries for a specific component 'i' of the solution. This utilizes Julia's colon operator for slicing. ```julia sol[i, :] ``` -------------------------------- ### Full Timeseries Statistics by Time Point Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Analyzes the full timeseries of ensemble data summarized by time points. Mean and meanvar return DiffEqArrays, while meancov and meancor return matrices of tuples. ```julia SciMLBase.EnsembleAnalysis.timeseries_point_mean SciMLBase.EnsembleAnalysis.timeseries_point_median SciMLBase.EnsembleAnalysis.timeseries_point_quantile SciMLBase.EnsembleAnalysis.timeseries_point_meanvar SciMLBase.EnsembleAnalysis.timeseries_point_meancov SciMLBase.EnsembleAnalysis.timeseries_point_meancor SciMLBase.EnsembleAnalysis.timeseries_point_weighted_meancov ``` -------------------------------- ### Check if Algorithm is Discrete Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md Use this trait to determine if a SciML algorithm operates on discrete systems. ```julia SciMLBase.isdiscrete ``` -------------------------------- ### Common Solve Function Signature Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md The core function signature for solving SciML problems with a specified algorithm. Algorithms should dispatch to this signature. ```julia CommonSolve.solve(prob::AbstractSciMLProblem, alg::AbstractSciMLAlgorithm; kwargs...) ``` -------------------------------- ### Check if Algorithm has Step Function Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md Use this trait to determine if the algorithm has a defined step function. ```julia SciMLBase.has_step ``` -------------------------------- ### Define `prob_func` for Random Initial Conditions Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Defines a function to modify the ODE problem by multiplying the initial condition by a random number. This function is used within EnsembleProblem for each trajectory. ```julia @everywhere function prob_func(prob, ctx) remake(prob, u0 = rand() * prob.u0) end ``` -------------------------------- ### Check if Algorithm Allows Arbitrary Number Types Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Algorithms.md Use this trait to check if a SciML algorithm can handle arbitrary number types. ```julia SciMLBase.allows_arbitrary_number_types ``` -------------------------------- ### EnsembleReduction for Summing Endpoints Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Defines a reduction function that sums the endpoints of each trajectory batch. This is used to calculate the mean of the endpoints efficiently, reducing memory usage. ```julia function reduction(u, batch, I) u + sum(batch), false end ``` -------------------------------- ### Concrete Nonlinear Problems Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Problems.md Defines a concrete type for representing homotopy problems, a specific type of nonlinear problem. ```APIDOC ## `SciMLBase.HomotopyProblem` ### Description A concrete type for representing homotopy problems. ### Type `SciMLBase.HomotopyProblem` ``` -------------------------------- ### Custom Output Function for Ensembles Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Defines a custom output function that returns the last element of the solution and a boolean indicating whether to stop. This is useful for focusing on the final state of a simulation. ```julia function output_func(sol, ctx) last(sol), false end ``` -------------------------------- ### Define Lotka-Volterra Drift Function Source: https://github.com/sciml/scimlbase.jl/blob/master/docs/src/interfaces/Ensembles.md Defines the deterministic part of the Lotka-Volterra system for an SDE. ```julia function f(du, u, p, t) du[1] = p[1] * u[1] - p[2] * u[1] * u[2] du[2] = -3 * u[2] + u[1] * u[2] end ```