SciML / SteadyStateDiffEq.jl

Solvers for steady states in scientific machine learning (SciML)
Other
30 stars 22 forks source link

Added abstol functionality #3

Closed rudrasohan closed 6 years ago

rudrasohan commented 6 years ago

I have added some functionality of abstol. with referrence to issue #228 solve(prob,SSRootfind(),abstol=1e-6) solve(prob,SSRootfind()) for default method I have tried out a few simple examples but the results were preety same for both the methods. Please do let me know if further changes are required.

ChrisRackauckas commented 6 years ago

Great! I will merge when tests pass.

rudrasohan commented 6 years ago

@ChrisRackauckas , I was checking the travis build and it was failing. So I found out that sol = solve(prob,SSRootfind(nlsolve = (f,u0) -> (res=NLsolve.nlsolve(f,u0,autodiff=true,method=:newton,iterations=Int(1e6));res.zero) )) the line of the test file was causing it . As i have changed the function definition of SSRootfind.

If I change it with the line sol = solve(prob,SSRootfind(nlsolve = (f,u0,abstol) -> (res=NLsolve.nlsolve(f,u0,autodiff=true,method=:newton,iterations=Int(1e6),ftol=abstol);res.zero) )) the errors vanish. So should I update the test as well ?

ChrisRackauckas commented 6 years ago

Yes

rudrasohan commented 6 years ago

There is some error related to Sundails. I think the new nlsolve method is causing some function type mismatches with the sundials package. ERROR: LoadError: MethodError: no method matching kinsol(::SteadyStateDiffEq.##9#13{DiffEqBase.SteadyStateProblem{Array{Float64,1},true,#f,UniformScaling{Int64}}}, ::Array{Float64,1}, ::Float64)

Closest candidates are: kinsol(::Any, ::Array{Float64,1}; userdata, linear_solver, jac_upper, jac_lower, stored_upper) at /home/travis/.julia/v0.6/Sundials/src/simple.jl:55

ChrisRackauckas commented 6 years ago

Yeah, Sundials cannot take an abstol so that test needs to be an anonymous function as well.

rudrasohan commented 6 years ago

I am testing an implementation on my local machine. sol = solve(prob,SSRootfind(nlsolve = (f,u0,abstol) -> (res=Sundials.kinsol(f,u0);res.zero) ))

I am getting the following error UndefVarError: libsundials_sunmatrixdense not defined .

The kinsol function definition kinsol(f, y0::Vector{Float64}; userdata::Any = nothing, linear_solver=:Dense, jac_upper=0, jac_lower=0, stored_upper = jac_upper + jac_lower) does not specify anything about this matrix.

ChrisRackauckas commented 6 years ago

You need to Pkg.build("Sundials"). That's an error due to the big version upgrade in Sundials.jl that just happened a last week.

rudrasohan commented 6 years ago

When trying to build Pkg.Sundials i'm getting a hash mismatch error. Hash Mismatch! Expected sha256: f34ad4faa4d0c9841e15348a48c8ab5780af56da23af9d46274192c6bbcf1049 Calculated sha256: 871fe23144f073aaae9c13c8f4f8a7d4b0193d347a09b6e13f289ce55fb1739d while loading /home/sohan/.julia/v0.6/Sundials/deps/build.jl, in expression starting on line 54

ChrisRackauckas commented 6 years ago

What operating system?

rudrasohan commented 6 years ago

Linux Ubuntu16.04(Xenial LTS) on julia v0.6

ChrisRackauckas commented 6 years ago

Are you on v1.0.0 of Sundials.jl? If so, then join the #bindeps2 channel on the slack and we need to find out what's going on. I just did the build on the same OS but a virtual machine and it was fine.

rudrasohan commented 6 years ago

@ChrisRackauckas is there any other way i can run the tests until the Sundials issue is resolved ?

ChrisRackauckas commented 6 years ago

The CI tests are automatically ran with each commit. I think this latest one will pass.

rudrasohan commented 6 years ago

There is still an error ERROR: LoadError: type Array has no field zero Stacktrace: [1] #solve#6(::Float64, ::Array{Any,1}, ::Function, ::DiffEqBase.SteadyStateProblem{Array{Float64,1},true,#f,UniformScaling{Int64}}, ::SteadyStateDiffEq.SSRootfind{##3#4}) at /home/travis/.julia/v0.6/SteadyStateDiffEq/src/solve.jl:30

Can you please help me regarding this, as without the test feature it might just take a lot more commits to correct it and then the pr would be flooded with commits.

rudrasohan commented 6 years ago

Thanks a lot. All the julia 0.6 tests passed. CI is showing error with the nightly build and v 0.5. Should we do somethig about it as I checked that even before this pr the v0.5 build was failing.

ChrisRackauckas commented 6 years ago

Thanks! Yes, v0.5 should be disabled and nightlies should be set to allow failures. v0.5 is too old so we don't even target that anymore. The nightlies are too unstable to attempt to keep working, and instead we upgrade when the version is released (so much less work!).