Order is lost with alias variables (FMI 3).
HansOlsson opened this issue · comments
Model variables can be declared in an arbitrary order in <fmiModelDescription><ModelVariables>
for FMI 3.
That allows them to match the structure of an existing (Modelica) model - including the declaration order.
However, in the original model the list of variables includes variables that will become aliases, whereas in
<fmiModelDescription><ModelVariables>
the aliases are not ordered together with other variables (they are listed under their "main"-variable).
That means it is not possible to recreate the original model structure - including order of declarations (if there are any alias-variables).
@HansOlsson : Could you please motivate, for which use cases it would be important to recreate the original model structure.
Recreating the original model structure (including declaration order within them) is useful for:
- Convenience - people are used to seeing the variables, and components, in a certain logical order.
- Animations in Dymola
If the goal weren't to recreate the original model structure the entire idea with ModelVariables mixing various types of variables wouldn't be needed, and I'm not sure if we would need alias-variables at all.
As an example of convenience consider Modelica.Mechanics.Rotational.Examples.CoupledClutches from MSL.
Originally the order is as follows (corresponding to what the user wrote):
Assumedly the user has some reason for that ordering.
Exporting it as FMI 3 (seen below) and trying to re-create the order will not work well as phi and tau will be in different order in different structured components, and the torque cannot be placed as it is entirely an alias:
The corresponding XML document:
Coupled.zip
A possible solution is (an annotation on the variable, or optional attribute) declarationOrder giving an order for the variable and each possible alias as part of a global order (mixing aliases and normal variables).
As follows:
modelDescription.zip
Smaller group at FMI-Design Meeting (Torsten S., Chrstian, Johannes, Markus F., Otto)
We intentionally got rid of the order-based indices in FMI 3.
We propose that Dymola goes on with the vendor-specific annotation, and not standardize this. Could also be handled in a separate file in the /extra file.