Overflow error in `mtkcompile` for friction model with 32 nodes
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
Hướng nghiên cứu
The reproducer calls mtkcompile on a generated friction model network and reports an OverflowError at 32 or more nodes; start by running the script with the listed ModelingToolkit version to confirm the threshold. The issue points to ModelingToolkit PR #2089 as possibly related, so inspect that change and the state selection code reached during compilation. Done means identifying and fixing the overflow so the reproducer compiles at the reported node counts.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
A network of friction model fails to compile with node counts 32 or larger, it seems to be an integer that overflows. With 31 it works fine.
copilot-authored script to reproduce and monkeypatch to use BigInt below.
ModelingToolkit version 11.45.5, Julia 1.13.2.
Maybe ModelingToolkit #2089: Fix Barreiss algorithm is related in some way?
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
@connector function ContactPort(; name)
variables = @variables begin
velocity(t)
force(t), [connect = Flow]
end
return System(Equation[], t, variables, []; name)
end
function contact_model(; name)
parameters = @parameters stiffness = 1.0 rate_coefficient = 1.0
variables = @variables begin
deformation(t) = 0.0
plastic_slip(t) = 0.0
accumulated_slip(t) = 0.0
resistance(t)
capacity(t)
positive_rate(t)
negative_rate(t)
slip_rate(t)
end
@named port = ContactPort()
equations = [
resistance ~ stiffness * deformation,
capacity ~ 1 + exp(-accumulated_slip),
positive_rate ~ (resistance - capacity + abs(resistance - capacity)) /
(2rate_coefficient),
negative_rate ~ (-resistance - capacity + abs(-resistance - capacity)) /
(2rate_coefficient),
slip_rate ~ positive_rate - negative_rate,
D(deformation) ~ port.velocity - slip_rate,
D(plastic_slip) ~ slip_rate,
D(accumulated_slip) ~ positive_rate + negative_rate,
port.force ~ resistance,
]
return compose(System(equations, t, variables, parameters; name), port)
end
function velocity_source(; name)
@named port = ContactPort()
return compose(System([port.velocity ~ -1.0], t; name), port)
end
function contact_network(contact_count)
@named source = velocity_source()
contacts = [contact_model(; name = Symbol(:contact, index)) for index in 1:contact_count]
equations = [connect(source.port, [contact.port for contact in contacts]...)]
return compose(System(equations, t; name = :contact_network), source, contacts...)
end
function reproduce_main()
for contact_count in (1, 30, 31, 32, 45, 60)
try
elapsed = @elapsed mtkcompile(contact_network(contact_count))
println("PASS contacts=", contact_count, " compile_s=", elapsed)
catch exception
println("FAIL contacts=", contact_count, " ", sprint(showerror, exception))
exception isa OverflowError || rethrow()
end
end
end
function enable_bigint_probe!()
@eval ModelingToolkit.StateSelection begin
function aag_bareiss!(structure, original::CLIL.SparseMatrixCLIL{Int, Int})
pristine = copy(original)
try
return invoke(aag_bareiss!, Tuple{Any, CLIL.SparseMatrixCLIL},
structure, original)
catch exception
exception isa OverflowError || rethrow()
end
reduced, solvable, ranks = aag_bareiss!(structure,
convert(CLIL.SparseMatrixCLIL{BigInt, Int}, pristine))
maximum_coefficient = maximum(
(maximum(abs, row; init = big(0)) for row in reduced.row_vals);
init = big(0))
println("BIGINT_RETRY_OK rows=", size(pristine, 1),
" max_reduced_coefficient=", maximum_coefficient)
return convert(CLIL.SparseMatrixCLIL{Int, Int}, reduced), solvable, ranks
end
end
end
if "--bigint-probe" in ARGS
enable_bigint_probe!()
end
if abspath(PROGRAM_FILE) == @__FILE__
reproduce_main()
end
- Ngôn ngữ chính
- Julia
- Star
- 8
- Fork
- 14
- Merge trung bình
- 8 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của JuliaComputing/StateSelection.jl
-
Inline linear SCC solves share one `LinearCache` per matrix size, so every call refactorizesĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
-
Inlined linear SCC of three unknowns: the run-time solve dominates the cost of the right-hand sideĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
JuliaComputing/StateSelection.jl#173 · 3 bình luận ·
-
State-machine query operators in ModelingToolkitTearing throw UndefVarError for wrapCó thể đã có người làm @baggepinnen đã nhận 16 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
-
`maybe_zeros` check does not look inside a division, so tearing divides by a parameter expression that is zero (NaN in initialization)Có thể đã có người làm @mwhincup đã nhận 20 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
JuliaComputing/StateSelection.jl#166 · 1 bình luận ·
Tất cả issue của JuliaComputing/StateSelection.jl
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
JuliaDiff/TaylorSeries.jl#445 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
SciML/PETScDiffEq.jl#362 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Prescribed ice velocities never get their halos filled, so ice is created at a periodic seamĐang mở🕷️ bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CliMA/ClimaSeaIce.jl#203 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
JuliaMath/SpecialFunctions.jl#570 ·
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
JuliaPhysics/BeamletOptics.jl#221 ·
Maintainer thường phản hồi trong vòng 1 ngày