My system is overdetermined. Are there tools to find the culprit equation?

Recently I’ve updated a very big project to the latest version of MTK. I now get this warning:

┌ Warning: Initialization system is overdetermined. 1 equations for 0 unknowns. 
Initialization will default to using least squares. To suppress this warning pass warn_initialize_determined = false. To make this warning into an error, pass fully_determined = true
└ @ ModelingToolkit C:\Users\datse\.julia\packages\ModelingToolkit\Vsl3C\src\systems\diffeqs\abstractodesystem.jl:1465

Are there tools to find the culprit equation somehow? My model is massive, with 50+ equations split over 5 files. Even though I am looking, it is very hard to find which one is overspecifying the system.

My code runs perfectly fine mind you - just like it used to run before I updated MTK. I am not really sure of the implications of this warning to be honest.

Check the initialization system, equations(prob.f.initializationprob.f.sys) and you’ll see what the extra equation is.

2 Likes

What’s prob supposed to be here? I am making an ODESystem, at which point I get the aforementioned warning, before making any ODEProblem. I can’t apply the code you cite for this system, it doesn’t have the fields.

If I then make prob = ODEProblem(ssys, nothing, (0.0, Inf)), I still can’t apply the code because I get

ODEProblem with uType Vector{Float64} and tType Float64. In-place: true
timespan: (0.0, Inf)
u0: 5-element Vector{Float64}:
  290.0
    1.0
 1200.0
  290.0
   11.0

julia> equations(prob.f.initializationprob.f.sys)
ERROR: type ODEFunction has no field initializationprob
Stacktrace:
 [1] getproperty(x::Function, f::Symbol)
   @ Base .\Base.jl:37
 [2] top-level scope
   @ REPL[15]:1

I’d need an MWE. If you aren’t creating the problem then it shouldn’t be creating the iniitalizaiton system.

Okay, I have found the solution. The answer is to use

equations(prob.f.initializeprob.f.sys)

on the created ODEProblem resulting from the ODESystem. Notice the typo initializeprob versus initializationprob.