Skip to content

Commit

Permalink
Merge pull request #878 from AayushSabharwal/as/allow-scc-init
Browse files Browse the repository at this point in the history
feat: allow SCCNonlinearProblem in OverrideInit
  • Loading branch information
ChrisRackauckas authored Nov 26, 2024
2 parents 86e671e + 01c8d25 commit a5ee8e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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 @@ -472,7 +472,8 @@ mutable struct SCCNonlinearProblem{uType, iip, P, E, I, Par} <:

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 @@ function SymbolicIndexingInterface.parameter_values(prob::SCCNonlinearProblem)
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

0 comments on commit a5ee8e9

Please sign in to comment.