Skip to content

Commit

Permalink
Add a simple mechanism to add passes to structural simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
BenChung committed Nov 13, 2024
1 parent b52bce7 commit f29b58f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/systems/systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ topological sort of the observed equations in `sys`.
+ `fully_determined=true` controls whether or not an error will be thrown if the number of equations don't match the number of inputs, outputs, and equations.
"""
function structural_simplify(
sys::AbstractSystem, io = nothing; simplify = false, split = true,
sys::AbstractSystem, io = nothing; additional_passes = [], simplify = false, split = true,
allow_symbolic = false, allow_parameter = true, conservative = false, fully_determined = true,
kwargs...)
isscheduled(sys) && throw(RepeatedStructuralSimplificationError())
Expand All @@ -49,6 +49,9 @@ function structural_simplify(
if newsys isa ODESystem || has_parent(newsys)
@set! newsys.parent = complete(sys; split, flatten = false)
end
for pass in additional_passes
newsys = pass(newsys)
end
newsys = complete(newsys; split)
if has_defaults(newsys) && (defs = get_defaults(newsys)) !== nothing
ks = collect(keys(defs)) # take copy to avoid mutating defs while iterating.
Expand Down

0 comments on commit f29b58f

Please sign in to comment.