@@ -190,6 +190,16 @@ struct System <: IntermediateDeprecationSystem
190
190
"""
191
191
tstops:: Vector{Any}
192
192
"""
193
+ $INTERNAL_FIELD_WARNING
194
+ The list of input variables of the system.
195
+ """
196
+ inputs:: OrderedSet{BasicSymbolic}
197
+ """
198
+ $INTERNAL_FIELD_WARNING
199
+ The list of output variables of the system.
200
+ """
201
+ outputs:: OrderedSet{BasicSymbolic}
202
+ """
193
203
The `TearingState` of the system post-simplification with `mtkcompile`.
194
204
"""
195
205
tearing_state:: Any
@@ -255,8 +265,9 @@ struct System <: IntermediateDeprecationSystem
255
265
brownians, iv, observed, parameter_dependencies, var_to_name, name, description,
256
266
defaults, guesses, systems, initialization_eqs, continuous_events, discrete_events,
257
267
connector_type, assertions = Dict {BasicSymbolic, String} (),
258
- metadata = MetadataT (), gui_metadata = nothing ,
259
- is_dde = false , tstops = [], tearing_state = nothing , namespacing = true ,
268
+ metadata = MetadataT (), gui_metadata = nothing , is_dde = false , tstops = [],
269
+ inputs = Set {BasicSymbolic} (), outputs = Set {BasicSymbolic} (),
270
+ tearing_state = nothing , namespacing = true ,
260
271
complete = false , index_cache = nothing , ignored_connections = nothing ,
261
272
preface = nothing , parent = nothing , initializesystem = nothing ,
262
273
is_initializesystem = false , is_discrete = false , isscheduled = false ,
@@ -296,7 +307,8 @@ struct System <: IntermediateDeprecationSystem
296
307
observed, parameter_dependencies, var_to_name, name, description, defaults,
297
308
guesses, systems, initialization_eqs, continuous_events, discrete_events,
298
309
connector_type, assertions, metadata, gui_metadata, is_dde,
299
- tstops, tearing_state, namespacing, complete, index_cache, ignored_connections,
310
+ tstops, inputs, outputs, tearing_state, namespacing,
311
+ complete, index_cache, ignored_connections,
300
312
preface, parent, initializesystem, is_initializesystem, is_discrete,
301
313
isscheduled, schedule)
302
314
end
@@ -367,15 +379,27 @@ function System(eqs::Vector{Equation}, iv, dvs, ps, brownians = [];
367
379
368
380
defaults = anydict (defaults)
369
381
guesses = anydict (guesses)
382
+ inputs = Set {BasicSymbolic} ()
383
+ outputs = Set {BasicSymbolic} ()
370
384
var_to_name = anydict ()
371
385
372
386
let defaults = discover_from_metadata ? defaults : Dict (),
373
- guesses = discover_from_metadata ? guesses : Dict ()
387
+ guesses = discover_from_metadata ? guesses : Dict (),
388
+ inputs = discover_from_metadata ? inputs : Set (),
389
+ outputs = discover_from_metadata ? outputs : Set ()
374
390
375
391
process_variables! (var_to_name, defaults, guesses, dvs)
376
392
process_variables! (var_to_name, defaults, guesses, ps)
377
393
process_variables! (var_to_name, defaults, guesses, [eq. lhs for eq in observed])
378
394
process_variables! (var_to_name, defaults, guesses, [eq. rhs for eq in observed])
395
+
396
+ for var in dvs
397
+ if isinput (var)
398
+ push! (inputs, var)
399
+ elseif isoutput (var)
400
+ push! (outputs, var)
401
+ end
402
+ end
379
403
end
380
404
filter! (! (isnothing ∘ last), defaults)
381
405
filter! (! (isnothing ∘ last), guesses)
@@ -417,7 +441,8 @@ function System(eqs::Vector{Equation}, iv, dvs, ps, brownians = [];
417
441
costs, consolidate, dvs, ps, brownians, iv, observed, Equation[],
418
442
var_to_name, name, description, defaults, guesses, systems, initialization_eqs,
419
443
continuous_events, discrete_events, connector_type, assertions, metadata, gui_metadata, is_dde,
420
- tstops, tearing_state, true , false , nothing , ignored_connections, preface, parent,
444
+ tstops, inputs, outputs, tearing_state, true , false ,
445
+ nothing , ignored_connections, preface, parent,
421
446
initializesystem, is_initializesystem, is_discrete; checks)
422
447
end
423
448
@@ -1143,6 +1168,8 @@ function Base.isapprox(sysa::System, sysb::System)
1143
1168
isequal (get_metadata (sysa), get_metadata (sysb)) &&
1144
1169
isequal (get_is_dde (sysa), get_is_dde (sysb)) &&
1145
1170
issetequal (get_tstops (sysa), get_tstops (sysb)) &&
1171
+ issetequal (get_inputs (sysa), get_inputs (sysb)) &&
1172
+ issetequal (get_outputs (sysa), get_outputs (sysb)) &&
1146
1173
safe_issetequal (get_ignored_connections (sysa), get_ignored_connections (sysb)) &&
1147
1174
isequal (get_is_initializesystem (sysa), get_is_initializesystem (sysb)) &&
1148
1175
isequal (get_is_discrete (sysa), get_is_discrete (sysb)) &&
0 commit comments