Skip to content
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

Merged
merged 3 commits into from
Mar 27, 2020

Conversation

sjoelund
Copy link
Member

This adds a list of functions and operators in Modelica; we need to
discuss which ones should be supported by Flat Modelica importers.

This adds a list of functions and operators in Modelica; we need to
discuss which ones should be supported by Flat Modelica importers.
Copy link
Collaborator

@HansOlsson HansOlsson left a 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.

Copy link
Collaborator

@henrikt-ma henrikt-ma left a 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.

Comment on lines 39 to 40
* size(A,i)
* size(A)
Copy link
Collaborator

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.


### Probably should be in Flat Modelica as is

* ndims
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment regarding size.


* EnumType(i) (indexed constant array, etc)
* Integer(enum) (easy to implement even if it could be a Flat Modelica function)
* semiLinear
Copy link
Collaborator

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.

Copy link
Collaborator

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]

Copy link
Collaborator

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

Comment on lines 68 to 73
* identity
* diagonal
* zeros
* ones
* fill
* linspace
Copy link
Collaborator

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.

Copy link
Collaborator

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]

Comment on lines +42 to +45
* delay
* spatialDistribution
* homotopy
* sample
Copy link
Member Author

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.

Comment on lines +48 to +51
* scalar
* vector
* matrix
* cat
Copy link
Member Author

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)
Copy link
Member Author

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.


### Do we need restrictions compared to Modelica?

* der
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See noEvent

Comment on lines +63 to +65
* pre
* edge
* change
Copy link
Member Author

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep

Comment on lines +74 to +78
* transpose
* outerProduct
* symmetric
* cross
* skew
Copy link
Member Author

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

Comment on lines 91 to 95
* min
* max
* sum
* product
* array
Copy link
Member Author

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.

Comment on lines +72 to +73
* EnumType(i) (indexed constant array, etc)
* Integer(enum) (easy to implement even if it could be a Flat Modelica function)
Copy link
Member Author

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.

@sjoelund sjoelund merged commit 72d227e into MCP/0031 Mar 27, 2020
@sjoelund sjoelund deleted the MCP/0031+functions branch March 27, 2020 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants