@@ -1421,9 +1421,34 @@ function assertions(sys::AbstractSystem)
1421
1421
return merge (asserts, namespaced_asserts)
1422
1422
end
1423
1423
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
+
1424
1445
const HierarchyVariableT = Vector{Union{BasicSymbolic, Symbol}}
1425
1446
const HierarchySystemT = Vector{Union{AbstractSystem, Symbol}}
1426
1447
"""
1448
+ The type returned from `analysis_point_common_hierarchy`.
1449
+ """
1450
+ const HierarchyAnalysisPointT = Vector{Union{IgnoredAnalysisPoint, Symbol}}
1451
+ """
1427
1452
The type returned from `as_hierarchy`.
1428
1453
"""
1429
1454
const HierarchyT = Union{HierarchyVariableT, HierarchySystemT}
@@ -1440,6 +1465,29 @@ function from_hierarchy(hierarchy::HierarchyT)
1440
1465
end
1441
1466
end
1442
1467
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
+
1443
1491
"""
1444
1492
$(TYPEDSIGNATURES)
1445
1493
@@ -1466,19 +1514,20 @@ end
1466
1514
"""
1467
1515
$(TYPEDSIGNATURES)
1468
1516
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.
1472
1519
"""
1473
1520
function ignored_connections (sys:: AbstractSystem )
1474
- has_ignored_connections (sys) || return (HierarchySystemT[], HierarchyVariableT[])
1521
+ has_ignored_connections (sys) ||
1522
+ return (HierarchyAnalysisPointT[], HierarchyAnalysisPointT[])
1475
1523
1476
1524
ics = get_ignored_connections (sys)
1477
1525
if ics === nothing
1478
- ics = (HierarchySystemT [], HierarchyVariableT [])
1526
+ ics = (HierarchyAnalysisPointT [], HierarchyAnalysisPointT [])
1479
1527
end
1480
1528
# 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 ]))
1482
1531
systems = get_systems (sys)
1483
1532
# for each subsystem, get its ignored connections, add the name of the subsystem
1484
1533
# to the hierarchy and concatenate corresponding buffers of the result
@@ -1487,7 +1536,8 @@ function ignored_connections(sys::AbstractSystem)
1487
1536
(map (Base. Fix2 (push!, nameof (subsys)), sub_ics[1 ]),
1488
1537
map (Base. Fix2 (push!, nameof (subsys)), sub_ics[2 ]))
1489
1538
end
1490
- return (Vector {HierarchySystemT} (result[1 ]), Vector {HierarchyVariableT} (result[2 ]))
1539
+ return (Vector {HierarchyAnalysisPointT} (result[1 ]),
1540
+ Vector {HierarchyAnalysisPointT} (result[2 ]))
1491
1541
end
1492
1542
1493
1543
"""
0 commit comments