-
-
Notifications
You must be signed in to change notification settings - Fork 47
Support LinearProblems in SCCs #633
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
Conversation
du[1]=cos(u[2])-u[1] | ||
du[2]=sin(u[1]+u[2])+u[2] | ||
du[3]=2u[4]+u[3]+1.0 | ||
du[4]=u[5]^2+u[4] | ||
du[5]=u[3]^2+u[5] | ||
du[6]=u[1]+u[2]+u[3]+u[4]+u[5]+2.0u[6]+2.5u[7]+1.5u[8] | ||
du[7]=u[1]+u[2]+u[3]+2.0u[4]+u[5]+4.0u[6]-1.5u[7]+1.5u[8] | ||
du[8]=u[1]+2.0u[2]+3.0u[3]+5.0u[4]+6.0u[5]+u[6]-u[7]-u[8] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
du[1]=cos(u[2])-u[1] | |
du[2]=sin(u[1]+u[2])+u[2] | |
du[3]=2u[4]+u[3]+1.0 | |
du[4]=u[5]^2+u[4] | |
du[5]=u[3]^2+u[5] | |
du[6]=u[1]+u[2]+u[3]+u[4]+u[5]+2.0u[6]+2.5u[7]+1.5u[8] | |
du[7]=u[1]+u[2]+u[3]+2.0u[4]+u[5]+4.0u[6]-1.5u[7]+1.5u[8] | |
du[8]=u[1]+2.0u[2]+3.0u[3]+5.0u[4]+6.0u[5]+u[6]-u[7]-u[8] | |
du[1] = cos(u[2]) - u[1] | |
du[2] = sin(u[1] + u[2]) + u[2] | |
du[3] = 2u[4] + u[3] + 1.0 | |
du[4] = u[5]^2 + u[4] | |
du[5] = u[3]^2 + u[5] | |
du[6] = u[1] + u[2] + u[3] + u[4] + u[5] + 2.0u[6] + 2.5u[7] + 1.5u[8] | |
du[7] = u[1] + u[2] + u[3] + 2.0u[4] + u[5] + 4.0u[6] - 1.5u[7] + 1.5u[8] | |
du[8] = u[1] + 2.0u[2] + 3.0u[3] + 5.0u[4] + 6.0u[5] + u[6] - u[7] - u[8] |
prob=NonlinearProblem(f, zeros(8)) | ||
sol=solve(prob, NewtonRaphson()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
prob=NonlinearProblem(f, zeros(8)) | |
sol=solve(prob, NewtonRaphson()) | |
prob = NonlinearProblem(f, zeros(8)) | |
sol = solve(prob, NewtonRaphson()) |
u0=zeros(2) | ||
p=zeros(3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
u0=zeros(2) | |
p=zeros(3) | |
u0 = zeros(2) | |
p = zeros(3) |
du[1]=cos(u[2])-u[1] | ||
du[2]=sin(u[1]+u[2])+u[2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
du[1]=cos(u[2])-u[1] | |
du[2]=sin(u[1]+u[2])+u[2] | |
du[1] = cos(u[2]) - u[1] | |
du[2] = sin(u[1] + u[2]) + u[2] |
explicitfun1(p, sols)=nothing | ||
prob1=NonlinearProblem( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
explicitfun1(p, sols)=nothing | |
prob1=NonlinearProblem( | |
explicitfun1(p, sols) = nothing | |
prob1 = NonlinearProblem( |
A3=[2.0 2.5 1.5; 4.0 -1.5 1.5; 1.0 -1.0 -1.0] | ||
b3=p # b will be updated by explicitfun3 | ||
prob3=LinearProblem(A3, b3, zeros(3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
A3=[2.0 2.5 1.5; 4.0 -1.5 1.5; 1.0 -1.0 -1.0] | |
b3=p # b will be updated by explicitfun3 | |
prob3=LinearProblem(A3, b3, zeros(3)) | |
A3 = [2.0 2.5 1.5; 4.0 -1.5 1.5; 1.0 -1.0 -1.0] | |
b3 = p # b will be updated by explicitfun3 | |
prob3 = LinearProblem(A3, b3, zeros(3)) |
p[1]=-(sols[1][1]+sols[1][2]+sols[2][1]+sols[2][2]+sols[2][3]) | ||
p[2]=-(sols[1][1]+sols[1][2]+sols[2][1]+2.0sols[2][2]+sols[2][3]) | ||
p[3]=-(sols[1][1]+2.0sols[1][2]+3.0sols[2][1]+5.0sols[2][2]+ | ||
6.0sols[2][3]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
p[1]=-(sols[1][1]+sols[1][2]+sols[2][1]+sols[2][2]+sols[2][3]) | |
p[2]=-(sols[1][1]+sols[1][2]+sols[2][1]+2.0sols[2][2]+sols[2][3]) | |
p[3]=-(sols[1][1]+2.0sols[1][2]+3.0sols[2][1]+5.0sols[2][2]+ | |
6.0sols[2][3]) | |
p[1] = -(sols[1][1] + sols[1][2] + sols[2][1] + sols[2][2] + sols[2][3]) | |
p[2] = -(sols[1][1] + sols[1][2] + sols[2][1] + 2.0sols[2][2] + sols[2][3]) | |
p[3] = -(sols[1][1] + 2.0sols[1][2] + 3.0sols[2][1] + 5.0sols[2][2] + | |
6.0sols[2][3]) |
sol3=solve(prob3) # LinearProblem uses default linear solver | ||
manualscc=reduce(vcat, (sol1, sol2, sol3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
sol3=solve(prob3) # LinearProblem uses default linear solver | |
manualscc=reduce(vcat, (sol1, sol2, sol3)) | |
sol3 = solve(prob3) # LinearProblem uses default linear solver | |
manualscc = reduce(vcat, (sol1, sol2, sol3)) |
|
||
sccprob = SciMLBase.SCCNonlinearProblem([prob1, prob2, prob3], | ||
sccprob=SciMLBase.SCCNonlinearProblem((prob1, prob2, prob3), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
sccprob=SciMLBase.SCCNonlinearProblem((prob1, prob2, prob3), | |
sccprob = SciMLBase.SCCNonlinearProblem((prob1, prob2, prob3), |
scc_alg=SCCNonlinearSolve.SCCAlg(nlalg = NewtonRaphson(), linalg = nothing) | ||
scc_sol=solve(sccprob, scc_alg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
scc_alg=SCCNonlinearSolve.SCCAlg(nlalg = NewtonRaphson(), linalg = nothing) | |
scc_sol=solve(sccprob, scc_alg) | |
scc_alg = SCCNonlinearSolve.SCCAlg(nlalg = NewtonRaphson(), linalg = nothing) | |
scc_sol = solve(sccprob, scc_alg) |
@test sol ≈ manualscc ≈ scc_sol | ||
|
||
# Backwards compat of alg choice | ||
scc_sol=solve(sccprob, NewtonRaphson()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
scc_sol=solve(sccprob, NewtonRaphson()) | |
scc_sol = solve(sccprob, NewtonRaphson()) |
scc_sol = solve(sccprob) | ||
@test sol ≈ manualscc ≈ scc_sol | ||
# Test default interface | ||
scc_sol_default=solve(sccprob) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
scc_sol_default=solve(sccprob) | |
scc_sol_default = solve(sccprob) |
if !SciMLBase.successful_retcode(_sol) | ||
break | ||
end | ||
function CommonSolve.solve(prob::SciMLBase.SCCNonlinearProblem, alg::SciMLBase.AbstractNonlinearAlgorithm; kwargs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function CommonSolve.solve(prob::SciMLBase.SCCNonlinearProblem, alg::SciMLBase.AbstractNonlinearAlgorithm; kwargs...) | |
function CommonSolve.solve(prob::SciMLBase.SCCNonlinearProblem, | |
alg::SciMLBase.AbstractNonlinearAlgorithm; kwargs...) |
No description provided.