@@ -190,6 +190,16 @@ struct System <: AbstractSystem
190190 """
191191 tstops:: Vector{Any}
192192 """
193+ $INTERNAL_FIELD_WARNING
194+ The list of input variables of the system.
195+ """
196+ inputs:: Set{BasicSymbolic}
197+ """
198+ $INTERNAL_FIELD_WARNING
199+ The list of output variables of the system.
200+ """
201+ outputs:: Set{BasicSymbolic}
202+ """
193203 The `TearingState` of the system post-simplification with `mtkcompile`.
194204 """
195205 tearing_state:: Any
@@ -255,8 +265,9 @@ struct System <: AbstractSystem
255265 brownians, iv, observed, parameter_dependencies, var_to_name, name, description,
256266 defaults, guesses, systems, initialization_eqs, continuous_events, discrete_events,
257267 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 ,
260271 complete = false , index_cache = nothing , ignored_connections = nothing ,
261272 preface = nothing , parent = nothing , initializesystem = nothing ,
262273 is_initializesystem = false , is_discrete = false , isscheduled = false ,
@@ -296,7 +307,8 @@ struct System <: AbstractSystem
296307 observed, parameter_dependencies, var_to_name, name, description, defaults,
297308 guesses, systems, initialization_eqs, continuous_events, discrete_events,
298309 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,
300312 preface, parent, initializesystem, is_initializesystem, is_discrete,
301313 isscheduled, schedule)
302314 end
@@ -367,15 +379,27 @@ function System(eqs::Vector{Equation}, iv, dvs, ps, brownians = [];
367379
368380 defaults = anydict (defaults)
369381 guesses = anydict (guesses)
382+ inputs = Set {BasicSymbolic} ()
383+ outputs = Set {BasicSymbolic} ()
370384 var_to_name = anydict ()
371385
372386 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 ()
374390
375391 process_variables! (var_to_name, defaults, guesses, dvs)
376392 process_variables! (var_to_name, defaults, guesses, ps)
377393 process_variables! (var_to_name, defaults, guesses, [eq. lhs for eq in observed])
378394 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
379403 end
380404 filter! (! (isnothing ∘ last), defaults)
381405 filter! (! (isnothing ∘ last), guesses)
@@ -416,7 +440,8 @@ function System(eqs::Vector{Equation}, iv, dvs, ps, brownians = [];
416440 costs, consolidate, dvs, ps, brownians, iv, observed, Equation[],
417441 var_to_name, name, description, defaults, guesses, systems, initialization_eqs,
418442 continuous_events, discrete_events, connector_type, assertions, metadata, gui_metadata, is_dde,
419- tstops, tearing_state, true , false , nothing , ignored_connections, preface, parent,
443+ tstops, inputs, outputs, tearing_state, true , false ,
444+ nothing , ignored_connections, preface, parent,
420445 initializesystem, is_initializesystem, is_discrete; checks)
421446end
422447
@@ -1141,6 +1166,8 @@ function Base.isapprox(sysa::System, sysb::System)
11411166 isequal (get_metadata (sysa), get_metadata (sysb)) &&
11421167 isequal (get_is_dde (sysa), get_is_dde (sysb)) &&
11431168 issetequal (get_tstops (sysa), get_tstops (sysb)) &&
1169+ issetequal (get_inputs (sysa), get_inputs (sysb)) &&
1170+ issetequal (get_outputs (sysa), get_outputs (sysb)) &&
11441171 safe_issetequal (get_ignored_connections (sysa), get_ignored_connections (sysb)) &&
11451172 isequal (get_is_initializesystem (sysa), get_is_initializesystem (sysb)) &&
11461173 isequal (get_is_discrete (sysa), get_is_discrete (sysb)) &&
0 commit comments