Skip to content

feat: make nlprobmap in-place #3832

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

Merged
merged 2 commits into from
Jul 18, 2025
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ RecursiveArrayTools = "3.26"
Reexport = "0.2, 1"
RuntimeGeneratedFunctions = "0.5.9"
SCCNonlinearSolve = "1.0.0"
SciMLBase = "2.100.0"
SciMLBase = "2.104.0"
SciMLPublic = "1.0.0"
SciMLStructures = "1.7"
Serialization = "1"
Expand Down
18 changes: 17 additions & 1 deletion src/systems/solver_nlprob.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function generate_ODENLStepData(sys::System, u0, p, mm = calculate_massmatrix(sy
set_gamma_c = setsym(nlsys, (ODE_GAMMA..., ODE_C))
set_outer_tmp = setsym(nlsys, outer_tmp)
set_inner_tmp = setsym(nlsys, inner_tmp)
nlprobmap = getsym(nlsys, unknowns(sys))
nlprobmap = generate_nlprobmap(sys, nlsys)

return SciMLBase.ODENLStepData(nlprob, subsetidxs, set_gamma_c, set_outer_tmp, set_inner_tmp, nlprobmap)
end
Expand Down Expand Up @@ -58,3 +58,19 @@ function inner_nlsystem(sys::System, mm)
nlsys = mtkcompile(System(new_eqs, new_dvs, new_ps; name = :nlsys); split = is_split(sys))
return nlsys, outer_tmp, inner_tmp
end

struct NLStep_probmap{F}
f::F
end

function (nlp::NLStep_probmap)(buffer, nlsol)
nlp.f(buffer, state_values(nlsol), parameter_values(nlsol))
end

function (nlp::NLStep_probmap)(nlsol)
nlp.f(state_values(nlsol), parameter_values(nlsol))
end

function generate_nlprobmap(sys::System, nlsys::System)
return NLStep_probmap(build_explicit_observed_function(nlsys, unknowns(sys)))
end
Loading