-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modelica functions and operators in Flat Modelica #2513
Conversation
This adds a list of functions and operators in Modelica; we need to discuss which ones should be supported by Flat Modelica importers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any overloading for the following that just returns an integer-matrix: identity,
or general integer-arrays: zeros, ones, or real-vector: linspace. (Even if you give integer arguments to linspace the result may contain reals).
I don't see a need for anything special for ndims, etc, der etc. (except that sample is overloaded for synchronous).
I'm unsure which tool changes sum(... for i in ...)
to sum({...})
since they should not always be semantically equivalent. The sum-reduction sums over the argument (and may return a non-scalar), the sum of array sums all element of the array down to scalars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I find this sort of list a very good starting point for our discussions. If discussed in the next web meeting, I think it will be good enough to be merged, and then we can create separate PRs for the different parts where we disagree.
RationaleMCP/0031/functions.md
Outdated
* size(A,i) | ||
* size(A) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest not seeing size
as a function, as it makes more sense to think of as an expression operating on the type of the first argument rather than the value.
RationaleMCP/0031/functions.md
Outdated
|
||
### Probably should be in Flat Modelica as is | ||
|
||
* ndims |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment regarding size
.
RationaleMCP/0031/functions.md
Outdated
|
||
* EnumType(i) (indexed constant array, etc) | ||
* Integer(enum) (easy to implement even if it could be a Flat Modelica function) | ||
* semiLinear |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's possible to implement semiLinear
in Flat Modelica, as the semantics depends on being able to identify certain forms of equations involving semiLinear
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Web Meeting:
Should semiLinear be a built-in function:
Yes: 4
No: 0
Apply this change [Martin]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should EnumType be a built-in function?
Yes: 1
No: 1
To be decided later
RationaleMCP/0031/functions.md
Outdated
* identity | ||
* diagonal | ||
* zeros | ||
* ones | ||
* fill | ||
* linspace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit concerned about efficiency if these are removed. Besides, I think we would need to get those input constant Integer
to functions that can be used to statically determine the type of the result based on the arguments and the function signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Web Meeting:
Should these array functions be built-in functions?
Yes: 3
No: 0
Decision to list these as built-in functions.
Apply the change [Martin]
* delay | ||
* spatialDistribution | ||
* homotopy | ||
* sample |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could possibly deoverload sample, but does not seem necessary. Agreed.
* scalar | ||
* vector | ||
* matrix | ||
* cat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed to keep in flat Modelica.
|
||
### Odd ones | ||
|
||
* String (quite complicated function with many kinds of arguments; could be de-overloaded before Flat Modelica) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep it as it is.
Meeting 2020-03-17
|
||
### Do we need restrictions compared to Modelica? | ||
|
||
* der |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
der(x+y)
- hard to expand, and code bloat. Keep as in regular Modelica.
### Do we need restrictions compared to Modelica? | ||
|
||
* der | ||
* noEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As before, simplification not needed.
|
||
* der | ||
* noEvent | ||
* smooth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See noEvent
* pre | ||
* edge | ||
* change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could remove edge/change, but won't.
* pre | ||
* edge | ||
* change | ||
* reinit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep
* transpose | ||
* outerProduct | ||
* symmetric | ||
* cross | ||
* skew |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works on any kind of array type, easiest to keep
RationaleMCP/0031/functions.md
Outdated
* min | ||
* max | ||
* sum | ||
* product | ||
* array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep both variants (array input and reduction). Agreed.
* EnumType(i) (indexed constant array, etc) | ||
* Integer(enum) (easy to implement even if it could be a Flat Modelica function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep (same as String). Agreed.
This adds a list of functions and operators in Modelica; we need to
discuss which ones should be supported by Flat Modelica importers.