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

Errors when testing the Thermostat tutorial problem #750

Closed
gkaf89 opened this issue Nov 6, 2023 · 6 comments
Closed

Errors when testing the Thermostat tutorial problem #750

gkaf89 opened this issue Nov 6, 2023 · 6 comments

Comments

@gkaf89
Copy link

gkaf89 commented Nov 6, 2023

I am trying to test the Thermostat problem from the tutorial, but it fails with errors during precompilation. Is this a bug?

Reproducing the behavior

  1. Create a Conda environment for Julia with micromamba.
    • micromamba env create --name julia
    • micromamba activate julia
    • micromamba install --channel conda-forge julia
    • Version 1.9.3 installed
  2. Create a project environment for the tutorial with Julia:
    • pkg> activate Tutorial
    • pkg> add ReachabilityAnalysis, ModelingToolkit
    • ReachabilityAnalysis version: v0.22.1
    • ModelingToolkit version: v8.70.0

At this point the packages that fail to compile are:

  • SimpleNonlinearSolve
  • NonlinearSolve
  • OrdinaryDiffEq
  • ModelingToolkit

Error messages

If I try to run the tutorial problem, I get the following error message when running from the project directory:

$ julia --interactive --project=. Thermostat.jl                                                                                                                                                                                            [373/1049]
ERROR: LoadError: UndefVarError: `NonlinearLeastSquaresProblem` not defined    
Stacktrace:                                                                    
 [1] top-level scope                                                           
   @ ~/micromamba/envs/julia/share/julia/packages/SimpleNonlinearSolve/nusbP/src/raphson.jl:66                                                                
 [2] include(mod::Module, _path::String)                                       
   @ Base ./Base.jl:457                                                        
 [3] include(x::String)                                                        
   @ SimpleNonlinearSolve ~/micromamba/envs/julia/share/julia/packages/SimpleNonlinearSolve/nusbP/src/SimpleNonlinearSolve.jl:1                               
 [4] top-level scope                                                           
   @ ~/micromamba/envs/julia/share/julia/packages/SimpleNonlinearSolve/nusbP/src/SimpleNonlinearSolve.jl:30                                                   
 [5] include                                                                   
   @ ./Base.jl:457 [inlined]                                                   
 [6] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
   @ Base ./loading.jl:2049                                                    
 [7] top-level scope                                                           
   @ stdin:3                                                                   
in expression starting at /home/gkaf/micromamba/envs/julia/share/julia/packages/SimpleNonlinearSolve/nusbP/src/raphson.jl:66                                  
in expression starting at /home/gkaf/micromamba/envs/julia/share/julia/packages/SimpleNonlinearSolve/nusbP/src/SimpleNonlinearSolve.jl:1                      
in expression starting at stdin:3                                              
ERROR: LoadError: Failed to precompile SimpleNonlinearSolve [727e6d20-b764-4bd8-a329-72de5adea6c7] to "/home/gkaf/micromamba/envs/julia/share/julia/compiled/v1.9/SimpleNonlinearSolve/jl_S3r7y0".
Stacktrace:                                                                    
  [1] error(s::String)                                                         
    @ Base ./error.jl:35                                                       
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)                                        
    @ Base ./loading.jl:2300                                                   
  [3] compilecache                                                             
    @ ./loading.jl:2167 [inlined]                                              
  [4] _require(pkg::Base.PkgId, env::String)                                   
    @ Base ./loading.jl:1805                                                   
  [5] _require_prelocked(uuidkey::Base.PkgId, env::String)                     
    @ Base ./loading.jl:1660                                                   
  [6] macro expansion                                                          
    @ ./loading.jl:1648 [inlined]                                              
  [7] macro expansion                                                          
    @ ./lock.jl:267 [inlined]                                                  
  [8] require(into::Module, mod::Symbol)                                       
    @ Base ./loading.jl:1611                                                   
  [9] include                                                                  
    @ ./Base.jl:457 [inlined]                                                  
 [10] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
    @ Base ./loading.jl:2049                                                   
 [11] top-level scope                                                          
    @ stdin:3                                                                  
in expression starting at /home/gkaf/micromamba/envs/julia/share/julia/packages/OrdinaryDiffEq/JJd6g/src/OrdinaryDiffEq.jl:1                                  
in expression starting at stdin:3                                              
ERROR: LoadError: Failed to precompile OrdinaryDiffEq [1dea7af3-3e70-54e6-95c3-0bf5283fa5ed] to "/home/gkaf/micromamba/envs/julia/share/julia/compiled/v1.9/OrdinaryDiffEq/jl_CuyzRV".
Stacktrace:                                                                    
  [1] error(s::String)                                                         
    @ Base ./error.jl:35                                                       
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)                                        
    @ Base ./loading.jl:2300                                                   
  [3] compilecache                                                             
    @ ./loading.jl:2167 [inlined]                                              
  [4] _require(pkg::Base.PkgId, env::String)                                   
    @ Base ./loading.jl:1805                                                   
  [5] _require_prelocked(uuidkey::Base.PkgId, env::String)                     
    @ Base ./loading.jl:1660                                                   
  [6] macro expansion                                                          
    @ ./loading.jl:1648 [inlined]                                              
  [7] macro expansion                                                          
    @ ./lock.jl:267 [inlined]                                                  
  [8] require(into::Module, mod::Symbol)                                       
    @ Base ./loading.jl:1611                                                   
  [9] include(mod::Module, _path::String)                                      
    @ Base ./Base.jl:457                                                       
 [10] include(x::String)                                                       
    @ ModelingToolkit ~/micromamba/envs/julia/share/julia/packages/ModelingToolkit/BsHty/src/ModelingToolkit.jl:4                                             
 [11] top-level scope                                                          
    @ ~/micromamba/envs/julia/share/julia/packages/ModelingToolkit/BsHty/src/ModelingToolkit.jl:128                                                           
 [12] include                                                                  
    @ ./Base.jl:457 [inlined]                                                  
 [13] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
    @ Base ./loading.jl:2049                                                   
 [14] top-level scope                                                          
    @ stdin:3                                                                  
in expression starting at /home/gkaf/micromamba/envs/julia/share/julia/packages/ModelingToolkit/BsHty/src/systems/abstractsystem.jl:1
in expression starting at /home/gkaf/micromamba/envs/julia/share/julia/packages/ModelingToolkit/BsHty/src/ModelingToolkit.jl:1                                
in expression starting at stdin:3                                              
ERROR: LoadError: Failed to precompile ModelingToolkit [961ee093-0014-501f-94e3-6117800e7a78] to "/home/gkaf/micromamba/envs/julia/share/julia/compiled/v1.9/ModelingToolkit/jl_5Cs96w".
Stacktrace:                                                                    
 [1] error(s::String)                                                          
   @ Base ./error.jl:35                                                        
 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)                                         
   @ Base ./loading.jl:2300                                                    
 [3] compilecache                                                              
   @ ./loading.jl:2167 [inlined]                                               
 [4] _require(pkg::Base.PkgId, env::String)                                    
   @ Base ./loading.jl:1805                                                    
 [5] _require_prelocked(uuidkey::Base.PkgId, env::String)                      
   @ Base ./loading.jl:1660                                                    
 [6] macro expansion                                                           
   @ ./loading.jl:1648 [inlined]                                               
 [7] macro expansion                                                           
   @ ./lock.jl:267 [inlined]                                                   
 [8] require(into::Module, mod::Symbol)                                        
   @ Base ./loading.jl:1611                                                    
in expression starting at /home/gkaf/Documents/repositories/Research/gaussian_regression/Reach/Thermostat.jl:1

The content of the thermostat file is:

module thermostat

using ReachabilityAnalysis, ModelingToolkit

const A1 = 40.0
const A2 = 30.0
const B = 0.5
const t1 = 75
const t2 = 65

const var = @variables t

function thermostat_on()
    invariant = HalfSpace(t <= t1)
    @system(x' = -Bx + A1, x  invariant)
end

function thermostat_off()
    invariant = HalfSpace(t >= t2)
    @system(x' = -Bx + A2, x  invariant)
end

function thermostat_hybrid()
    automaton = GraphAutomaton(2)
    add_transition!(automaton, 1, 2, 1)
    add_transition!(automaton, 2, 1, 2)

    mode1 = thermostat_on()
    mode2 = thermostat_off()
    modes = [mode1, mode2]

    # transition on -> off
    guard = HalfSpace(t >= t1)
    trans1 = ConstrainedIdentityMap(1, guard)
    # transition off -> on
    guard = HalfSpace(t <= t2)
    trans2 = ConstrainedIdentityMap(1, guard)
    resetmaps = [trans1, trans2]

    return HybridSystem(automaton, modes, resetmaps, [AutonomousSwitching()])
end

function model(X0)
    H = thermostat_hybrid()
    return IVP(H, X0)
end

end  # module
@schillic
Copy link
Member

schillic commented Nov 6, 2023

As you say, these other packages fail to compile. We cannot do anything about that. NonlinearLeastSquaresProblem seems to have been added in SciML/SimpleNonlinearSolve.jl#91. Please report the issue in that repository.

@gkaf89
Copy link
Author

gkaf89 commented Nov 7, 2023

Thank you, I will monitor the issue in SciML and close the issue when it is resolved.

@mforets
Copy link
Member

mforets commented Nov 24, 2023

Hey @gkaf89 shall we close this, or is the issue still present?

@gkaf89
Copy link
Author

gkaf89 commented Nov 28, 2023

No, tested again with the latest package versions, and the issue is still present. I will try to look into a solution as soon as I get the chance.

@schillic
Copy link
Member

schillic commented Jan 4, 2024

@gkaf89: I found that one of our dependencies held back some other central package, which was likely the reason why you had to use such an old version of SimpleNonlinearSolve. I just fixed that. Here is the result of up'ing the packages:

 SimpleNonlinearSolve v0.1.23  v1.2.0

I suggest you try again now.

@gkaf89
Copy link
Author

gkaf89 commented Feb 17, 2024

Hello, I have tested with version 1.2.0 of SimpleNonlinearSolve, and the tutorial loads and runs successfully.

Thank you very much!

@gkaf89 gkaf89 closed this as completed Feb 17, 2024
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