Skip to content

Commit f29b58f

Browse files
committed
Add a simple mechanism to add passes to structural simplify
1 parent b52bce7 commit f29b58f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/systems/systems.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ topological sort of the observed equations in `sys`.
2626
+ `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.
2727
"""
2828
function structural_simplify(
29-
sys::AbstractSystem, io = nothing; simplify = false, split = true,
29+
sys::AbstractSystem, io = nothing; additional_passes = [], simplify = false, split = true,
3030
allow_symbolic = false, allow_parameter = true, conservative = false, fully_determined = true,
3131
kwargs...)
3232
isscheduled(sys) && throw(RepeatedStructuralSimplificationError())
@@ -49,6 +49,9 @@ function structural_simplify(
4949
if newsys isa ODESystem || has_parent(newsys)
5050
@set! newsys.parent = complete(sys; split, flatten = false)
5151
end
52+
for pass in additional_passes
53+
newsys = pass(newsys)
54+
end
5255
newsys = complete(newsys; split)
5356
if has_defaults(newsys) && (defs = get_defaults(newsys)) !== nothing
5457
ks = collect(keys(defs)) # take copy to avoid mutating defs while iterating.

0 commit comments

Comments
 (0)