Skip to content

Commit

Permalink
Merge pull request #3244 from AayushSabharwal/as/sde-observed-eqs
Browse files Browse the repository at this point in the history
fix: retain observed equations after `structural_simplify` of `SDESystem`
  • Loading branch information
ChrisRackauckas authored Nov 29, 2024
2 parents 1eda645 + 6729cda commit 8e48f65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/systems/systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ function __structural_simplify(sys::AbstractSystem, io = nothing; simplify = fal
noise_eqs = StructuralTransformations.tearing_substitute_expr(ode_sys, noise_eqs)
return SDESystem(full_equations(ode_sys), noise_eqs,
get_iv(ode_sys), unknowns(ode_sys), parameters(ode_sys);
name = nameof(ode_sys), is_scalar_noise)
name = nameof(ode_sys), is_scalar_noise, observed = observed(ode_sys))
end
end
10 changes: 10 additions & 0 deletions test/sdesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -799,3 +799,13 @@ end
prob = SDEProblem(sys, [], (0.0, 1.0), [])
@test_nowarn solve(prob, RKMil())
end

@testset "Observed variables retained after `structural_simplify`" begin
@variables x(t) y(t) z(t)
@brownian a
@mtkbuild sys = System([D(x) ~ x + a, D(y) ~ y + a, z ~ x + y], t)
@test sys isa SDESystem
@test length(observed(sys)) == 1
prob = SDEProblem(sys, [x => 1.0, y => 1.0], (0.0, 1.0))
@test prob[z] 2.0
end

0 comments on commit 8e48f65

Please sign in to comment.