@@ -1097,3 +1097,46 @@ function supports_initialization(sys::System)
1097
1097
return isempty (jumps (sys)) && _iszero (cost (sys)) &&
1098
1098
isempty (constraints (sys))
1099
1099
end
1100
+
1101
+ safe_eachrow (:: Nothing ) = nothing
1102
+ safe_eachrow (x:: AbstractArray ) = eachrow (x)
1103
+
1104
+ """
1105
+ $(TYPEDSIGNATURES)
1106
+
1107
+ Check if two systems are about equal, to the extent that ModelingToolkit.jl supports. Note
1108
+ that if this returns `true`, the systems are not guaranteed to be exactly equivalent
1109
+ (unless `sysa === sysb`) but are highly likely to represent a similar mathematical problem.
1110
+ If this returns `false`, the systems are very likely to be different.
1111
+ """
1112
+ function Base. isapprox (sysa:: System , sysb:: System )
1113
+ sysa === sysb && return true
1114
+ return nameof (sysa) == nameof (sysb) &&
1115
+ isequal (get_iv (sysa), get_iv (sysb)) &&
1116
+ issetequal (get_eqs (sysa), get_eqs (sysb)) &&
1117
+ issetequal (safe_eachrow (get_noise_eqs (sysa)), safe_eachrow (get_noise_eqs (sysb))) &&
1118
+ issetequal (get_jumps (sysa), get_jumps (sysb)) &&
1119
+ issetequal (get_constraints (sysa), get_constraints (sysb)) &&
1120
+ issetequal (get_costs (sysa), get_costs (sysb)) &&
1121
+ isequal (get_consolidate (sysa), get_consolidate (sysb)) &&
1122
+ issetequal (get_unknowns (sysa), get_unknowns (sysb)) &&
1123
+ issetequal (get_ps (sysa), get_ps (sysb)) &&
1124
+ issetequal (get_brownians (sysa), get_brownians (sysb)) &&
1125
+ issetequal (get_observed (sysa), get_observed (sysb)) &&
1126
+ issetequal (get_parameter_dependencies (sysa), get_parameter_dependencies (sysb)) &&
1127
+ isequal (get_description (sysa), get_description (sysb)) &&
1128
+ isequal (get_defaults (sysa), get_defaults (sysb)) &&
1129
+ isequal (get_guesses (sysa), get_guesses (sysb)) &&
1130
+ issetequal (get_initialization_eqs (sysa), get_initialization_eqs (sysb)) &&
1131
+ issetequal (get_continuous_events (sysa), get_continuous_events (sysb)) &&
1132
+ issetequal (get_discrete_events (sysa), get_discrete_events (sysb)) &&
1133
+ isequal (get_connector_type (sysa), get_connector_type (sysb)) &&
1134
+ isequal (get_assertions (sysa), get_assertions (sysb)) &&
1135
+ isequal (get_metadata (sysa), get_metadata (sysb)) &&
1136
+ isequal (get_is_dde (sysa), get_is_dde (sysb)) &&
1137
+ issetequal (get_tstops (sysa), get_tstops (sysb)) &&
1138
+ issetequal (get_ignored_connections (sysa), get_ignored_connections (sysb)) &&
1139
+ isequal (get_is_initializesystem (sysa), get_is_initializesystem (sysb)) &&
1140
+ isequal (get_is_discrete (sysa), get_is_discrete (sysb)) &&
1141
+ isequal (get_isscheduled (sysa), get_isscheduled (sysb))
1142
+ end
0 commit comments