ITADN
SciML/SciMLBase.jl
SciML/SciMLBase.jl · 文件 下载 ZIP
文件最后提交记录最后更新时间
README.md
以下内容由 AI 翻译,如有问题请点此提交 issue 反馈

SciMLBase

Join the chat at https://julialang.zulipchat.com #sciml-bridged Global Docs

codecov Build Status

ColPrac: Contributor's Guide on Collaborative Practices for Community Packages SciML Code Style

SciMLBase.jl 是 SciML 生态系统的核心接口定义。它是一个低依赖库,旨在被下游库依赖,以提供通用接口并允许数学问题之间的互换。

v3.0 破坏性变更

RecursiveArrayTools v4:Solution 类型现在是 AbstractArrays 的子类型 (#1297)

影响最大的变更。 AbstractVectorOfArray(因此 ODESolutionDDESolutionRODESolutionDAESolution)现在是 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::EnsembleContext
  • output_func(sol, i)output_func(sol, ctx)
  • EnsembleContext 包含 sim_idrepeatrngsim_seedworker_idmaster_rng
  • solve() 新增 seed/rng/rng_func 关键字参数,用于确定性的、与线程数无关的 ensemble 求解

移除已弃用的 API

  • u_modified! 重命名为 derivative_discontinuity! (#1289)
  • 移除 deprecated.jl:旧类型别名(DEAlgorithmDEProblemDESolution 等)、构造函数、已弃用的访问器 (#1291)
  • 移除 remake.jl 和 MLStyle 扩展中的向后兼容垫片 (#1292)
  • 移除旧迭代器:tuplesintervalsTimeChoiceIterator (#1290)
  • 移除 SymbolReturnCode.T 转换(Base.convert(::Type{ReturnCode.T}, ::Symbol)symbol_to_ReturnCode)——在 v1/v2 中已弃用多年,每次使用时都会打印警告。比较 sol.retcode == :Success 不再有效;请使用 SciMLBase.successful_retcode(sol),它能正确接受所有类似成功的 ReturnCode 值(SuccessStalledSuccessExactSolutionLeftExactSolutionRightFloatingPointLimit、…),而不仅仅是 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 solfor u in sol.u
u_modified!(integrator, true)derivative_discontinuity!(integrator, true)
prob_func(prob, i, repeat)prob_func(prob, ctx) — 使用 ctx.sim_idctx.repeat
output_func(sol, i)output_func(sol, ctx)
sol.destatssol.stats
sol.retcode == :SuccessSciMLBase.successful_retcode(sol)
ODEFunction{true}(f) (FullSpecialize)现在默认使用 AutoSpecialize

v2.0 破坏性变更

v2.0 中的破坏性变更如下:

  • IntegralProblem 已迁移到 IntegralFunctionBatchedIntegralFunction 的接口,该接口要求为要修改的值指定 prototype, 而不是 noutbatchhttps://github.com/SciML/SciMLBase.jl/pull/497
    • ODEProblem 暂时被改为 mutable struct 以支持 EnzymeRules。使用突变会抛出警告,指出这仅是实验性的,不应依赖。 https://github.com/SciML/SciMLBase.jl/pull/501
    • BVProblem 现在为 TwoPointBVProblem 提供了新接口,该接口将边界条件项拆分为两侧,强制使用真正的两点 BVProblem,以允许进一步的特化, 并允许在接口中包装 Fortran 求解器。https://github.com/SciML/SciMLBase.jl/pull/477
    • SDEProblem 构造函数已更改,移除了一个反模式,该模式要求将扩散函数 g 传递两次,即 SDEProblem(SDEFunction(f,g),g, ...)。 现在这仅仅是 SDEProblem(SDEFunction(f,g),...)https://github.com/SciML/SciMLBase.jl/pull/489