-
-
Notifications
You must be signed in to change notification settings - Fork 46
Levenberg-Marquardt with Sparse J: J isn't square?! #599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Levenberg-Marquardt with Sparse J: J isn't square?! #599
Comments
LM needs to solve a linear system with a size |
https://github.com/SciML/LinearSolve.jl/blob/main/ext/LinearSolveSparseArraysExt.jl#L248 Can someone add an |
I did so, and I'm getting that it's Edit: working my way up the stacktrace, the errant matrix is created in stack frame |
using NonlinearSolve
using SciMLBase
using SparseArrays
using PowerFlows, PowerSystemCaseBuilder
const PF = PowerFlows
const PSB = PowerSystemCaseBuilder
# small system for demo purposes: actual target system has 10k buses.
sys = PSB.build_system(PSB.MatpowerTestSystems, "matpower_case5_sys") ERROR: KeyError: key :PowerSystems not found
Stacktrace:
[1] root_module(where::Module, name::Symbol)
@ Base ./loading.jl:1951
[2] get_module(module_name::String)
@ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/yUXE4/src/utils/utils.jl:382
[3] get_type_from_serialization_metadata(metadata::Dict{String, Any})
@ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/yUXE4/src/serialization.jl:132
[4] get_type_from_serialization_data(data::Dict{String, Any})
@ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/yUXE4/src/serialization.jl:128
[5] deserialize_components!(sys::PowerSystems.System, raw::Dict{String, Any})
@ PowerSystems ~/.julia/packages/PowerSystems/9ugJZ/src/base.jl:1464
[6] deserialize(::Type{…}, filename::String; time_series_read_only::Bool, time_series_directory::Nothing, kwargs::@Kwargs{…})
@ PowerSystems ~/.julia/packages/PowerSystems/9ugJZ/src/base.jl:1441
[7] deserialize
@ ~/.julia/packages/PowerSystems/9ugJZ/src/base.jl:1389 [inlined]
[8] PowerSystems.System(file_path::String; assign_new_uuids::Bool, kwargs::@Kwargs{})
@ PowerSystems ~/.julia/packages/PowerSystems/9ugJZ/src/base.jl:204
[9] _build_system(category::Type{…}, name::String, sys_descriptor::SystemDescriptor, print_stat::Bool; kwargs::@Kwargs{})
@ PowerSystemCaseBuilder ~/.julia/packages/PowerSystemCaseBuilder/7w4lG/src/build_system.jl:112
[10] _build_system
@ ~/.julia/packages/PowerSystemCaseBuilder/7w4lG/src/build_system.jl:75 [inlined]
[11] #build_system#236
@ ~/.julia/packages/PowerSystemCaseBuilder/7w4lG/src/build_system.jl:26 [inlined]
[12] build_system
@ ~/.julia/packages/PowerSystemCaseBuilder/7w4lG/src/build_system.jl:18 [inlined]
[13] build_system(category::Type{MatpowerTestSystems}, name::String)
@ PowerSystemCaseBuilder ~/.julia/packages/PowerSystemCaseBuilder/7w4lG/src/build_system.jl:18
[14] top-level scope
@ ~/Desktop/test2.jl:8
Some type information was truncated. Use `show(err)` to see complete types. |
And I couldn't recreate it with a simple MWE: using NonlinearSolve
function f!(du, u, p)
du[1] = 2u[1] - 2
du[2] = u[1] - 4u[2]
end
jac = SparseMatrixCSC([
1 0
1 1
])
u0 = [0.0, 0.0]
prob = NonlinearProblem(
NonlinearFunction(f!, jac_prototype = jac), u0)
solver = NonlinearSolveFirstOrder.LevenbergMarquardt()
solve(prob, solver) Please try and make an MWE that doesn't require the extra packages. The core issue shouldn't require anything specific about |
Try adding
Strangely, if I change the indexing type to
|
Thanks, that pinpointed where the issue was. ArrayInterface and LinearSolve need to handle Int32 cases, so it'll need to wait for the LinearSolve.jl bump but this is fixed locally and just needs one more merge. |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug 🐞
I'm trying to run the
LevenbergMarquardt
solver on the system of equations arising from a power flow problem. After setting everything up, NonlinearSolve.jl is saying that the Jacobian matrix isn't square. All matrices I've provided are indeed square.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
There's a chance that I'm just doing something wrong here, that this isn't actually a bug. But the error message is bizarre enough that I decided to pick "Bug" over "Question" when opening this issue. I also created a discourse post about this same issue.
The text was updated successfully, but these errors were encountered: