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

feat: allow SCCNonlinearProblem in OverrideInit #878

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/initialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ struct OverrideInitData{IProb, UIProb, IProbMap, IProbPmap}

function OverrideInitData(initprob::I, update_initprob!::J, initprobmap::K,
initprobpmap::L) where {I, J, K, L}
@assert initprob isa Union{NonlinearProblem, NonlinearLeastSquaresProblem}
@assert initprob isa
Union{SCCNonlinearProblem, NonlinearProblem, NonlinearLeastSquaresProblem}
return new{I, J, K, L}(initprob, update_initprob!, initprobmap, initprobpmap)
end
end
Expand Down
6 changes: 4 additions & 2 deletions src/problems/nonlinear_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
!!! warn
While `explictfuns![i]` could in theory use `sols[i+1]` in its computation,
these values will not be updated. It is thus the contract of the interface
to not use those values except for as caches to be overriden.

Check warning on line 388 in src/problems/nonlinear_problems.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"overriden" should be "overridden".

!!! note
prob.probs[i].p can be aliased with each other as a performance / memory
Expand Down Expand Up @@ -472,7 +472,8 @@

function SCCNonlinearProblem{P, E, I, Par}(
probs::P, funs::E, indp::I, pobj::Par, alias::Bool) where {P, E, I, Par}
u0 = mapreduce(state_values, vcat, probs)
u0 = mapreduce(
state_values, vcat, probs; init = similar(state_values(first(probs)), 0))
uType = typeof(u0)
new{uType, false, P, E, I, Par}(probs, funs, indp, pobj, alias)
end
Expand Down Expand Up @@ -501,7 +502,8 @@
prob.parameter_object
end
function SymbolicIndexingInterface.state_values(prob::SCCNonlinearProblem)
mapreduce(state_values, vcat, prob.probs)
mapreduce(
state_values, vcat, prob.probs; init = similar(state_values(first(prob.probs)), 0))
end

function SymbolicIndexingInterface.set_state!(prob::SCCNonlinearProblem, val, idx)
Expand Down
Loading