Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/problems/sccnonlinearproblem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@
@warn "System is simplified but does not have a schedule. This should not happen."
var_eq_matching, var_sccs = StructuralTransformations.algebraic_variables_scc(ts)
condensed_graph = MatchedCondensationGraph(
DiCMOBiGraph{true}(

Check warning on line 447 in src/problems/sccnonlinearproblem.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos / Spell Check with Typos

"CMO" should be "COM".
complete(ts.structure.graph),
complete(var_eq_matching)
),
Expand Down Expand Up @@ -609,7 +609,7 @@
end
end
MissingGuessValue.HashedRandom() => begin
newval = [hash(var,hash(i)) for i in SU.stable_eachindex(symbolic_idxs)]./0x1p64
newval = [hash(dvs[vscc[j]]) for j in symbolic_idxs]./0x1p64
_u0[symbolic_idxs] .= newval
for (idx, j) in enumerate(symbolic_idxs)
write_possibly_indexed_array!(
Expand Down
14 changes: 14 additions & 0 deletions test/scc_nonlinear_problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,17 @@ end
ModelingToolkitBase.subexpressions_not_involving_vars!(ir, [unwrap(expr)], banned_vars, state)
@test issetequal(keys(state), [x[1], 2x[2], x[2]^2, f(x[2] + 1)])
end

@testset "HashedRandom missing guesses in init `SCCNonlinearProblem` (#4603)" begin
# Initialization decomposes into multiple SCCs and no guesses are provided,
# so the default `HashedRandom` missing-guess strategy is used for the SCC
# init problem. This previously errored with
# `MethodError: no method matching stable_eachindex(::Vector{Int64})`.
@variables a(t) b(t) c(t) d(t)
@mtkcompile sys = System(
[D(a) ~ b, 0 ~ b^3 + b + a - 2, 0 ~ c^3 + c - b, 0 ~ d - c * b], t)
prob = ODEProblem(sys, [a => 0.5], (0.0, 1.0))
@test prob.f.initialization_data.initializeprob isa SCCNonlinearProblem
sol = solve(prob, Rodas5P())
@test SciMLBase.successful_retcode(sol)
end
Loading