Title: New Width Inference Algorithm
1New Width Inference Algorithm
Rationale In Ptolemy II relations can have
multiple channels, each one representing a
sequence of tokens. The number of channels is
specified by the width of a relation. Having to
explicitly specify the width for each relation
can be a tedious job. To make it even worse, the
addition of one relation to a multiport might
result in a model builder needing to go through
the model again to adapt widths. To cope with
this you can let the relations infer the width
from other relations or other ports with a graph
algorithm.
Constraints mechanism on ports
Restricted existing algorithm Only one relation
to be inferred at each port
Width of relation connected to output, has to be
equal to True and False input.
output.setWidthEquals(trueInput) output.setWidthE
quals(falseInput)
Performance
- Properties of new algorithm
- Widths are propagated
- Each relation is only visited once
- Not all widths can be inferred
- More expensive algorithm
- Initialization step O(total number of relations)
2A graph algorithm is often a trade-off between
completeness of the algorithm and the complexity
of the algorithm. There was already an existing
fast implementation that had many limitations and
hence we tried to come up with a solution that
can infer the width for most scenarios without
imposing a large performance cost. The algorithm
propagates the widths it knows and at multiports
tries to infer the widths of other relations from
these propagated widths. However there are some
cases that don't work.
Models that fail