@@ -1397,9 +1397,34 @@ function assertions(sys::AbstractSystem)
13971397 return merge (asserts, namespaced_asserts)
13981398end
13991399
1400+ """
1401+ $(TYPEDEF)
1402+
1403+ Information about an `AnalysisPoint` for which the corresponding connection must be
1404+ ignored during `expand_connections`, since the analysis point has been transformed.
1405+
1406+ # Fields
1407+
1408+ $(TYPEDFIELDS)
1409+ """
1410+ struct IgnoredAnalysisPoint
1411+ """
1412+ The input variable/connector.
1413+ """
1414+ input:: Union{BasicSymbolic, AbstractSystem}
1415+ """
1416+ The output variables/connectors.
1417+ """
1418+ outputs:: Vector{Union{BasicSymbolic, AbstractSystem}}
1419+ end
1420+
14001421const HierarchyVariableT = Vector{Union{BasicSymbolic, Symbol}}
14011422const HierarchySystemT = Vector{Union{AbstractSystem, Symbol}}
14021423"""
1424+ The type returned from `analysis_point_common_hierarchy`.
1425+ """
1426+ const HierarchyAnalysisPointT = Vector{Union{IgnoredAnalysisPoint, Symbol}}
1427+ """
14031428The type returned from `as_hierarchy`.
14041429"""
14051430const HierarchyT = Union{HierarchyVariableT, HierarchySystemT}
@@ -1416,6 +1441,29 @@ function from_hierarchy(hierarchy::HierarchyT)
14161441 end
14171442end
14181443
1444+ """
1445+ $(TYPEDSIGNATURES)
1446+
1447+ Represent an ignored analysis point as a namespaced hierarchy. The hierarchy is built
1448+ using the common hierarchy of all involved systems/variables.
1449+ """
1450+ function analysis_point_common_hierarchy (ap:: IgnoredAnalysisPoint ):: HierarchyAnalysisPointT
1451+ isys = as_hierarchy (ap. input)
1452+ osyss = as_hierarchy .(ap. outputs)
1453+ suffix = Symbol[]
1454+ while isys[end ] == osyss[1 ][end ] && allequal (last .(osyss))
1455+ push! (suffix, isys[end ])
1456+ pop! (isys)
1457+ pop! .(osyss)
1458+ end
1459+ isys = from_hierarchy (isys)
1460+ osyss = from_hierarchy .(osyss)
1461+ newap = IgnoredAnalysisPoint (isys, osyss)
1462+ hierarchy = HierarchyAnalysisPointT ([suffix; newap])
1463+ reverse! (hierarchy)
1464+ return hierarchy
1465+ end
1466+
14191467"""
14201468 $(TYPEDSIGNATURES)
14211469
@@ -1442,19 +1490,20 @@ end
14421490"""
14431491 $(TYPEDSIGNATURES)
14441492
1445- Get the connections to ignore for `sys` and its subsystems. The returned value is a
1446- `Tuple` similar in structure to the `ignored_connections` field. Each system (variable)
1447- in the first (second) element of the tuple is also passed through `as_hierarchy`.
1493+ Get the analysis points to ignore for `sys` and its subsystems. The returned value is a
1494+ `Tuple` similar in structure to the `ignored_connections` field.
14481495"""
14491496function ignored_connections (sys:: AbstractSystem )
1450- has_ignored_connections (sys) || return (HierarchySystemT[], HierarchyVariableT[])
1497+ has_ignored_connections (sys) ||
1498+ return (HierarchyAnalysisPointT[], HierarchyAnalysisPointT[])
14511499
14521500 ics = get_ignored_connections (sys)
14531501 if ics === nothing
1454- ics = (HierarchySystemT [], HierarchyVariableT [])
1502+ ics = (HierarchyAnalysisPointT [], HierarchyAnalysisPointT [])
14551503 end
14561504 # turn into hierarchies
1457- ics = (map (as_hierarchy, ics[1 ]), map (as_hierarchy, ics[2 ]))
1505+ ics = (map (analysis_point_common_hierarchy, ics[1 ]),
1506+ map (analysis_point_common_hierarchy, ics[2 ]))
14581507 systems = get_systems (sys)
14591508 # for each subsystem, get its ignored connections, add the name of the subsystem
14601509 # to the hierarchy and concatenate corresponding buffers of the result
@@ -1463,7 +1512,8 @@ function ignored_connections(sys::AbstractSystem)
14631512 (map (Base. Fix2 (push!, nameof (subsys)), sub_ics[1 ]),
14641513 map (Base. Fix2 (push!, nameof (subsys)), sub_ics[2 ]))
14651514 end
1466- return (Vector {HierarchySystemT} (result[1 ]), Vector {HierarchyVariableT} (result[2 ]))
1515+ return (Vector {HierarchyAnalysisPointT} (result[1 ]),
1516+ Vector {HierarchyAnalysisPointT} (result[2 ]))
14671517end
14681518
14691519"""
0 commit comments