Skip to content
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

gared crash on Julia v1.10.0-beta2 #26

Closed
franckgaga opened this issue Aug 30, 2023 · 6 comments
Closed

gared crash on Julia v1.10.0-beta2 #26

franckgaga opened this issue Aug 30, 2023 · 6 comments

Comments

@franckgaga
Copy link

franckgaga commented Aug 30, 2023

Hi,

Thanks for all the great works! It's great to have an OO alternative to MATLAB.

On Julia v.1.10.0-beta2 (you can install it with UpdateJulia.jl or juliaup), ared function crash.

If I do:

using MatrixEquations
A=[0.5;;]
B=[1.0;;]
Q=[1.0;;]
R=[1.0;;]
ared(A, B, R, Q)

I get this error:

ERROR: MethodError: no method matching *(::LinearAlgebra.AdjointQ{Float64, LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}}, ::LinearMaps.BlockMap{Float64, Tuple{LinearMaps.WrappedMap{Float64, Matrix{Float64}}, LinearMaps.UniformScalingMap{Bool}, Vararg{LinearMaps.WrappedMap{Float64, Matrix{Float64}}, 4}}, Tuple{Int64, Int64}})

Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...)
   @ Base operators.jl:585
  *(::LinearMaps.ScaledMap, ::LinearMaps.LinearMap)
   @ LinearMaps ~/.julia/packages/LinearMaps/gMfcQ/src/scaledmap.jl:49
  *(::LinearMaps.CompositeMap, ::LinearMaps.LinearMap)
   @ LinearMaps ~/.julia/packages/LinearMaps/gMfcQ/src/composition.jl:147
  ...

Stacktrace:
 [1] gared(A::Matrix{…}, E::LinearAlgebra.UniformScaling{…}, B::Matrix{…}, R::Matrix{…}, Q::Matrix{…}, S::Matrix{…}; as::Bool, rtol::Float64)
   @ MatrixEquations ~/.julia/packages/MatrixEquations/vBvfe/src/riccati.jl:833
 [2] gared
   @ MatrixEquations ~/.julia/packages/MatrixEquations/vBvfe/src/riccati.jl:774 [inlined]
 [3] #ared#38
   @ MatrixEquations ~/.julia/packages/MatrixEquations/vBvfe/src/riccati.jl:693 [inlined]
 [4] ared
   @ MatrixEquations ~/.julia/packages/MatrixEquations/vBvfe/src/riccati.jl:690 [inlined]
 [5] ared(A::Matrix{Float64}, B::Matrix{Float64}, R::Matrix{Float64}, Q::Matrix{Float64})
   @ MatrixEquations ~/.julia/packages/MatrixEquations/vBvfe/src/riccati.jl:690
 [6] top-level scope
   @ ~/Documents/Personnel/ModelPredictiveControl.jl/example/Untitled-2.jl:6
Some type information was truncated. Use `show(err)` to see complete types.

and the complete types with show(err) are:

julia> show(err)
1-element ExceptionStack:
LoadError: MethodError: no method matching *(::LinearAlgebra.AdjointQ{Float64, LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}}, ::LinearMaps.BlockMap{Float64, Tuple{LinearMaps.WrappedMap{Float64, Matrix{Float64}}, LinearMaps.UniformScalingMap{Bool}, Vararg{LinearMaps.WrappedMap{Float64, Matrix{Float64}}, 4}}, Tuple{Int64, Int64}})

Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...)
   @ Base operators.jl:585
  *(::LinearMaps.ScaledMap, ::LinearMaps.LinearMap)
   @ LinearMaps ~/.julia/packages/LinearMaps/gMfcQ/src/scaledmap.jl:49
  *(::LinearMaps.CompositeMap, ::LinearMaps.LinearMap)
   @ LinearMaps ~/.julia/packages/LinearMaps/gMfcQ/src/composition.jl:147
  ...

Stacktrace:
  [1] gared(A::Matrix{Float64}, E::LinearAlgebra.UniformScaling{Bool}, B::Matrix{Float64}, R::Matrix{Float64}, Q::Matrix{Float64}, S::Matrix{Float64}; as::Bool, rtol::Float64)
    @ MatrixEquations ~/.julia/packages/MatrixEquations/vBvfe/src/riccati.jl:833
  [2] gared
    @ MatrixEquations ~/.julia/packages/MatrixEquations/vBvfe/src/riccati.jl:774 [inlined]
  [3] #ared#38
    @ MatrixEquations ~/.julia/packages/MatrixEquations/vBvfe/src/riccati.jl:693 [inlined]
  [4] ared
    @ MatrixEquations ~/.julia/packages/MatrixEquations/vBvfe/src/riccati.jl:690 [inlined]
  [5] ared(A::Matrix{Float64}, B::Matrix{Float64}, R::Matrix{Float64}, Q::Matrix{Float64})
    @ MatrixEquations ~/.julia/packages/MatrixEquations/vBvfe/src/riccati.jl:690
  [6] top-level scope
    @ ~/Documents/Personnel/ModelPredictiveControl.jl/example/Untitled-2.jl:6
  [7] eval
    @ Base ./boot.jl:383 [inlined]
  [8] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:2070
  [9] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Base ./essentials.jl:887
 [10] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:884
 [11] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.51.1/scripts/packages/VSCodeServer/src/eval.jl:261
 [12] (::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.51.1/scripts/packages/VSCodeServer/src/eval.jl:181
 [13] withpath(f::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.51.1/scripts/packages/VSCodeServer/src/repl.jl:274
 [14] (::VSCodeServer.var"#66#71"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.51.1/scripts/packages/VSCodeServer/src/eval.jl:179
 [15] hideprompt(f::VSCodeServer.var"#66#71"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.51.1/scripts/packages/VSCodeServer/src/repl.jl:38
 [16] (::VSCodeServer.var"#65#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.51.1/scripts/packages/VSCodeServer/src/eval.jl:150
 [17] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:515
 [18] with_logger
    @ VSCodeServer ./logging.jl:627 [inlined]
 [19] (::VSCodeServer.var"#64#69"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.51.1/scripts/packages/VSCodeServer/src/eval.jl:253
 [20] #invokelatest#2
    @ Base ./essentials.jl:887 [inlined]
 [21] invokelatest(::Any)
    @ Base ./essentials.jl:884
 [22] (::VSCodeServer.var"#62#63")()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.51.1/scripts/packages/VSCodeServer/src/eval.jl:34
in expression starting at /home/francis/Documents/Personnel/ModelPredictiveControl.jl/example/Untitled-2.jl:6

Francis Gagnon

@andreasvarga
Copy link
Owner

I think this issue is related to a new type AdjointFactorization introduced in v1.10, which is breaking (see #46874). Unfortunately, in the next two weeks I will be not available to look for a fix, but perhaps @dkarrasch could help in this issue.

@dkarrasch
Copy link
Contributor

This looks like an oversight in LinearMaps.jl: the product of a matrix and a linear map yields a LinearMaps.CompositeMap, but AbstractQs no longer subtype AbstractMatrix and hence are not covered by that method anymore. I'll take a look at it tomorrow. Hopefully, that will fix the issue.

@dkarrasch
Copy link
Contributor

Actually, it's something else. It's an unintended type piracy that occured due to changes in Base/LinearAlgebra. JuliaLang/julia#51132 should help here, together with corresponding changes in LinearMaps.jl.

@andreasvarga
Copy link
Owner

The nightly tests with Julia Version 1.11.0-DEV.448, produced plenty of errors, of which I picked out only a few below with the corresponding Julia statements:

1. MethodError: no method matching schur(::LinearMaps.BlockMap{Float64, Tuple{LinearMaps.WrappedMap{Float64, Matrix{Float64}}, LinearMaps.WrappedMap{Float64, Matrix{Float64}}, LinearMaps.UniformScalingMap{Float64}, LinearMaps.WrappedMap{Float64, Matrix{Float64}}}, Tuple{Int64, Int64}})

S = schur([A  -G; -Q  -copy(A')])

2. MethodError: no method matching schur(::LinearMaps.BlockMap{Float64, Tuple{LinearMaps.WrappedMap{Float64, Matrix{Float64}}, LinearMaps.WrappedMap{Float64, Matrix{Float64}}, LinearMaps.UniformScalingMap{Float64}, LinearMaps.WrappedMap{Float64, LinearAlgebra.Adjoint{Float64, Matrix{Float64}}}}, Tuple{Int64, Int64}}, ::Matrix{Float64})

L = [ A -G; -Q -A']
P = [ E zeros(T,n,n); zeros(T,n,n) E']
LPS = schur(L,P)


3. MethodError: no method matching *(::LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}, ::LinearMaps.BlockMap{Bool, Tuple{LinearMaps.WrappedMap{Bool, Matrix{Bool}}, LinearMaps.UniformScalingMap{Bool}}, Tuple{Int64, Int64}})

n2 = n+n;
W = qr(Matrix([S; B; R]));
cond(W.R) * epsm  < 1 || error("The extended Hamiltonian/skew-Hamiltonian pencil is not regular")
z = W.Q*[fill(false,m,n2); I ]

4. MethodError: no method matching *(::LinearAlgebra.AdjointQ{Float64, LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}}, ::LinearMaps.BlockMap{Float64, Tuple{LinearMaps.WrappedMap{Float64, Matrix{Float64}}, LinearMaps.UniformScalingMap{Bool}, Vararg{LinearMaps.WrappedMap{Float64, Matrix{Float64}}, 4}}, Tuple{Int64, Int64}})
  
n2 = n+n;
F = qr([A'; -B'])
L2 = F.Q'*[-Q  E' -S; copy(S') zeros(T,m,n) R]

While with the current Julia version v1.9.3 there are no problems, I am afraid it will be not possible to register new versions of the package as soon as v1.10 will be the current version. Is there a realistic chance to get rid of these errors for the next Julia version or should I try to find a workarround in each case to avoid errors? Any suggestion in this respect is welcome.

@dkarrasch
Copy link
Contributor

I have launched the necessary PRs both in Julia Base/LinearAlgebra and LinearMaps.jl. For the time being, you could simply ignore CI on v1.10/nightly and release new versions as long as the older versions pass.

@franckgaga
Copy link
Author

It seems to work now on the beta channel of juliaup, that is v1.10.0-rc1. I will close the issue and you can re-open it if it comes back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants