# Using multiple rollups in a single part definition

**URL:** <https://forum.sensmetry.com/t/using-multiple-rollups-in-a-single-part-definition/290>\
**Category:** Bug Reports\
**Tags:** automator\
**Created:** [November 10, 2025, 11:11am UTC](https://forum.sensmetry.com/t/using-multiple-rollups-in-a-single-part-definition/290 "2025-11-10T11:11:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Axel](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@Axel](https://forum.sensmetry.com/u/Axel)\
**Post date:** [November 10, 2025, 11:11am UTC](https://forum.sensmetry.com/t/using-multiple-rollups-in-a-single-part-definition/290/1 "2025-11-10T11:11:33Z")

</div>

Hello,

I’ve got a somewhat complex example here of using multiple rollups in a single part definition. Since in a real use case I expect that you would typically have more than one attribute to roll up (e.g., mass, cost, power), this is my attempt to achieve that by re-using a single rollup definition in several specializations. If this is the totally wrong way to go about this, please let me know.

See the attached files with the model and python code:

[multi\_rollup.sysml](https://forum.sensmetry.com/uploads/short-url/fuSVyqGSXBQ0iwZ8ssEpRSGC4zM.sysml) (1.6 KB)

[multi\_rollup.py.txt](https://forum.sensmetry.com/uploads/short-url/1S0eKOS2bPuyFgO98Ngch535wkO.txt) (2.7 KB)

The output of my python script becomes:

```auto
{'subsystem1': {'cost': 1000,
                'mass': 1,
                'power': 10,
                'totalCost': <syside.core.AttributeUsage object at 0x7df7a3a5ee90>,
                'totalMass': <syside.core.AttributeUsage object at 0x7df7a3a5ecf0>,
                'totalPower': <syside.core.AttributeUsage object at 0x7df7a3a5ee70>},
 'subsystem2': {'cost': 2000,
                'mass': 2,
                'power': 20,
                'totalCost': <syside.core.AttributeUsage object at 0x7df7a3a5ee90>,
                'totalMass': <syside.core.AttributeUsage object at 0x7df7a3a5ecf0>,
                'totalPower': <syside.core.AttributeUsage object at 0x7df7a3a5ee70>},
 'system': {'cost': 10000,
            'mass': 10,
            'power': 0,
            'totalCost': <syside.core.AttributeUsage object at 0x7df7a3a5ee90>,
            'totalMass': <syside.core.AttributeUsage object at 0x7df7a3a5ecf0>,
            'totalPower': <syside.core.AttributeUsage object at 0x7df7a3a5ee70>}}

```

I think something is breaking when the `totalValue` attribute gets renamed, like in `attribute totalMass redefines totalValue`.

When I tried this with `SystemProduct` only specializing `MassedCompositeThing` and without renaming `totalValue` to `totalMass`, the rollup still worked even after renaming `value` to `mass`. But once the line `attribute totalMass redefines totalValue;` is added, the `totalMass` attribute no longer correctly evaluates to a number like you see in the printed output above.

I expect something could also be going wrong with the `system::components` attribute since `components` is being inherited 3 times (from each Rollup being specialized) and I don’t know how that’s getting handled in the background.

Any thoughts on what is going on here?

---

<div class="post-metadata">

**Author:** ![Daumantas](https://yyz2.discourse-cdn.com/flex008/user_avatar/forum.sensmetry.com/daumantas/32/19_2.png) [@Daumantas](https://forum.sensmetry.com/u/Daumantas)\
**Post date:** [November 10, 2025, 12:33pm UTC](https://forum.sensmetry.com/t/using-multiple-rollups-in-a-single-part-definition/290/2 "2025-11-10T12:33:56Z")

</div>

Hi Axel,

This looks like a typical case of multiple-inheritance gone wrong, especially when combined with redefinitions. Conceptually, _redefinitions_ do not create new features, they instead _overwrite_ them. So when your `SystemProduct` inherits multiple renamed `values`, all `mass`, `power`, and `cost` actually point to the same inherited `value` feature. SysML hides this catastrophic error by allowing redefining features to have different names. (Not to mention that this requires linear search for specific features when evaluating them on a type instead of looking them up by name in constant time like in all other sane languages.)

---

<div class="post-metadata">

**Author:** ![Axel](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@Axel](https://forum.sensmetry.com/u/Axel)\
**Post date:** [November 10, 2025, 4:37pm UTC](https://forum.sensmetry.com/t/using-multiple-rollups-in-a-single-part-definition/290/3 "2025-11-10T16:37:49Z")

</div>

Hi Daumantas,

Ok that sounds pretty bad. But how does that interpretation fit with the observation that mass, cost and power (not the totals) have distinct values even though you say they are all pointing to the same attribute from the rollup package? It’s just the total calculation that fails, and this failure already appears once the totalValue attribute gets renamed by the redefine, even if SystemProduct is only inheriting from one part definition.

If this approach really is doomed, do you have any ideas about how to make this kind of use case possible to implement? Is there really no way to roll up multiple values with the rollup pattern extracted as a generic package?

---

<div class="post-metadata">

**Author:** ![Daumantas](https://yyz2.discourse-cdn.com/flex008/user_avatar/forum.sensmetry.com/daumantas/32/19_2.png) [@Daumantas](https://forum.sensmetry.com/u/Daumantas)\
**Post date:** [November 11, 2025, 7:55am UTC](https://forum.sensmetry.com/t/using-multiple-rollups-in-a-single-part-definition/290/4 "2025-11-11T07:55:25Z")

</div>

> But how does that interpretation fit with the observation that mass, cost and power (not the totals) have distinct values even though you say they are all pointing to the same attribute from the rollup package?

That is the hidden problem - they are technically not distinct even if no analysers/specification catch it yet.

> If this approach really is doomed, do you have any ideas about how to make this kind of use case possible to implement? Is there really no way to roll up multiple values with the rollup pattern extracted as a generic package?

Rather than redefining the same features multiple times, make the features distinct. For example,

```sysml
part def CompositeThing {
    part components : CompositeThing [*] default null;
}

part def MassedCompositeThing specializes CompositeThing {
    attribute mass : Real default 0;
    attribute totalMass = mass + NumericalFunctions::sum(components.totalMass);
}
part def PoweredCompositeThing specializes CompositeThing {
    attribute power : Real default 0;
    attribute totalPower = power + NumericalFunctions::sum(components.totalPower);
}
part def CostlyCompositeThing specializes CompositeThing {
    attribute cost : Real default 0;
    attribute totalCost = cost + NumericalFunctions::sum(components.totalCost);
}

```

A little boiler-platy but not by that much given that the attributes were redefined previously. Ideally, there would be generics in SysML that would make this much easier.
