@@ -1368,104 +1368,6 @@ struct IgnoredAnalysisPoint
13681368 outputs:: Vector{Union{BasicSymbolic, AbstractSystem}}
13691369end
13701370
1371- const HierarchyVariableT = Vector{Union{BasicSymbolic, Symbol}}
1372- const HierarchySystemT = Vector{Union{AbstractSystem, Symbol}}
1373- """
1374- The type returned from `analysis_point_common_hierarchy`.
1375- """
1376- const HierarchyAnalysisPointT = Vector{Union{IgnoredAnalysisPoint, Symbol}}
1377- """
1378- The type returned from `as_hierarchy`.
1379- """
1380- const HierarchyT = Union{HierarchyVariableT, HierarchySystemT}
1381-
1382- """
1383- $(TYPEDSIGNATURES)
1384-
1385- The inverse operation of `as_hierarchy`.
1386- """
1387- function from_hierarchy (hierarchy:: HierarchyT )
1388- namefn = hierarchy[1 ] isa AbstractSystem ? nameof : getname
1389- foldl (@view hierarchy[2 : end ]; init = hierarchy[1 ]) do sys, name
1390- rename (sys, Symbol (name, NAMESPACE_SEPARATOR, namefn (sys)))
1391- end
1392- end
1393-
1394- """
1395- $(TYPEDSIGNATURES)
1396-
1397- Represent an ignored analysis point as a namespaced hierarchy. The hierarchy is built
1398- using the common hierarchy of all involved systems/variables.
1399- """
1400- function analysis_point_common_hierarchy (ap:: IgnoredAnalysisPoint ):: HierarchyAnalysisPointT
1401- isys = as_hierarchy (ap. input)
1402- osyss = as_hierarchy .(ap. outputs)
1403- suffix = Symbol[]
1404- while isys[end ] == osyss[1 ][end ] && allequal (last .(osyss))
1405- push! (suffix, isys[end ])
1406- pop! (isys)
1407- pop! .(osyss)
1408- end
1409- isys = from_hierarchy (isys)
1410- osyss = from_hierarchy .(osyss)
1411- newap = IgnoredAnalysisPoint (isys, osyss)
1412- hierarchy = HierarchyAnalysisPointT ([suffix; newap])
1413- reverse! (hierarchy)
1414- return hierarchy
1415- end
1416-
1417- """
1418- $(TYPEDSIGNATURES)
1419-
1420- Represent a namespaced system (or variable) `sys` as a hierarchy. Return a vector, where
1421- the first element is the unnamespaced system (variable) and subsequent elements are
1422- `Symbol`s representing the parents of the unnamespaced system (variable) in order from
1423- inner to outer.
1424- """
1425- function as_hierarchy (sys:: Union{AbstractSystem, BasicSymbolic} ):: HierarchyT
1426- namefn = sys isa AbstractSystem ? nameof : getname
1427- # get the hierarchy
1428- hierarchy = namespace_hierarchy (namefn (sys))
1429- # rename the system with unnamespaced name
1430- newsys = rename (sys, hierarchy[end ])
1431- # and remove it from the list
1432- pop! (hierarchy)
1433- # reverse it to go from inner to outer
1434- reverse! (hierarchy)
1435- # concatenate
1436- T = sys isa AbstractSystem ? AbstractSystem : BasicSymbolic
1437- return Union{Symbol, T}[newsys; hierarchy]
1438- end
1439-
1440- """
1441- $(TYPEDSIGNATURES)
1442-
1443- Get the analysis points to ignore for `sys` and its subsystems. The returned value is a
1444- `Tuple` similar in structure to the `ignored_connections` field.
1445- """
1446- function ignored_connections (sys:: AbstractSystem )
1447- has_ignored_connections (sys) ||
1448- return (HierarchyAnalysisPointT[], HierarchyAnalysisPointT[])
1449-
1450- ics = get_ignored_connections (sys)
1451- if ics === nothing
1452- ics = (HierarchyAnalysisPointT[], HierarchyAnalysisPointT[])
1453- end
1454- # turn into hierarchies
1455- ics = (map (analysis_point_common_hierarchy, ics[1 ]),
1456- map (analysis_point_common_hierarchy, ics[2 ]))
1457- systems = get_systems (sys)
1458- # for each subsystem, get its ignored connections, add the name of the subsystem
1459- # to the hierarchy and concatenate corresponding buffers of the result
1460- result = mapreduce (Broadcast. BroadcastFunction (vcat), systems; init = ics) do subsys
1461- sub_ics = ignored_connections (subsys)
1462- (map (Base. Fix2 (push!, nameof (subsys)), sub_ics[1 ]),
1463- map (Base. Fix2 (push!, nameof (subsys)), sub_ics[2 ]))
1464- end
1465- return (Vector {HierarchyAnalysisPointT} (result[1 ]),
1466- Vector {HierarchyAnalysisPointT} (result[2 ]))
1467- end
1468-
14691371"""
14701372$(TYPEDSIGNATURES)
14711373
0 commit comments