File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 110
110
@test val[] == 2
111
111
end
112
112
end
113
+
114
+ @testset " Do not codegen redundant expressions" begin
115
+ @variables v1 (t) = 1
116
+ @variables v2 (t) [guess = 0 ]
117
+
118
+ mutable struct Data
119
+ count:: Int
120
+ end
121
+ function update! (d:: Data , t)
122
+ d. count += 1 # Count the number of times the data gets updated.
123
+ end
124
+ function (d:: Data )(t)
125
+ update! (d, t)
126
+ rand (1 : 10 )
127
+ end
128
+
129
+ @parameters (d1:: Data )(.. ) = Data (0 )
130
+ @parameters (d2:: Data )(.. ) = Data (0 )
131
+
132
+ eqs = [
133
+ D (v1) ~ d1 (t),
134
+ v2 ~ d2 (t) # Some of the data parameters are not actually needed to solve the system.
135
+ ]
136
+
137
+ @mtkbuild sys = System (eqs, t)
138
+ prob = ODEProblem (sys, [], (0.0 , 1.0 ))
139
+ sol = solve (prob, Tsit5 ())
140
+
141
+ @test sol. ps[d2]. count == 0
142
+ end
You can’t perform that action at this time.
0 commit comments