Skip to content

Commit 8e48f65

Browse files
Merge pull request #3244 from AayushSabharwal/as/sde-observed-eqs
fix: retain observed equations after `structural_simplify` of `SDESystem`
2 parents 1eda645 + 6729cda commit 8e48f65

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/systems/systems.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,6 @@ function __structural_simplify(sys::AbstractSystem, io = nothing; simplify = fal
156156
noise_eqs = StructuralTransformations.tearing_substitute_expr(ode_sys, noise_eqs)
157157
return SDESystem(full_equations(ode_sys), noise_eqs,
158158
get_iv(ode_sys), unknowns(ode_sys), parameters(ode_sys);
159-
name = nameof(ode_sys), is_scalar_noise)
159+
name = nameof(ode_sys), is_scalar_noise, observed = observed(ode_sys))
160160
end
161161
end

test/sdesystem.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,3 +799,13 @@ end
799799
prob = SDEProblem(sys, [], (0.0, 1.0), [])
800800
@test_nowarn solve(prob, RKMil())
801801
end
802+
803+
@testset "Observed variables retained after `structural_simplify`" begin
804+
@variables x(t) y(t) z(t)
805+
@brownian a
806+
@mtkbuild sys = System([D(x) ~ x + a, D(y) ~ y + a, z ~ x + y], t)
807+
@test sys isa SDESystem
808+
@test length(observed(sys)) == 1
809+
prob = SDEProblem(sys, [x => 1.0, y => 1.0], (0.0, 1.0))
810+
@test prob[z] 2.0
811+
end

0 commit comments

Comments
 (0)