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