@@ -1421,9 +1421,34 @@ function assertions(sys::AbstractSystem)
14211421 return merge (asserts, namespaced_asserts)
14221422end
14231423
1424+ """
1425+ $(TYPEDEF)
1426+
1427+ Information about an `AnalysisPoint` for which the corresponding connection must be
1428+ ignored during `expand_connections`, since the analysis point has been transformed.
1429+
1430+ # Fields
1431+
1432+ $(TYPEDFIELDS)
1433+ """
1434+ struct IgnoredAnalysisPoint
1435+ """
1436+ The input variable/connector.
1437+ """
1438+ input:: Union{BasicSymbolic, AbstractSystem}
1439+ """
1440+ The output variables/connectors.
1441+ """
1442+ outputs:: Vector{Union{BasicSymbolic, AbstractSystem}}
1443+ end
1444+
14241445const HierarchyVariableT = Vector{Union{BasicSymbolic, Symbol}}
14251446const HierarchySystemT = Vector{Union{AbstractSystem, Symbol}}
14261447"""
1448+ The type returned from `analysis_point_common_hierarchy`.
1449+ """
1450+ const HierarchyAnalysisPointT = Vector{Union{IgnoredAnalysisPoint, Symbol}}
1451+ """
14271452The type returned from `as_hierarchy`.
14281453"""
14291454const HierarchyT = Union{HierarchyVariableT, HierarchySystemT}
@@ -1440,6 +1465,29 @@ function from_hierarchy(hierarchy::HierarchyT)
14401465 end
14411466end
14421467
1468+ """
1469+ $(TYPEDSIGNATURES)
1470+
1471+ Represent an ignored analysis point as a namespaced hierarchy. The hierarchy is built
1472+ using the common hierarchy of all involved systems/variables.
1473+ """
1474+ function analysis_point_common_hierarchy (ap:: IgnoredAnalysisPoint ):: HierarchyAnalysisPointT
1475+ isys = as_hierarchy (ap. input)
1476+ osyss = as_hierarchy .(ap. outputs)
1477+ suffix = Symbol[]
1478+ while isys[end ] == osyss[1 ][end ] && allequal (last .(osyss))
1479+ push! (suffix, isys[end ])
1480+ pop! (isys)
1481+ pop! .(osyss)
1482+ end
1483+ isys = from_hierarchy (isys)
1484+ osyss = from_hierarchy .(osyss)
1485+ newap = IgnoredAnalysisPoint (isys, osyss)
1486+ hierarchy = HierarchyAnalysisPointT ([suffix; newap])
1487+ reverse! (hierarchy)
1488+ return hierarchy
1489+ end
1490+
14431491"""
14441492 $(TYPEDSIGNATURES)
14451493
@@ -1466,19 +1514,20 @@ end
14661514"""
14671515 $(TYPEDSIGNATURES)
14681516
1469- Get the connections to ignore for `sys` and its subsystems. The returned value is a
1470- `Tuple` similar in structure to the `ignored_connections` field. Each system (variable)
1471- in the first (second) element of the tuple is also passed through `as_hierarchy`.
1517+ Get the analysis points to ignore for `sys` and its subsystems. The returned value is a
1518+ `Tuple` similar in structure to the `ignored_connections` field.
14721519"""
14731520function ignored_connections (sys:: AbstractSystem )
1474- has_ignored_connections (sys) || return (HierarchySystemT[], HierarchyVariableT[])
1521+ has_ignored_connections (sys) ||
1522+ return (HierarchyAnalysisPointT[], HierarchyAnalysisPointT[])
14751523
14761524 ics = get_ignored_connections (sys)
14771525 if ics === nothing
1478- ics = (HierarchySystemT [], HierarchyVariableT [])
1526+ ics = (HierarchyAnalysisPointT [], HierarchyAnalysisPointT [])
14791527 end
14801528 # turn into hierarchies
1481- ics = (map (as_hierarchy, ics[1 ]), map (as_hierarchy, ics[2 ]))
1529+ ics = (map (analysis_point_common_hierarchy, ics[1 ]),
1530+ map (analysis_point_common_hierarchy, ics[2 ]))
14821531 systems = get_systems (sys)
14831532 # for each subsystem, get its ignored connections, add the name of the subsystem
14841533 # to the hierarchy and concatenate corresponding buffers of the result
@@ -1487,7 +1536,8 @@ function ignored_connections(sys::AbstractSystem)
14871536 (map (Base. Fix2 (push!, nameof (subsys)), sub_ics[1 ]),
14881537 map (Base. Fix2 (push!, nameof (subsys)), sub_ics[2 ]))
14891538 end
1490- return (Vector {HierarchySystemT} (result[1 ]), Vector {HierarchyVariableT} (result[2 ]))
1539+ return (Vector {HierarchyAnalysisPointT} (result[1 ]),
1540+ Vector {HierarchyAnalysisPointT} (result[2 ]))
14911541end
14921542
14931543"""
0 commit comments