LeastSquaresOptim.jl
LeastSquaresOptim.jl copied to clipboard
`Dogleg()` only works with a single equation at a time
MWE:
using LeastSquaresOptim
func(x) = sum(x.^2)
optimize(func, [1.0])
yields
Results of Optimization Algorithm
* Algorithm: Dogleg
* Minimizer: [0.0004882886969070914]
* Sum of squares at Minimum: 0.000000
* Iterations: 11
* Convergence: true
* |x - x'| < 1.0e-08: false
* |f(x) - f(x')| / |f(x)| < 1.0e-08: false
* |g(x)| < 1.0e-08: true
* Function Calls: 12
* Gradient Calls: 11
* Multiplication Calls: 44
whereas instead
using LeastSquaresOptim
func(x) = sum(x.^2)
optimize(func, [1.0, 1.0])
yields
ERROR: DimensionMismatch: B has leading dimension 1 but needs at least 2
Stacktrace:
[1] ldiv!(A::LinearAlgebra.QRPivoted{Float64, Matrix{Float64}, Vector{Float64}, Vector{Int64}}, B::Matrix{Float64}, rcond::Float64)
@ LinearAlgebra C:\Program Files\julia-1.11.1\share\julia\stdlib\v1.11\LinearAlgebra\src\qr.jl:544
[2] ldiv!
@ C:\Program Files\julia-1.11.1\share\julia\stdlib\v1.11\LinearAlgebra\src\qr.jl:620 [inlined]
[3] ldiv!
@ C:\Program Files\julia-1.11.1\share\julia\stdlib\v1.11\LinearAlgebra\src\qr.jl:618 [inlined]
[4] ldiv!(x::Vector{Float64}, J::Matrix{Float64}, y::Vector{Float64}, A::LeastSquaresOptim.DenseQRAllocatedSolver{Matrix{…}, Vector{…}})
@ LeastSquaresOptim C:\Users\iwheeler\.julia\packages\LeastSquaresOptim\PaxlX\src\solver\dense_qr.jl:34
[5] optimize!(anls::LeastSquaresProblemAllocated{…}; x_tol::Float64, f_tol::Float64, g_tol::Float64, iterations::Int64, Δ::Float64, store_trace::Bool, show_trace::Bool, show_every::Int64, lower::Vector{…}, upper::Vector{…})
@ LeastSquaresOptim C:\Users\iwheeler\.julia\packages\LeastSquaresOptim\PaxlX\src\optimizer\dogleg.jl:113
[6] optimize!
@ C:\Users\iwheeler\.julia\packages\LeastSquaresOptim\PaxlX\src\optimizer\dogleg.jl:46 [inlined]
[7] #optimize!#11
@ C:\Users\iwheeler\.julia\packages\LeastSquaresOptim\PaxlX\src\types.jl:149 [inlined]
[8] optimize!(nls::LeastSquaresProblem{…}, optimizer::Dogleg{…})
@ LeastSquaresOptim C:\Users\iwheeler\.julia\packages\LeastSquaresOptim\PaxlX\src\types.jl:148
[9] optimize(f::typeof(func), x::Vector{Float64}, t::Dogleg{Nothing}; autodiff::Symbol, kwargs::@Kwargs{})
@ LeastSquaresOptim C:\Users\iwheeler\.julia\packages\LeastSquaresOptim\PaxlX\src\types.jl:145
[10] optimize(f::Function, x::Vector{Float64}, t::Dogleg{Nothing})
@ LeastSquaresOptim C:\Users\iwheeler\.julia\packages\LeastSquaresOptim\PaxlX\src\types.jl:144
[11] top-level scope
@ REPL[9]:1
[12] top-level scope
@ none:1
Some type information was truncated. Use `show(err)` to see complete types.
Install information:
(dbug) pkg> st
Status `C:\Users\iwheeler\OneDrive - purdue.edu\Documents\OtherCode\dbug\Project.toml`
[0fc2ff8b] LeastSquaresOptim v0.8.6
(dbug) pkg> st -m
Status `C:\Users\iwheeler\OneDrive - purdue.edu\Documents\OtherCode\dbug\Manifest.toml`
[79e6a3ab] Adapt v4.1.1
[66dad0bd] AliasTables v1.1.3
[4fba245c] ArrayInterface v7.18.0
[bbf7d656] CommonSubexpressions v0.3.1
[34da2185] Compat v4.16.0
[187b0558] ConstructionBase v1.5.8
[9a962f9c] DataAPI v1.16.0
[864edb3b] DataStructures v0.18.20
[163ba53b] DiffResults v1.1.0
[b552c78f] DiffRules v1.15.1
[ffbed154] DocStringExtensions v0.9.3
[1a297f60] FillArrays v1.13.0
[6a86dc24] FiniteDiff v2.26.2
[f6369f11] ForwardDiff v0.10.38
[92d709cd] IrrationalConstants v0.2.2
[692b3bcd] JLLWrappers v1.6.1
[0fc2ff8b] LeastSquaresOptim v0.8.6
[d3d80556] LineSearches v7.3.0
[2ab3a3ac] LogExpFunctions v0.3.29
[1914dd2f] MacroTools v0.5.13
[e1d29d7a] Missings v1.2.0
[d41bc354] NLSolversBase v7.8.3
[77ba4419] NaNMath v1.0.2
[429524aa] Optim v1.10.0
[bac558e1] OrderedCollections v1.7.0
[d96e819e] Parameters v0.12.3
[85a6dd25] PositiveFactorizations v0.2.4
[21216c6a] Preferences v1.4.3
[43287f4e] PtrArrays v1.2.1
[ae029012] Requires v1.3.0
[efcf1570] Setfield v1.1.1
[a2af1166] SortingAlgorithms v1.2.1
[276daf66] SpecialFunctions v2.5.0
[1e83bf80] StaticArraysCore v1.4.3
[10745b16] Statistics v1.11.1
[82ae8749] StatsAPI v1.7.0
[2913bbd2] StatsBase v0.34.4
[3a884ed6] UnPack v1.0.2
[efe28fd5] OpenSpecFun_jll v0.5.5+0
[0dad84c5] ArgTools v1.1.2
[56f22d72] Artifacts v1.11.0
[2a0f44e3] Base64 v1.11.0
[ade2ca70] Dates v1.11.0
[8ba89e20] Distributed v1.11.0
[f43a241f] Downloads v1.6.0
[7b1f6079] FileWatching v1.11.0
[9fa8497b] Future v1.11.0
[b77e0a4c] InteractiveUtils v1.11.0
[b27032c2] LibCURL v0.6.4
[76f85450] LibGit2 v1.11.0
[8f399da3] Libdl v1.11.0
[37e2e46d] LinearAlgebra v1.11.0
[56ddb016] Logging v1.11.0
[d6f4376e] Markdown v1.11.0
[ca575930] NetworkOptions v1.2.0
[44cfe95a] Pkg v1.11.0
[de0858da] Printf v1.11.0
[9a3f8284] Random v1.11.0
[ea8e919c] SHA v0.7.0
[9e88b42a] Serialization v1.11.0
[6462fe0b] Sockets v1.11.0
[2f01184e] SparseArrays v1.11.0
[4607b0f0] SuiteSparse
[fa267f1f] TOML v1.0.3
[a4e569a6] Tar v1.10.0
[cf7118a7] UUIDs v1.11.0
[4ec0a83e] Unicode v1.11.0
[e66e0078] CompilerSupportLibraries_jll v1.1.1+0
[deac9b47] LibCURL_jll v8.6.0+0
[e37daf67] LibGit2_jll v1.7.2+0
[29816b5a] LibSSH2_jll v1.11.0+1
[c8ffd9c3] MbedTLS_jll v2.28.6+0
[14a3606d] MozillaCACerts_jll v2023.12.12
[4536629a] OpenBLAS_jll v0.3.27+1
[05823500] OpenLibm_jll v0.8.1+2
[bea87d4a] SuiteSparse_jll v7.7.0+0
[83775a58] Zlib_jll v1.2.13+1
[8e850b90] libblastrampoline_jll v5.11.0+0
[8e850ede] nghttp2_jll v1.59.0+0
[3f19e933] p7zip_jll v17.4.0+2