An acausal modeling framework for automatically parallelized scientific machine learning (SciML) in Julia. A computer algebra system for integrated symbolics for physics-informed machine learning and automated transformations of differential equations
When I create a 2-dimensional parameter (A) and variable (L) of the same size, I get a DimensionMismatch error when creating the equation L ~ A.
Expected behavior
I would expect that the equation L ~ A is valid when L and A have the same dimensions and sizes.
Minimal Reproducible Example 👇
using LinearAlgebra
using DifferentialEquations
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
industries = 4
function test_factory(;name)
@parameters A[1:industries, 1:industries] = rand(industries, industries)
@variables L(t)[1:industries, 1:industries]
eq = [
L ~ A
]
return ODESystem(eq, t; name)
end
@named mysys = test_factory()
eqsystem = compose(mysys)
eqsystem = structural_simplify(eqsystem)
prob = ODEProblem(eqsystem, (0.0, 100.0))
sol = solve(prob, Tsit5())
Plots.display(plot(sol))
Error & Stacktrace ⚠️
ERROR: DimensionMismatch: number of columns of each array must match (got (1, 4))
Stacktrace:
[1] _typed_vcat(::Type{Equation}, A::Tuple{Vector{Equation}, Matrix{Equation}})
@ Base .\abstractarray.jl:1702
[2] typed_vcat
@ .\abstractarray.jl:1716 [inlined]
[3] vcat(::Vector{Equation}, ::Matrix{Equation})
@ Base .\abstractarray.jl:1694
[4] BottomRF
@ .\reduce.jl:86 [inlined]
[5] MappingRF
@ .\reduce.jl:100 [inlined]
[6] _foldl_impl(op::Base.MappingRF{…}, init::Vector{…}, itr::Vector{…})
@ Base .\reduce.jl:58
[7] foldl_impl
@ .\reduce.jl:48 [inlined]
[8] mapfoldl_impl
@ .\reduce.jl:44 [inlined]
[9] _mapreduce_dim
@ .\reducedim.jl:362 [inlined]
[10] mapreduce
@ .\reducedim.jl:357 [inlined]
[11] flatten_equations(eqs::Vector{Equation})
@ ModelingToolkit C:\Users\robva\.julia\packages\ModelingToolkit\kByuD\src\systems\diffeqs\abstractodesystem.jl:1526
[12] TearingState(sys::ODESystem; quick_cancel::Bool, check::Bool)
@ ModelingToolkit C:\Users\robva\.julia\packages\ModelingToolkit\kByuD\src\systems\systemstructure.jl:255
[13] TearingState(sys::ODESystem)
@ ModelingToolkit C:\Users\robva\.julia\packages\ModelingToolkit\kByuD\src\systems\systemstructure.jl:250
[14] __structural_simplify(sys::ODESystem, io::Nothing; simplify::Bool, kwargs::@Kwargs{})
@ ModelingToolkit C:\Users\robva\.julia\packages\ModelingToolkit\kByuD\src\systems\systems.jl:58
[15] __structural_simplify
@ C:\Users\robva\.julia\packages\ModelingToolkit\kByuD\src\systems\systems.jl:55 [inlined]
[16] structural_simplify(sys::ODESystem, io::Nothing; simplify::Bool, split::Bool, kwargs::@Kwargs{})
@ ModelingToolkit C:\Users\robva\.julia\packages\ModelingToolkit\kByuD\src\systems\systems.jl:22
[17] structural_simplify
@ C:\Users\robva\.julia\packages\ModelingToolkit\kByuD\src\systems\systems.jl:19 [inlined]
[18] structural_simplify(sys::ODESystem)
@ ModelingToolkit C:\Users\robva\.julia\packages\ModelingToolkit\kByuD\src\systems\systems.jl:19
[19] top-level scope
@ c:\Users\robva\ToBe\Trials\Julia\Array tests.jl:24
Some type information was truncated. Use `show(err)` to see complete types.
Environment (please complete the following information):
Describe the bug 🐞
When I create a 2-dimensional parameter (A) and variable (L) of the same size, I get a DimensionMismatch error when creating the equation L ~ A.
Expected behavior
I would expect that the equation L ~ A is valid when L and A have the same dimensions and sizes.
Minimal Reproducible Example 👇
Error & Stacktrace ⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context
Add any other context about the problem here.