SciML/SciMLBase.jl · 文件 下载 ZIP
文件最后提交记录最后更新时间
README.md
以下内容由 AI 翻译,如有问题请点此提交 issue 反馈
SciMLBase
SciMLBase.jl 是 SciML 生态系统的核心接口定义。它是一个低依赖库,旨在被下游库依赖,以提供通用接口并允许数学问题之间的互换。
v3.0 破坏性变更
RecursiveArrayTools v4:Solution 类型现在是 AbstractArrays 的子类型 (#1297)
影响最大的变更。 AbstractVectorOfArray(因此 ODESolution、DDESolution、RODESolution、DAESolution)现在是 AbstractArray 的子类型:
sol[i]返回第i个标量元素(列主序),而不是第i个时间步。请使用sol.u[i]或sol[:, i]获取时间步。length(sol)返回总元素数(prod(size(sol)))。请使用length(sol.u)获取时间步数量。iterate(sol)迭代标量元素。请使用sol.u进行时间步迭代。map(f, sol)对元素进行映射。请使用map(f, sol.u)处理时间步。
Ensemble RNG 重新设计 (#1252)
prob_func(prob, i, repeat)→prob_func(prob, ctx),其中ctx::EnsembleContextoutput_func(sol, i)→output_func(sol, ctx)EnsembleContext包含sim_id、repeat、rng、sim_seed、worker_id、master_rngsolve()新增seed/rng/rng_func关键字参数,用于确定性的、与线程数无关的 ensemble 求解
移除已弃用的 API
u_modified!重命名为derivative_discontinuity!(#1289)- 移除
deprecated.jl:旧类型别名(DEAlgorithm、DEProblem、DESolution等)、构造函数、已弃用的访问器 (#1291) - 移除
remake.jl和 MLStyle 扩展中的向后兼容垫片 (#1292) - 移除旧迭代器:
tuples、intervals、TimeChoiceIterator(#1290) - 移除
Symbol→ReturnCode.T转换(Base.convert(::Type{ReturnCode.T}, ::Symbol)和symbol_to_ReturnCode)——在 v1/v2 中已弃用多年,每次使用时都会打印警告。比较sol.retcode == :Success不再有效;请使用SciMLBase.successful_retcode(sol),它能正确接受所有类似成功的ReturnCode值(Success、StalledSuccess、ExactSolutionLeft、ExactSolutionRight、FloatingPointLimit、…),而不仅仅是Success。
简化 getproperty
- 移除解决方案抽象类型上冗余的
getproperty重载 (#1293) - 移除已弃用的
getproperty别名(.destats、.x、.lb/.ub、.minimizer、.minimum) (#1294)
其他破坏性变更
- 用纯 Julia 结构体替换 Moshi 用于 Clocks —— 预编译性能提升 23% (#1295)
ODEFunction使用DEFAULT_SPECIALIZATION(AutoSpecialize) 用于便捷构造函数 (#1300)- 从解决方案可调用对象向 DiffEqArrays 传播
interp/dense(#1297) is_discrete_time_domain(nothing)现在返回false(#1306)
迁移指南
| 旧版 (v2) | 新版 (v3) |
|---|---|
sol[i] (timestep) | sol.u[i] 或 sol[:, i] |
length(sol) (timesteps) | length(sol.u) |
for u in sol | for u in sol.u |
u_modified!(integrator, true) | derivative_discontinuity!(integrator, true) |
prob_func(prob, i, repeat) | prob_func(prob, ctx) — 使用 ctx.sim_id、ctx.repeat |
output_func(sol, i) | output_func(sol, ctx) |
sol.destats | sol.stats |
sol.retcode == :Success | SciMLBase.successful_retcode(sol) |
ODEFunction{true}(f) (FullSpecialize) | 现在默认使用 AutoSpecialize |
v2.0 破坏性变更
v2.0 中的破坏性变更如下:
IntegralProblem已迁移到IntegralFunction和BatchedIntegralFunction的接口,该接口要求为要修改的值指定prototype, 而不是nout和batch。https://github.com/SciML/SciMLBase.jl/pull/497ODEProblem暂时被改为mutable struct以支持 EnzymeRules。使用突变会抛出警告,指出这仅是实验性的,不应依赖。 https://github.com/SciML/SciMLBase.jl/pull/501BVProblem现在为TwoPointBVProblem提供了新接口,该接口将边界条件项拆分为两侧,强制使用真正的两点 BVProblem,以允许进一步的特化, 并允许在接口中包装 Fortran 求解器。https://github.com/SciML/SciMLBase.jl/pull/477SDEProblem构造函数已更改,移除了一个反模式,该模式要求将扩散函数g传递两次,即SDEProblem(SDEFunction(f,g),g, ...)。 现在这仅仅是SDEProblem(SDEFunction(f,g),...)。https://github.com/SciML/SciMLBase.jl/pull/489