@@ -748,12 +748,14 @@ function update_simplified_system!(
748748 unknowns = [unknowns; extra_unknowns]
749749 @set! sys. unknowns = unknowns
750750
751- obs, subeqs, deps = cse_and_array_hacks (
752- sys, obs, solved_eqs, unknowns, neweqs; cse = cse_hack, array = array_hack)
751+ obs = cse_and_array_hacks (
752+ sys, obs, unknowns, neweqs; cse = cse_hack, array = array_hack)
753753
754+ deps = Vector{Int}[i == 1 ? Int[] : collect (1 : (i - 1 ))
755+ for i in 1 : length (solved_eqs)]
754756 @set! sys. eqs = neweqs
755757 @set! sys. observed = obs
756- @set! sys. substitutions = Substitutions (subeqs , deps)
758+ @set! sys. substitutions = Substitutions (solved_eqs , deps)
757759
758760 # Only makes sense for time-dependent
759761 # TODO : generalize to SDE
@@ -850,7 +852,7 @@ if all `p[i]` are present and the unscalarized form is used in any equation (obs
850852not) we first count the number of times the scalarized form of each observed variable
851853occurs in observed equations (and unknowns if it's split).
852854"""
853- function cse_and_array_hacks (sys, obs, subeqs, unknowns, neweqs; cse = true , array = true )
855+ function cse_and_array_hacks (sys, obs, unknowns, neweqs; cse = true , array = true )
854856 # HACK 1
855857 # mapping of rhs to temporary CSE variable
856858 # `f(...) => tmpvar` in above example
@@ -878,7 +880,6 @@ function cse_and_array_hacks(sys, obs, subeqs, unknowns, neweqs; cse = true, arr
878880 tempeq = tempvar ~ rhs_arr
879881 rhs_to_tempvar[rhs_arr] = tempvar
880882 push! (obs, tempeq)
881- push! (subeqs, tempeq)
882883 end
883884
884885 # getindex_wrapper is used because `observed2graph` treats `x` and `x[i]` as different,
@@ -887,10 +888,6 @@ function cse_and_array_hacks(sys, obs, subeqs, unknowns, neweqs; cse = true, arr
887888 neweq = lhs ~ getindex_wrapper (
888889 rhs_to_tempvar[rhs_arr], Tuple (arguments (rhs)[2 : end ]))
889890 obs[i] = neweq
890- subeqi = findfirst (isequal (eq), subeqs)
891- if subeqi != = nothing
892- subeqs[subeqi] = neweq
893- end
894891 end
895892 # end HACK 1
896893
@@ -920,7 +917,6 @@ function cse_and_array_hacks(sys, obs, subeqs, unknowns, neweqs; cse = true, arr
920917 tempeq = tempvar ~ rhs_arr
921918 rhs_to_tempvar[rhs_arr] = tempvar
922919 push! (obs, tempeq)
923- push! (subeqs, tempeq)
924920 end
925921 # don't need getindex_wrapper, but do it anyway to know that this
926922 # hack took place
@@ -960,15 +956,8 @@ function cse_and_array_hacks(sys, obs, subeqs, unknowns, neweqs; cse = true, arr
960956 push! (obs_arr_eqs, arrvar ~ rhs)
961957 end
962958 append! (obs, obs_arr_eqs)
963- append! (subeqs, obs_arr_eqs)
964-
965- # need to re-sort subeqs
966- subeqs = ModelingToolkit. topsort_equations (subeqs, [eq. lhs for eq in subeqs])
967-
968- deps = Vector{Int}[i == 1 ? Int[] : collect (1 : (i - 1 ))
969- for i in 1 : length (subeqs)]
970959
971- return obs, subeqs, deps
960+ return obs
972961end
973962
974963function is_getindexed_array (rhs)
0 commit comments