Skip to content

Commit d68cc62

Browse files
committed
Add test that requires substitution of chained observeds
1 parent 7d9d1fd commit d68cc62

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/nonlinearsystem.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,13 @@ sys = structural_simplify(ns; conservative = true)
306306
prob = NonlinearProblem(ns, guesses, ps, jac = true)
307307
sol = solve(prob, NewtonRaphson())
308308
@test sol.retcode == ReturnCode.Success
309+
310+
# system that contains a chain of observed variables when simplified
311+
@variables x y z
312+
eqs = [0 ~ x^2 + 2*z + y, z ~ y, y ~ x] # analytical solution x = y = z = 0 or -3
313+
@mtkbuild ns = NonlinearSystem(eqs) # solve for y with observed chain z -> x -> y
314+
@test isequal(expand.(calculate_jacobian(ns)), [3//2 + y;;])
315+
prob = NonlinearProblem(ns, unknowns(ns) .=> -4.0) # give guess < -3 to reach -3
316+
sol = solve(prob, NewtonRaphson())
317+
@test sol[x] sol[y] sol[z] -3
309318
end

0 commit comments

Comments
 (0)